[python-ldap] Connection to Active Directory

Gustavo Gómez gustavo.gomez at nuevosmedios.ws
Fri Nov 15 18:13:19 CET 2013


Hello, I am trying to authenticate against an Active Directory. If I use a
tool like Apache Directory Studio it works if I pass as the user the string
"DOMAIN\myuser", but I need to know how can I can connect using Python. It
does not work if I use "cn=myuser,dc=domain,dc=com".

On Python, if I pass "DOMAIN\myuser" I get: ldap.FILTER_ERROR: {'desc':
'Bad search filter'}

Otherwise, I get: {'info': '80090308: LdapErr: DSID-0C0903AA, comment:
AcceptSecurityContext error, data 525, v1772', 'desc': 'Invalid
credentials'}


I am trying the following script:

# -----
import ldap
conn = ldap.initialize("ldap://server:389")

try:
    conn.set_option(ldap.OPT_REFERRALS, 0)
    conn.simple_bind_s('myuser', 'mypass')
    conn.search_st('DC=domain,DC=com',
                   ldap.SCOPE_SUBTREE,
                   "(uid=%(user)s)")
except ldap.INVALID_CREDENTIALS as e:
    print 'wrong password provided'
# -----

Any idea?

-- 
*Gustavo Gómez Farhat*
Ingeniero de Desarrollo e Implementación
* <http://www.nuevosmedios.ws/>*
+(57)(2)3809490-4850745
3165097806
Cali, Colombia
gustavo.gomez at nuevosmedios.ws
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20131115/ac654f34/attachment.html>


More information about the python-ldap mailing list