English 中文(简体)
LDAP Directory entry in .Net - not working with OU=Users
原标题:LDAP Directory Entry in .Net - not working with OU=Users
  • 时间:2009-09-10 12:31:36
  •  标签:
问题回答

我尝试的第一项尝试是,在你创建名录时,不要把你所希望的道路code起来:

DirectoryEntry de = new DirectoryEntry("LDAP://OU=Users,DC=company,DC=local");

如果这是你积极名录中的一种实际途径,这将迅速告诉你。 我不知道你的促动会是什么样子,如果这是一条有效的道路,我可以告诉你。 如果这一途径是正确的,那么在你积极的用户和计算机MMC的gin子下,你应该拥有根基,在根称为用户的 root子下拥有一根。

途径在反倾销中出现倒退,这样,如果你愿意的话。 使用者的双管齐下是另一个根基,而不是它。

DirectoryEntry de = new DirectoryEntry("LDAP://OU=Users,OU=<first OU folder>,DC=company,DC=local");

因此,您的推荐方案希望:

 Root 
 |
 --><first OU folder>
     |
     -->Users

关于如何管理主动名录的一篇重要文章。 NET:

• 如何通过C#在主动目录中实现(几乎所有)

您也不妨研究该系统。 Directory Servicess, System.Directory Servicess.ActiveDirectory, and the System.Directoryservices.AccountManagement namespaces provided in the .Net 3.5 Framework. 我认为制度。 名录服务公司和主动发射器名称空间在1.Net 1.1中可供使用,账户管理在.Net 3.5中实行。

http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx” rel=“nofollow noreferer”>Microsoft Documentation - 关于如何使用名称空间的许多良好联系

增编:

要想在自动协调机制中找到用户,你将做以下工作:

 DirectoryEntry de = new DirectoryEntry();
 de.Path = "LDAP://DC=company,DC=local";
 de.AuthenticationType = AuthenticationTypes.Secure;

 DirectorySearcher deSearch = new DirectorySearcher();

 deSearch.SearchRoot = de;
 deSearch.Filter = "(&(objectClass=user) (cn=" + username + "))";

 SearchResult result = deSearch.FindOne();

 if (result != null)
 {
     DirectoryEntry deUser = new DirectoryEntry(result.Path);
     ... do what ever you need to the deUser
     deUser.Close();
 }

这可能看起来是sil和 st,但是,在活跃的台上安装的 default树不是OU=Us,dc=domain,dc=com,而是<>cn=Users,dc=domain,dc=com (注:CN=不是用户的OU=用户。)

看来是站不住脚的,因为在反倾销中,集装箱物体(cn的物体)不能成为集团政策的接受者,但出于我不理解的原因,这就是违约。 (实际上,我确实理解,这是因为对一个国家的遏制比对乌的管制更为类似。)

我几乎每个人都会聚一堂,他们第一次试图将LDAP/auth约束到AD。

As geoffc mentioned correctly, in Active Directory the "Users" under the domain is a container object rather than organizational unit object. This results in a totally different LDAP path which is why you get the error message.

处理以下问题:

// Replace the "company" and "com" with actual domain values...
DirectoryEntry de = new DirectoryEntry("LDAP://CN=Users,DC=company,DC=com");
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;

// Set your other search params here




相关问题
热门标签