C++ 使用“绑定到ldap服务器”;ldaps“;
我正在编写一个程序,将连接到运行在端口10389上的LDAP服务器。我能够使用用户dn和密码成功绑定到服务器 以下是我的示例程序:C++ 使用“绑定到ldap服务器”;ldaps“;,c++,c,ldap,C++,C,Ldap,我正在编写一个程序,将连接到运行在端口10389上的LDAP服务器。我能够使用用户dn和密码成功绑定到服务器 以下是我的示例程序: #include "windows.h" #include "winldap.h" #include "stdio.h" int main(int argc, char* argv[]) { LDAP* pLdapConnection = NULL; ULONG version = LDAP_VERSION3; ULONG connectS
#include "windows.h"
#include "winldap.h"
#include "stdio.h"
int main(int argc, char* argv[])
{
LDAP* pLdapConnection = NULL;
ULONG version = LDAP_VERSION3;
ULONG connectSuccess = 0;
INT returnCode = 0;
pLdapConnection = ldap_init("localhost", 10389);
if (pLdapConnection == NULL)
{
printf( "ldap_init failed");
goto error_exit;
}
else
printf("ldap_init succeeded \n");
// Set the version to 3.0 (default is 2.0).
returnCode = ldap_set_option(pLdapConnection,
LDAP_OPT_PROTOCOL_VERSION,
(void*)&version);
if(returnCode != LDAP_SUCCESS)
{
printf("SetOption Error:%0X\n", returnCode);
goto error_exit;
}
// Connect to the server.
connectSuccess = ldap_connect(pLdapConnection, NULL);
if(connectSuccess == LDAP_SUCCESS)
printf("ldap_connect succeeded \n");
else
{
printf("ldap_connect failed with 0x%x.\n",connectSuccess);
goto error_exit;
}
printf("Binding ...\n");
returnCode = ldap_bind_s(pLdapConnection, "dc=mojo,dc=com", "mojo", LDAP_AUTH_SIMPLE);
if (returnCode == LDAP_SUCCESS)
printf("The bind was successful");
else{
printf("ldap_bind_s failed with 0x%x.\n",returnCode);
goto error_exit;
}
// Cleanup and exit.
ldap_unbind(pLdapConnection);
return 0;
// On error cleanup and exit.
error_exit:
ldap_unbind(pLdapConnection);
return -1;
}
如何通过“ldaps://
”进行连接?ldaps服务器正在端口10636上侦听
我的程序连接到端口10636上的“ldaps”需要什么?ldaps是一种用于通过SSL隧道连接到ldap的协议。这意味着您必须启动SSL会话(或TLS,具体取决于ldap版本),然后使用ldap协议连接到服务器
以下是windows LDAPS协议:LDAPS是一种用于通过SSL隧道连接到ldap的协议。这意味着您必须启动SSL会话(或TLS,具体取决于ldap版本),然后使用ldap协议连接到服务器 以下是windows LDAPS协议: