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;
ds.PropertiesToLoad.Add("name");
ds.PropertiesToLoad.Add("sn");
ds.PropertiesToLoad.Add("givenName");
ds.PropertiesToLoad.Add("mail");
ds.PropertiesToLoad.Add("telephoneNumber");

SearchResultCollection src = ds.FindAll();

try 
{
   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)
{
   MessageBox.Show(e.Message);
}

the ds.FindAll() result get returns empty.

Is there any better way to do around this?

Hi,

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.