Я использую код, найденной в этой ссылке. аутентификация с помощью простой связывания < /h3>
Следующий код работает правильно: < /p>
Код: Выделить всё
con = ldap.initialize(uri, bytes_mode=False)
con.protocol_version = ldap.VERSION3
con.set_option(ldap.OPT_REFERRALS, 0) # required for AD authentication
con.simple_bind_s(bindDN, bindPW)
print("Bind success!")
Код: Выделить всё
REFERRAL
Когда я пытаюсь выполнить код ниже, последняя инструкция con.result3 , повысить исключение ldap.referral.
Код: Выделить всё
# optional, but reduce the number of supported control, since only this one will be parsed
known_ldap_resp_ctrls = {
SimplePagedResultsControl.controlType: SimplePagedResultsControl,
}
# instantiate the control that will make the paged results
# it carries the page cookie (initially empty, to request the first page)
req_ctrl = SimplePagedResultsControl(
criticality=True,
size=pagesize,
cookie=''
)
# query next page, asynchronous
msgid = con.search_ext(
baseDN,
ldap.SCOPE_SUBTREE,
filterstr,
attrlist=attrlist,
serverctrls=[req_ctrl]
)
try:
con.result3(msgid, timeout=timeout, resp_ctrl_classes=known_ldap_resp_ctrls)
except ldap.REFERRAL as ex:
print("REFERRAL Exception --> " + str(ex))
REFERRAL Exception --> {'msgtype': 101, 'msgid': 2, 'result': 10, 'desc': 'Referral', 'ctrls': [('1.2.840.113556.1.4.319', 0, b'0\x84\x00\x00\x00\x05\x02\x01\x00\x04\x00')], 'info': 'Referral:\nldap://domain.local/DC=domain,DC=local'}
< /code>
Я полностью застрял в этом исключении. < /p>
Кто -то может помочь мне найти, где проблема? < /p>
Спасибо < /p>
Если я выполняю один и тот же запрос с помощью утилиты ldapsearch < /code>, он работает правильно, а сервер AD отправляет запрошенные данные.
Подробнее здесь: https://stackoverflow.com/questions/739 ... p-referral