我正在嘗試執行LDAP搜索,但它不在我的Active Directory測試服務器上工作。我使用此代碼:在AD服務器上使用winldap.h進行LDAP搜索
#include <winldap.h>
...
LDAP* ld = ldap_init("AD-servername", 389);
int myVersion =LDAP_VERSION3;
ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &myVersion);
ldap_connect(ld, NULL);
//ldap_simple_bind_s(ld, NULL, NULL); I tried using this line too. but got the same error
LDAPMessage *pMsg = NULL;
int retVal = ldap_search_s(ld, "dc=myDomain,dc=extension", LDAP_SCOPE_SUBTREE, "(samAccountName=testaccount)", NULL, NULL, &pMsg);
//retVal = 1 which is LDAP_OPERATIONS_ERROR
我在做什麼錯了?
的值由 'ldap_set_option' 和 'ldap_connect' 回來怎麼辦?你有沒有試過只使用一個DN而不是2?嘗試使用一些簡單的過濾器。 – besworland
'ldap_set_option'和'ldap_connect'返回'LDAP_SUCCESS'。我的實際DN是'dc = dl,dc = intern',這是我的域名 - >'dl.intern'。 –