使用LdapConnection连接到OpenLDAP时出错

Bre*_*ead 5 .net c# active-directory ldapconnection openldap

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

我尝试使用身份验证类型以及身份验证类型.但是它会出现"可分辨名称包含无效语法"的错误

还有一件事是,我不能使用System.DirectoryServices,因为它仅适用于Active Directory,这就是我使用System.DirectoryServices.Protocol的原因.

谢谢!

小智 10

这篇MSDN博客文章可能会对您的问题有所了解.试试这个:

    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"));
    }
Run Code Online (Sandbox Code Playgroud)