在 LDAP3 中获取 connection.bind 的 invalidCredentials

A. *_*Man 2 credentials python-3.6 ldap3

我正在尝试编写 python 代码,它将使用 LDAP 模块来验证 LDAP 连接:

import configuration
from ldap3 import Server, Connection, SIMPLE, SYNC, ALL

server = Server(configuration.LDAP_SERVER, port=XXXX, get_info=ALL)
c = Connection(server, authentication=SIMPLE, user=configuration.LDAP_USER, password=configuration.LDAP_PASS, check_names=True, lazy=False, client_strategy=SYNC, raise_exceptions=False)
c.open()
c.bind()
Run Code Online (Sandbox Code Playgroud)

运行代码时,我得到:

{'result': 49, 'description': 'invalidCredentials', 'dn': '', 'message': '80090308: LdapErr: DSID-0C09042A, comment: AcceptSecurityContext error, data 52e, v3839\x00', 'referrals': None, 'saslCreds': None, 'type': 'bindResponse'}
Run Code Online (Sandbox Code Playgroud)

我确信我使用的用户名和密码是正确的。你能告诉我代码有什么问题吗?

A. *_*Man 5

我不得不用谷歌搜索它,但最终,下面的代码起作用了:

import configuration
from ldap3 import Server, Connection, SIMPLE, SYNC, ALL
server = Server(configuration.LDAP_SERVER, get_info=ALL)
conn = Connection(server, "CN=XXXXX,OU=XXX;OU=XXXX,OU=Users,XX=People,XX=corp,XX=[organization],XX=XXX", password=configuration.LDAP_PASS, auto_bind=False)
conn.bind()
print(conn)
Run Code Online (Sandbox Code Playgroud)