ldap_bind_s returning LDAP_SUCCESS with wrong credentials

Posted by rezna on Stack Overflow See other posts from Stack Overflow or by rezna
Published on 2009-07-20T13:51:16Z Indexed on 2010/04/26 10:13 UTC
Read the original article Hit count: 331

Filed under:
|

Hi guys, I have this little problem. I want to authenticate user against LDAP (Windows Active Directory), everything works OK, but the combination (good user, good password, wrong domain).

LDAP* ldap = ldap_init(L"myserver", 389);
ULONG ldap_version = 3;

ULONG ret = LDAP_SUCCESS;

ret = ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, (void*)&ldap_version);
ret = ldap_connect(ldap, NULL);

SEC_WINNT_AUTH_IDENTITY ai;
ai.Domain = (unsigned short*)BAD_DOMAIN;
ai.DomainLength = wcslen(BAD_DOMAIN);
ai.User = (unsigned short*)OK_USER;
ai.UserLength = wcslen(OK_USER);
ai.Password = (unsigned short*)OK_PASS;
ai.PasswordLength = wcslen(OK_PASS);
ai.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;

ret = ldap_bind_s(ldap, NULL, (PWCHAR) &ai, LDAP_AUTH_NTLM); // !!! HERE !!!
ret = ldap_unbind_s(ldap);

On the line marke '!!! HERE !!!' I'd expect 0x31 or any other error returned. Instead I get LDAP_SUCCESS :(

Any suggestions? Thx, Milan

© Stack Overflow or respective owner

Related posts about ldap

Related posts about authentication