AD查询USERs中怎么去掉Computers
string domainAndUsername = domain + @"\" + username;
DirectoryEntry entry = new DirectoryEntry( _path,
domainAndUsername, pwd);
try
{
// 绑定到本机 AdsObject 以强制身份验证。
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = ("(objectClass=user)");
foreach(System.DirectoryServices.SearchResult resEnt in search.FindAll())
{
Response.Write( resEnt.Path+"---");
}
结果:
LDAP://jf.com/CN=xuhu,CN=Users,DC=jf,DC=com---
LDAP://jf.com/CN=test,CN=Computers,DC=jf,DC=com---