我試圖使用ldap_bind,但得到這個錯誤。從ldap.h使用ldap_bind C++
error: âldap_bindâ was not declared in this scope
代碼:
#include <lber.h>
#include <ldap.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
LDAP *ld;
char *ldap_host = "ldap://localhost";
int ldap_port = 389;
int auth_method = LDAP_AUTH_SIMPLE;
int desired_version = LDAP_VERSION3;
char *root_dn = "ou=people,dc=localhost,dc=local";
char *root_ps = "password";
int result;
result = ldap_initialize(&ld, ldap_host);
cout << "result: " << result << endl;
result = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &desired_version);
cout << "result: " << result << endl;
result = ldap_bind_s(ld, root_dn, root_ps, auth_method);
cout << "result: " << result << endl;
}
我用這個命令編譯
g++ ldap.cpp -llber -lldap -o prog
TIA
查看代碼後,我不得不定義LDAP_DEPRECATED,所以你是正確的。謝謝 – Jeremiah 2011-03-12 14:38:16
@Jeremiah:他們沒有把它放在手冊頁中是一種遺憾。 – 2011-03-12 14:39:28