kk m

kk m

  • NA
  • 4
  • 0

Get users's group information from Active Directory

Jan 16 2008 8:32 PM
Hello,

I have the following code which queries all the users in an active directory. I need to get the group name and users full name for each user using c#.

Any help with code or a resource reference will of great help.

Thank you in advance.


private String adspath = "LDAP://dc=adserver,dc=netsweeper,dc=com";
private String username = "smanager";
private String password = "password";
private DBOperations dbdata ;
DirectoryEntry entry = new DirectoryEntry(this.adspath, this.username, this.password, AuthenticationTypes.Secure);
DirectorySearcher srch = new DirectorySearcher(entry);
//srch.SearchScope = SearchScope.Subtree;
srch.Filter = "(objectClass=User)";

foreach (SearchResult result in results)
{
if (result.Equals(null))
Console.WriteLine("Did not find any results");
else
Console.WriteLine("Initial find "+results.Count+" "+result.Path);

}
Edit/Delete Message

Answers (4)