locked
How to get Email Id of all users from Active directory RRS feed

  • Question

  • User1064890599 posted

    Hello all,

    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.

    Friday, April 19, 2013 7:11 AM

Answers

  • User-917364509 posted

    entry.UserName = "username";
    entry.Password = "password"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 19, 2013 9:06 AM

All replies

  • User-917364509 posted
    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) 
            email.Add(sResultSet.Properties["mail"][0].ToString()); 
    }

    Friday, April 19, 2013 8:42 AM
  • User1064890599 posted

    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 ???

    Thanks.

    Friday, April 19, 2013 8:54 AM
  • User-917364509 posted

    entry.UserName = "username";
    entry.Password = "password"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 19, 2013 9:06 AM