使用LDAP连接时出现异常

时间:2016-06-22 10:13:27

标签: c# ldap

使用LDAP连接时出现以下错误

  

Connection.freeWriteSemaphore(-2):信号量不归任何线程所有    我使用以下代码

 public static bool Authenticate(string userName, string password)
    {
        //logger.Debug("Try to connect to LDAP to authenticate user with " + userName + "/***");

        string uDN = ldapUserDN.Replace("$UID", userName);


        bool flag = false;
        LdapConnection ldapConn = new LdapConnection();
        try
        {
            ldapConn.Connect(ldapServer, int.Parse(ldapServerPort));
            ldapConn.Bind(uDN, password);
            flag = ldapConn.Bound;
        }
        catch (Exception ex)
        {
            //logger.Error("Exception in Authenticate():", ex);
        }
        finally
        {
            ldapConn.Disconnect();
        }


        return flag;
    }

0 个答案:

没有答案