![](/img/trans.png)
[英]Secure this invaluable documentation on using C/C++ with GSSAPI and SASL
[英]LDAP SASL Binding C++
我目前正在针对AD域的Linux上实现授权机制。 我使用OpenLDAP库进行授权。 现在,我尝试使用ldap_sasl_bind_s
函数执行绑定操作,并且由于服务器的响应,我的应用程序收到了挑战,但是我不确定如何解决它。 所以我被困在这里:
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知识中心,我找到了如何绑定凭证的方法。 使用简单的身份验证机制,我们可以通过调用
ret = ldap_sasl_bind_s(
ldapConnection,
"username@example.com",
NULL, // Simple bind mechanism
&creds,
NULL,
NULL,
NULL
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.