gpt4 book ai didi

c++ - LDAP SASL 绑定(bind) C++

转载 作者:行者123 更新时间:2023-12-02 10:08:51 25 4
gpt4 key购买 nike

我目前正在 Linux 上针对 AD 域实现授权机制。我使用 OpenLDAP 库进行授权。现在我正在尝试使用 ldap_sasl_bind_s 执行绑定(bind)操作。功能,并且作为来自服务器的响应,我的应用程序正在接收挑战,但我不确定如何解决它。所以我坚持这个:

berval creds;            // User creds
berval *srv = NULL; // Server challenge
creds.bv_val = (char*)password.c_str();
creds.bv_len = password.length();

ret = ldap_sasl_bind_s(
ldapConnection,
username.c_str(),
"DIGEST-MD5",
&creds,
NULL,
NULL,
&srv
);

if((srv != NULL) && (ret == LDAP_SASL_BIND_IN_PROGRESS)) // If challenge has been received
{
// Challenge solving mechanism goes there.
ret = ldap_sasl_bind_s(
ldapConnection,
username.c_str(),
"DIGEST-MD5",
srv, // Not sure if it's the right place
NULL,
NULL,
NULL
);

if(ret != LDAP_SUCCESS) // Here I get 0x31 (LDAP_INVALID_CREDENTIALS)
{
ldap_unbind_ext(ldapConnection, NULL, NULL);
return false;
}
}

最佳答案

好的,感谢 IBM Knowledge Center我想出了如何绑定(bind)凭据。使用简单的身份验证机制,我们可以通过调用来做到这一点

ret = ldap_sasl_bind_s(
ldapConnection,
"username@example.com",
NULL, // Simple bind mechanism
&creds,
NULL,
NULL,
NULL
);

关于c++ - LDAP SASL 绑定(bind) C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31746817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com