Mar*_*rco 9 c# active-directory account-management
这是我的代码示例
var domainContext = new PrincipalContext(ContextType.Domain, "domain_server_ip",
"domain_admin_username", "domain_admin_password");
var group = GroupPrincipal.FindByIdentity(domainContext, "mygroup");
var users = group.Members.Where(member => names.Contains(member.Name))
.ToList();
users.ForEach(u => group.Members.Remove(u));
group.Save(domainContext); // <-- Here I get the error
Run Code Online (Sandbox Code Playgroud)
如果我尝试获取用户组,则会出现相同的错误
var user = UserPrincipal.FindByIdentity(domainContext, "username");
var gps = user.GetGroups(domainContext).ToList(); // <-- Here I get the error
Run Code Online (Sandbox Code Playgroud)
我尝试ContextOptions.SimpleBind
连接使用,但没有任何改变.
我也尝试过连接设置容器名称,但是没有任何改变.
请注意,我能够检索该组及其成员......所以我不明白为什么我无法保存组或读取用户组.