gpt4 book ai didi

c++ - winldap 无法使用 ssl 连接到 openldap

转载 作者:太空宇宙 更新时间:2023-11-04 11:34:28 24 4
gpt4 key购买 nike

我可以通过这个命令查询服务器的数据

ldapsearch -H ldaps://CS-GAMEBOY-PC -x -b dc=micmiu,dc=com -D cn=Manager,dc=micmiu,dc=com -w secret

但我无法通过winldap的示例代码查询数据(我删除了大部分错误句柄和资源清理以简化代码)

#include <iostream>

#include <windows.h>
#include <winldap.h>
#include <winber.h>

int main()
{
char *LdapServer = "CS-GAMEBOY-PC";
LDAP *ldap = ldap_sslinitA(LdapServer, LDAP_SSL_PORT, 1);

unsigned long version = LDAP_VERSION3;
ldap_set_option(ldap,
LDAP_OPT_PROTOCOL_VERSION,
(void*)&version);

// If SSL is not enabled, enable it.
ldap_set_option(ldap, LDAP_OPT_SSL, LDAP_OPT_ON);

// Connect to the server.
unsigned long connectSuccess = ldap_connect(ldap, NULL);
if(connectSuccess == LDAP_SUCCESS){
std::cout<<"ldap_connect succeeded \n";
}else{
std::cout<<"ldap_connect failed with "<<ldap_err2string(connectSuccess)<<std::endl;
std::cout<<"error codes = 0x"<<std::hex<<connectSuccess<<std::endl;
return -1;
}
}

ldap_connect 失败并给我错误代码“0X51”

服务器站点给我的错误是

........tls_read: want=5 error=未知错误TLS 跟踪:SSL_accept:SSLv3 中的错误读取客户端证书 ATLS 跟踪:SSL_accept:SSLv3 中的错误读取客户端证书 A…………tls_read: want=5 error=未知错误TLS 跟踪:SSL_accept:SSLv3 中的错误读取客户端证书 ATLS:无法接受:(未知)。

我该如何解决这个问题?

最佳答案

 //
static bool VerifyCert(void/*LDAP* ld, PCCERT_CONTEXT pServerCert*/)
{
return true;
}
//

..
// Set the version to 3.0 (default is 2.0). and than ->

ldap_set_option(pLdapConnection, LDAP_OPT_SERVER_CERTIFICATE, &VerifyCert);

// Now you can Bind.
..

关于c++ - winldap 无法使用 ssl 连接到 openldap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23358837/

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