A question of active directory in asp.net

  • Thread starter Thread starter mingjing
  • Start date Start date
M

mingjing

Hello ,everyone:

I want to search domain user in active directory uses those code ,but
the result not return domain user information ,
but only return the domain computer ,how can I resolve the problem!


System.DirectoryServices.DirectoryEntry entry =
new
System.DirectoryServices.DirectoryEntry("LDAP://silan.com/DC=silan,DC=com");
System.DirectoryServices.DirectorySearcher mySearcher = new
System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter = ("(anr=chen)");
string s = "";
foreach(System.DirectoryServices.SearchResult result in
mySearcher.FindAll())
{
s = result.GetDirectoryEntry().Path;
Console.WriteLine(s );
}
 
Hi,
You might want to add (objectClass=user) to the filter condition and try.
Eg:
mySearcher.Filter = "(&(objectClass=user)(anr=chen))";

Hello ,everyone:

I want to search domain user in active directory uses those code ,but
the result not return domain user information ,
but only return the domain computer ,how can I resolve the problem!


System.DirectoryServices.DirectoryEntry entry =
new
System.DirectoryServices.DirectoryEntry("LDAP://silan.com/DC=silan,DC=com");
System.DirectoryServices.DirectorySearcher mySearcher = new
System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter = ("(anr=chen)");
string s = "";
foreach(System.DirectoryServices.SearchResult result in
mySearcher.FindAll())
{
s = result.GetDirectoryEntry().Path;
Console.WriteLine(s );
}
 
Back
Top