Hi All,

I need desperate help.

I have a group "MyGroupABC" in Active Directory (AD). In this group there are close to 100 list of users.

How can i write a logic to actually to get me the list of users with their particulars details such as Name, SN, GivenName, Telephone, Mail, etc?

I've been trying many days to figuring it out, but not success.

Below is my simple code.

DirectorySearcher ds = new DirectorySearcher("");
ds.SearchRoot = new DirectoryEntry("LDAP://myserver/CN=MyGroupABC,OU=MyProject,OU=DEVApplications,DC=myserver,DC=local");
ds.PropertyNamesOnly = true;

SearchResultCollection src = ds.FindAll();

   foreach (SearchResult sr in src)
      string str1 = de.name.ToString();
      string str2 = de.sn.ToString();
      string str3 = de.givenName.ToString();
      string str4 = de.mail.ToString();
      string str5 = de.telephoneNumber.ToString();
catch (Exception e)

the ds.FindAll() result get returns empty.

Is there any better way to do around this?


It could be a permissions error, naturally enough your AD is well protected - i'd never recommend querying it directly from a web page you're better building a comm object or something to do it for you and then just pulling back the data from that.