On Fri, 05 May 2006 05:39:08 -0700, D wrote: > Is it possible to have Python authenticate with Active Directory? > Specifically what I'd like to do is have a user enter a > username/password, then have Python check the credentials with AD - if > what they entered is valid, for example, it returns a 1, otherwise a > 0.. Thanks!
It's possible and you need the python-ldap package for it. The actual authentication will look like (simplified): def authenticate(user='',passwd=''): dn = find_user_dn(user) try: l = ldap.open(AD_HOST_URL) l.protocol_version = ldap.VERSION3 l.simple_bind_s(dn,passwd) l.search_s(SEARCHDN,ldap.SCOPE_SUBTREE,'objectType=bla') l.unbind_s() return True except ldap.LDAPError: return False obviously, you need to supply some function 'find_user_dn' that maps the user to its DN. -- http://mail.python.org/mailman/listinfo/python-list