【问题标题】:LDAP to LDAPS URL Change (.Net MVC)LDAP 到 LDAPS URL 更改 (.Net MVC)
【发布时间】:2016-08-03 03:51:32
【问题描述】:

我的应用程序正在使用 AD 身份验证使用 LDAP URL 登录。一切都很好,直到我们的 SA 告诉我们将 URL 更改为 LDAPS。一旦我将 URL 添加为 LDAPS,它就会引发异常并且不允许用户登录。请帮帮我。

Working LDAP URL: LDAP://reg1.abc.com
LDAPS URL (NEW) : LDAPS://reg1.abc.com (Not working once changed)

以下是通过 LDAP 验证用户的代码。

    public static SearchResult AuthenticateUser(string userName, string password)
    {
        var directoryEntry = new DirectoryEntry(ConfigurationManager.AppSettings["ActiveDirectoryPath"], userName, password, AuthenticationTypes.Secure);
        var directorySearcher = new DirectorySearcher(directoryEntry);
        directorySearcher.Filter = "(samaccountname=" + userName + ")";
        var result = directorySearcher.FindOne();
        return result;
    }

【问题讨论】:

    标签: asp.net-mvc authentication active-directory ldap


    【解决方案1】:

    这是一个常见问题,Unknown Error (0x80005000) with LDAPS Connection 可能已经回答了。按照该链接并尝试添加端口 636 和自定义证书验证:

    LdapConnection con = new LdapConnection(new LdapDirectoryIdentifier("server", port));
    con.SessionOptions.SecureSocketLayer = true;
    con.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(ServerCallback);
    con.Credential = new NetworkCredential(String.Empty, String.Empty);
    con.AuthType = AuthType.Basic;
    con.Bind();
    

    在给定的示例中,凭据使用的是空字符串,如果需要,可能需要通过真实登录名/密码进行更改。

    【讨论】:

    • 谢谢!帮了我很多!
    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-08
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多