locked
Connect to ActiveDirectory using DirectoryEntry RRS feed

  • Question

  • Hi,

    I want to connect with an AD server;

    This is how I try:

    // ldap=OU=Employees,DC=xxxxxx,DC=yyyyyyy,DC=kkk  
    // port = 389;
    string ldapPath = "LDAP://" + serverName + ":" + port + "/" + ldap;    
    using (DirectoryEntry rootEntry = new DirectoryEntry(ldapPath))
    {
                    //username does not contain the prefix: CN=xxxxxx\
                    rootEntry.Username = username;
                    rootEntry.Password = password;

                    object k = rootEntry.NativeObject;
    }

    Can you tell me what am I doing wrong?
    I have the ADExplorer tool, and successfully connected there, without stating the server name at all ! (only domain, user and password)

    Thursday, February 25, 2010 11:36 AM

Answers