authLdap.py 518 B

123456789101112131415161718192021222324
  1. # -*- coding: utf-8 -*-
  2. import sys, ldap
  3. from radicale import config
  4. def has_right(owner, user, password):
  5. if user == None:
  6. user=""
  7. if password == None:
  8. password=""
  9. if owner != user:
  10. return False
  11. try:
  12. l=ldap.open(LDAPSERVER, 389)
  13. cn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
  14. l.simple_bind_s(cn, password);
  15. return True
  16. except:
  17. return False
  18. LDAPSERVER = config.get("authLdap", "LDAPServer")
  19. LDAPPREPEND = config.get("authLdap", "LDAPPrepend")
  20. LDAPAPPEND = config.get("authLdap", "LDAPAppend")