gpt4 book ai didi

.net - 将用户添加到事件目录中的安全组

转载 作者:行者123 更新时间:2023-12-04 07:09:45 25 4
gpt4 key购买 nike

使用任何 .NET 框架

我能够创建安全组,但是当我尝试从同一域中添加用户时,我收到错误消息。

使用 System.DirectoryServices.AccountManagement :

TheGroup = GroupPrincipal.FindByIdentity(SecurityContext, "GROUPNAME")
TheGroup.Members.Add(SecurityContext, IdentityType.SamAccountName, "username")
TheGroup.Save()

一切都适用于创建和获取现有组。添加成员也有效,但是当我尝试保存对组所做的更改时,出现此错误:

Information about the domain could not be retrieved (1355).



现在不使用 DirectoryServices.AccountManagement :
Dim dGroup As DirectoryEntry = GetDirectoryEntry(GroupPath, UserName, Password)
dGroup.Properties("member").Add(nUser.Path)
dGroup.CommitChanges()
dGroup.Close()

再次以这种方式创建/删除组工作正常,但是当我尝试将确实存在的成员添加到创建的组时,我收到此错误:

The server is unwilling to process the request. (Exception from HRESULT: 0x80072035)



进入运行 AD 本身的服务器,我可以添加组并将用户放入其中。我正在使用相同的凭据。

最佳答案

只是猜测:您可能会收到此错误,因为您尝试添加到安全组的用户没有遵循您的域密码策略的密码。

关于.net - 将用户添加到事件目录中的安全组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/562585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com