I encountered following issue while working with LDAP3 package: When I am passing wrong credentials (wrong username and wrong password), I am getting same Microsoft Active Directory LDAP Result Codes sub-codes for Bind Response, as when only password is invalid.
My code:
from ldap3 import Connection, Server, NONE, NTLM
server = Server(url, use_ssl=True, get_info=NONE)
con = Connection(server, user='ValidID', password='ValidPassword')
con.bind()
con.unbind()
print(con.result)
Result I am getting here:
{'result': 0, 'description': 'success', 'dn': '', 'message': '', 'referrals': None, 'saslCreds': None, 'type': 'bindResponse'}
Nothing wrong with that. But...
con = Connection(server, user='InvalidID', password='InvalidPassword')
con.bind()
con.unbind()
print(con.result)
Gives me following result:
{'result': 49, 'description': 'invalidCredentials', 'dn': '', 'message': '80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580\x00', 'referrals': None, 'saslCreds': None, 'type': 'bindResponse'}
According to ldap wiki:
52e - ERROR_LOGON_FAILURE
Returns when username is valid but password/credential is invalid. Will prevent most other er from being displayed as noted.
In that case I shouldn't be getting "data 52e" message, because username is not valid.
Or I am getting something wrong? Another thing coming to my head, it might be the ldap server fault, and it is sending wrong messages