PyLDAP: Авторизация в AD

Наткнулся на вредную багу при авторизации в ActiveDirectory: после успешного ldap.bind() получал ошибку "In order to perform this operation a successful bind must be completed on the connection". Решение нашлось в официальном FAQ python-ldap:

When searching from the domain level MS AD returns referrals (search continuations) for some objects to indicate to the client where to look for these objects. Client-chasing of referrals is a broken concept since LDAPv3 does not specify which credentials to use when chasing the referral. Windows clients are supposed to simply use their Windows credentials but this does not work in general when chasing referrals received from and pointing to arbitrary LDAP servers.
Therefore per default libldap automatically chases the referrals internally with an anonymous access which fails with MS AD.


Если по русски,- иногда AD-сервер возвращает ссылки на дополнительные сервера, на которых могут быть дополнительные результаты поиска. По умолчанию libldap пытается получить результаты с помощью анонимного доступа, в случае с Active Directory этот номер не проходит.
Решается добавлением l.set_option(ldap.OPT_REFERRALS,0) после ldap.initialize().


l = ldap.initialize('ldap://foobar')
l.set_option(ldap.OPT_REFERRALS,0)

Комментарии

Популярные сообщения