Last post Apr 19, 2013 09:06 AM by mm10
Apr 19, 2013 07:11 AM|Rauf abid|LINK
I am an administrator of Active directory. I also worked on ASP.net Web applications. I want to get all the user's Emails from active directory programatically. How can i achieve this ???
Thanks in advance.
Apr 19, 2013 08:42 AM|mm10|LINK
List<string> emails = new List<string>();
DirectoryEntry entry = new DirectoryEntry("LDAP://domain");
DirectorySearcher dSearch = new DirectorySearcher(entry);
dSearch.Filter = "(objectClass=user)";
foreach (SearchResult sResultSet in dSearch.FindAll())
if (sResultSet.Properties["mail"].Count > 0)
Apr 19, 2013 08:54 AM|Rauf abid|LINK
Thanks for the reply,
I think the code is ok. but iam getting error which is following.
Logon failure: unknown user name or bad password.
Where to write username and password of active directory to get all users ???
Apr 19, 2013 09:06 AM|mm10|LINK
entry.UserName = "username";
entry.Password = "password"