Checking an user aginst a LDAP service

Our university uses a LDAP login service. I have made a little Python script that can answer if an user has provided the right login information. Python-ldap is needed.
import ldap

LDAP_ADDR = 'ldap.daimi.au.dk'
LDAP_CONFIG = 'uid=%s,ou=people,dc=daimi,dc=au,dc=dk'

def checkPassword(username, password):
   server = LDAP_ADDR
   l = ldap.open(server)
   if password == "":
       password = "wrong"
   try:
       l.simple_bind_s(LDAP_CONFIG % username, password)
   except:
       return False
   return True
Code · Python 14. Apr 2006
© Amir Salihefendic. Powered by Skeletonz.