locked
How to get active directory groups membership of a user RRS feed

  • Question

  • Hi,

    I want to query with ldap for retireving the group names of a user which is member of but i couldn't write the ldap query. Is there a template for this query?

    What is searchDN and searcher.Filter for this specific task ? Here is the code sample :

     

    string server = "myserver";
    string port = "111";
    string searchDN = "ou=People,dc=myDomain";?????

     

    string filter = "uid=" + "myUserName";
    string fullUserName = filter + "," + searchDN;
    string path = "LDAP://" + server + ":" + port + "/" + searchDN;

     

     

    DirectoryEntry entry = new DirectoryEntry(path);
    entry.AuthenticationType =
    AuthenticationTypes.ServerBind;
    entry.Username = fullUserName;
    entry.Password =
    "******";

     

    DirectorySearcher searcher = new DirectorySearcher(entry);
    searcher.SearchScope =
    SearchScope.Subtree;
    searcher.ReferralChasing =
    ReferralChasingOption.All;
    searcher.Filter =
    ??????;
    SearchResultCollection result = searcher.FindAll();





    Kutlu Araslı
    Monday, August 17, 2009 2:26 PM

Answers