queryn an OpenLDAP server with C#.NET RRS feed

  • Question

  • User-1041979202 posted


    Sorry because I'm Spanish and I don't speak in english very well.

    I need autentication my users against an OpenLDAP server with C#.NET. I'm using the namespace System.DirectoryServices to access an OpenLDAP server but it gives me one error: the server is not operational. I don`t know why it tells me that because the path is correct.

     I'm trying to connect with this OpenLDAP server but I can´t.

    String Path = "LDAP://name of OpenLdap server,DC=ehu,DC=es";

    DirectoryEntry entry = new DirectoryEntry(Path);

    DirectorySearcher search = new DirectorySearcher(entry);

    search.Filter = "uid=username";

    SearchResult result = search.FindOne();


    I know that this namespace is correct to interact with Active Directory but I need another namespace to interact with an OpenLDAP server?



    Wednesday, February 7, 2007 6:36 AM


All replies

  • User-851552593 posted

    DirectoryEntry nRoot = new DirectoryEntry("LDAP://your ip/o=xxx,c=xxx");
    nRoot.AuthenticationType = AuthenticationTypes.None;
    nRoot.Username = "uid=xxx,ou=xxx,o=xxx,c=xx";  //full dn

    nRoot.Password = "xxx";

    DirectorySearcher nDS = new DirectorySearcher(nRoot);
    nDS.SearchScope = SearchScope.Subtree;
    nDS.Filter = "objectClass=*";
    //nDS.PageSize = 1000;

    SearchResult sr = nDS.FindOne();

    I have tried it on openldap, and it works

    Wednesday, February 7, 2007 9:12 PM
  • User-1041979202 posted

    First, thanks for your answer because this subject is very important for me.

    I have one question about your solution. When you tell me:

     DirectoryEntry nRoot = new DirectoryEntry("LDAP://your ip/o=xxx,c=xxx");

    Is it the Ip of the server OpenLDAP? and o=xxx,c=xxx is the DN base no?

    My DN base is in DC=xxx, Dc=xxx.



    Thursday, February 8, 2007 5:45 AM
  • User-851552593 posted


    "LDAP://ldap server ip or url/base dn"

    ex: LDAP://,dc=bbb

    ps:"LDAP" must be upper


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 9, 2007 8:43 PM
  • User-1041979202 posted


    Thank you for your answers.


    Saturday, February 10, 2007 10:54 AM