authLdap.py 562 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. import sys, ldap, syslog
  3. from radicale import config, log
  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. dn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
  14. l.simple_bind_s(dn, password);
  15. return True
  16. except:
  17. log.error(sys.exc_info()[0])
  18. return False
  19. LDAPSERVER = config.get("authLdap", "LDAPServer")
  20. LDAPPREPEND = config.get("authLdap", "LDAPPrepend")
  21. LDAPAPPEND = config.get("authLdap", "LDAPAppend")