2012-06-21 9 views
2

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 

내가 뭘 잘못하고 있니?

+0

:

ldap_simple_bind_s(ld, NULL, NULL); 

같은 것을 대체 할 필요가? 2 대신에 하나의 DN만을 사용하려 했습니까? 간단한 필터를 사용해보십시오. – besworland

+0

'ldap_set_option'과'ldap_connect'는 둘 다'LDAP_SUCCESS'를 리턴합니다. 내 실제 DN은'dc = dl, dc = intern'이며 내 도메인 이름 ->'dl.intern'입니다. –

답변

3

다르게 구성되어 있지 않으면 이어야하며 Microsoft Active Directory 서버의 유효한 계정 이름과 암호를 사용해야합니다. 그렇지 않으면 a very small handful을 제외한 모든 쿼리에 대해 작업 오류가 반환됩니다.

즉 그 : 값이 'ldap_set_option'과 'ldap_connect'에 의해 반환 무엇

char *username = "cn=aUser,ou=Users,dc=myDomain,dc=extension"; 
char *password = "this is the password"; 
ldap_simple_bind_s(ld, username, password); 
+0

그레이트 - 이제 작동합니다! –

+0

맞아, 나는 이것을 알아 차리지 못했다. – besworland

관련 문제