【发布时间】:2018-09-16 12:25:17
【问题描述】:
我正在尝试创建一个用户并将其添加到 3 个组,创建工作正常,但将用户添加到组有时它可以工作,有时会显示此错误:
服务器上没有这样的对象
我将用户添加到组的代码:
try
{
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + group, ADUsername, ADPassword);
if (dirEntry != null)
{
dirEntry.Properties["member"].Add(userPrincipal.DistinguishedName);
dirEntry.CommitChanges();
dirEntry.Close();
}
}
catch (System.DirectoryServices.DirectoryServicesCOMException E)
{
//doSomething with E.Message.ToString();
}
【问题讨论】:
标签: c# asp.net active-directory ldap active-directory-group