【问题标题】:LdapConnection port 636 connects without SSLLdapConnection 端口 636 不使用 SSL 连接
【发布时间】:2016-05-03 12:17:23
【问题描述】:

我已经在我的虚拟机中设置了一个 Active Directory 服务器,并根据以下链接启用了 LDAP over SSL: https://support.microsoft.com/en-us/kb/321051

我使用 ldp.exe 来测试我的设置,并且能够连接到端口 636 并选中“SSL”复选框。然后我取消选中“SSL”复选框并再次尝试连接到端口 636。我预计连接会失败,因为端口 636 是为 LDAP over SSL 保留的。然而,令我惊讶的是,连接仍然通过。我很困惑。我可以使用端口 636 但没有 SSL 连接到 Active Directory 是否正常?

public static LdapConnection CreateLdapConnection(string server, int port, bool IsSSL, string userDN, string password, out string err)
{
    err = null;
    LdapConnection con = new LdapConnection(new LdapDirectoryIdentifier(server, port));

    if (IsSSL)
    {
        con.SessionOptions.SecureSocketLayer = true;
        con.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(ServerCallback);
    }
    con.Credential = new NetworkCredential(userDN, password);
    con.AuthType = AuthType.Basic;

    try
    {
        con.Bind();
    }
    catch (Exception ex)
    {
        if (ex.Message.Contains("The supplied credential is invalid"))
        {
            err = "Invalid ldap user password";
        }
        else if (ex.Message.Contains("The LDAP server is unavailable"))
        {
            err = "Invalid server address or port number";
        }
        else
        {
            err = ex.Message;
        }
    }

    return con;
}

我还使用上面的代码在我的应用程序中测试了 ldap 连接,当 IsSSL 变量为 false 时它能够连接。

【问题讨论】:

    标签: ssl active-directory ldap ldapconnection


    【解决方案1】:

    可能是使用 StartTLS 协议,连接以明文开始,然后客户端发出 StartTLS,然后双方升级到 SSL。

    【讨论】:

    • 您好,感谢您的回复。所以“con.SessionOptions.SecureSocketLayer = true;”如果我在这种情况下将端口号设置为 636,实际上根本没有效果?
    • StartTLS 扩展操作通常用于“普通”端口(默认为 389)而不是安全端口。 AD 端似乎存在错误配置,因为当我尝试在不使用 TLS/SSL 的情况下连接到安全端口时收到错误消息
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    相关资源
    最近更新 更多