Posted By

genie_vn on 07/15/09


Tagged

python ldap


Versions (?)

Python ldap


 / Published in: Python
 

Validate ldap user

  1. import ldap
  2.  
  3. LDAP_ADDR = 'ldap.daimi.au.dk'
  4. LDAP_CONFIG = 'uid=%s,ou=people,dc=daimi,dc=au,dc=dk'
  5.  
  6. def checkPassword(username, password):
  7. server = LDAP_ADDR
  8. l = ldap.open(server)
  9. if password == "":
  10. password = "wrong"
  11. try:
  12. l.simple_bind_s(LDAP_CONFIG % username, password)
  13. except:
  14. return False
  15. return True

Report this snippet  

You need to login to post a comment.