【问题标题】:LDAP over SSL returns 'unwilling to perform' error when setting fast concurrent bind (PrincipalContext.ValidateCredentials)设置快速并发绑定 (PrincipalContext.ValidateCredentials) 时,基于 SSL 的 LDAP 返回“不愿意执行”错误
【发布时间】:2017-05-26 11:08:16
【问题描述】:

最初的问题始于 .NET\C# 和 ValidateCredentials 方法 - 没有 SSL 它可以工作,使用 SSL 它会返回“服务器无法处理目录请求”。但我缩小了范围并简化为下面发布的 C++ 代码。

MSDN 说 LDAP_OPT_FAST_CONCURRENT_BIND 支持多个简单绑定,并且不适用于接下来的 2 个选项:LDAP_OPT_SIGNLDAP_OPT_ENCRYPT。它还说使用不带 SSL 的简单绑定是not good,因为当通过网络发送时,您将以明文形式公开您的凭据。

因此,当您在没有签名和加密的情况下通过 SSL 使用 LDAP 时,您似乎可以启用 FCB。但每次我这样做时,我都会收到 0x35(不愿意执行)。 Article 关于密码认证也没有提到 SSL。所以,问题是 - 我做错了什么?或者,Microsoft 是否应该在其文档中声明 LDAP_OPT_FAST_CONCURRENT_BIND 不支持 SSL?

#include "stdafx.h"
#include <windows.h>
#include <winldap.h>

int main()
{
    PCHAR username = "bla-bla-bla";
    PCHAR password = "bla-bla-bla";
    PCHAR hostName = "bla-bla-bla";
    ULONG lRtn = 0;
    LDAP* pLdapConnection = NULL;

    pLdapConnection = ldap_init(hostName, LDAP_PORT);

    // NOTE: those 2 below - will return 0x35 (Unwilling to perform) during setting LDAP_OPT_FAST_CONCURRENT_BIND option
    //pLdapConnection = ldap_init(hostName, LDAP_SSL_PORT);
    //pLdapConnection = ldap_sslinit(hostName, LDAP_SSL_PORT, 1);

    if (pLdapConnection == NULL)
    {
        printf("ldap_init failed with 0x%x.\n", LdapGetLastError());
        ldap_unbind(pLdapConnection);
        return -1;
    }
    else
        printf("ldap_init succeeded \n");

    lRtn = ldap_connect(pLdapConnection, NULL);
    if (lRtn == LDAP_SUCCESS)
        printf("ldap_connect succeeded \n");
    else
    {
        printf("ldap_connect failed with 0x%lx.\n", lRtn);
        ldap_unbind(pLdapConnection);
        return -1;
    }

    // Enable concurrent binding - returns 0x35 when used with SSL.
    lRtn = ldap_set_option(pLdapConnection, LDAP_OPT_FAST_CONCURRENT_BIND, LDAP_OPT_ON);
    if (lRtn == LDAP_SUCCESS)
        printf("Fast concurrent binding enabled\n");
    else
    {
        printf("SetOption Error:%0lX\n", lRtn);
        ldap_unbind(pLdapConnection);
        return -1;
    }

    lRtn = ldap_simple_bind_s(pLdapConnection, username, password);
    if (lRtn == LDAP_SUCCESS)
    {
        printf("ldap_simple_bind_s succeeded \n");
        password = NULL;         // Remove password pointer
    }
    else
    {
        printf("ldap_bind_s failed with 0x%lx.\n", lRtn);
        ldap_unbind(pLdapConnection);
        return -1;
    }

    ldap_unbind(pLdapConnection);

    return 0;
}

【问题讨论】:

标签: c# ssl active-directory ldap directoryservices


【解决方案1】:

在这里查看我的回复:https://stackoverflow.com/a/49310208/1950304

或者,Microsoft 应该在其文档中声明 LDAP_OPT_FAST_CONCURRENT_BIND 不支持 SSL?

这不是一般的 SSL,而是 相互 SSL。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-10
    • 2016-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多