我正在尝试使用ldap_bind,但是得到了这个错误.
error: âldap_bindâ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
码:
#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;
}
Run Code Online (Sandbox Code Playgroud)
我正在用这个命令编译
g++ ldap.cpp -llber -lldap -o prog
Run Code Online (Sandbox Code Playgroud)
TIA
我没有使用 OpenLDAP 的经验,但从标题看来你需要:
extern "C" {
# define LDAP_DEPRECATED
# include <ldap.h>
# include <lber.h>
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5727 次 |
| 最近记录: |