Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error on connecting to OpenLDAP using LdapConnection

        using (LdapConnection ldap = new LdapConnection("localhost:389"))
        {
            //ldap.AuthType = AuthType.Basic;
            ldap.Bind(new NetworkCredential("cn=manager,dc=wave,dc=com", "secret"));
        }

I tried with both with Authentication type as well with authentication type as basic. but it gives an error that 'The distinguished name contains invalid syntax'

One more thing, is that I can't use System.DirectoryServices, because it works perfect only for Active Directory, thats why I am using System.DirectoryServices.Protocol.

Thanks!

like image 750
BreakHead Avatar asked Jun 26 '12 09:06

BreakHead


1 Answers

This MSDN blog post may shed some light on your problem. Try this:

    using (LdapConnection ldap = new LdapConnection("localhost:389"))
    {
        ldap.AuthType = AuthType.Basic;
        ldap.SessionOptions.ProtocolVersion = 3;
        ldap.Bind(new NetworkCredential("cn=manager,dc=wave,dc=com", "secret"));
    }
like image 139
Alan Avatar answered Sep 27 '22 17:09

Alan