有誰知道在Active Directory中使用DirectoryServices
搜索單個用戶的最佳方法嗎?我有代碼,目前列出給定的LDAP路徑下的所有子'OU',但我現在想要添加搜索路徑下的用戶的功能。代碼是否適合搜索用戶?ASPX C#在Active Directory中搜索用戶
我已經包含了我的代碼,列出了所有用戶在當前的OU:
DirectoryEntry Ldap = new DirectoryEntry("LDAP://" + ouselect.SelectedValue + ";" + LDAPRoot, LDAPUser, LDAPPass);
DirectorySearcher ad_search = new DirectorySearcher(Ldap);
ad_search.Filter = "(objectClass=User)";
ad_search.SearchScope = SearchScope.Subtree;
ad_search.PropertiesToLoad.Add("samaccountname");
任何指針任何人都可以提供將是極好的。
你還是會希望包括過濾器的基礎對象類的組成部分。 –