【发布时间】:2011-08-05 08:46:24
【问题描述】:
我正在尝试从我的控制台应用程序访问 XXX 域中的目录。
DirectoryEntry oDE = new DirectoryEntry("LDAP://DC=XXXX,DC=myDomain,DC=com");
using (DirectorySearcher ds = new DirectorySearcher(oDE))
{
ds.PropertiesToLoad.Add("name");
ds.PropertiesToLoad.Add("userPrincipalName");
ds.Filter = "(&(objectClass=user))";
SearchResultCollection results = ds.FindAll();
foreach (SearchResult result in results)
{
Console.WriteLine("{0} - {1}",
result.Properties["name"][0].ToString(),
result.Properties["userPrincipalName"][0].ToString());
}
}
当行 SearchResultCollection results = ds.FindAll();执行我收到错误“服务器上没有这样的对象。”
我做错了什么?
【问题讨论】:
-
是否需要提供任何身份验证才能访问目录条目?
-
您是否确定也更改了 LDAP Uri 中的其他 3 个部分?如果您的域是 DomainXXX.lan;它需要是 DC=DomainXXX,DC=lan
-
外部域 = XXXX.com MyDomain = test.com DirectoryEntry oDE = new DirectoryEntry("LDAP://DC=XXX.com,DC=test,DC=com");我认为是这样。
-
不,这不正确。如果您的服务器名称 = DomainServerA.SomeCompany.net,您的 Uri 将是:LDAP://DC=DomainServerA,DC=SomeCompany,DC=net
-
实际上我想从我的控制台应用程序中访问并验证用户是否存在于以下域的 AD 中。 ldap://Test1.Test2.gov.lk/ 如果是的话如何创建目录条目?
标签: c# active-directory active-directory-group