2010-12-02 10:01:09 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2010-12-02 17:58:56 +01:00
|
|
|
import sys, ldap, syslog
|
2010-12-02 10:01:09 +01:00
|
|
|
|
2011-02-16 13:53:27 +01:00
|
|
|
from radicale import config, log
|
2010-12-02 10:01:09 +01:00
|
|
|
|
|
|
|
def has_right(owner, user, password):
|
|
|
|
if user == None:
|
|
|
|
user=""
|
|
|
|
if password == None:
|
|
|
|
password=""
|
|
|
|
if owner != user:
|
|
|
|
return False
|
|
|
|
try:
|
2011-02-16 13:53:27 +01:00
|
|
|
log.log(10, "Open LDAP server connexion")
|
2010-12-02 10:01:09 +01:00
|
|
|
l=ldap.open(LDAPSERVER, 389)
|
|
|
|
cn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
|
2011-02-16 13:53:27 +01:00
|
|
|
log.log(10, "LDAP bind with dn: %s" %(cn))
|
2010-12-02 10:01:09 +01:00
|
|
|
l.simple_bind_s(cn, password);
|
2011-02-16 13:53:27 +01:00
|
|
|
log.log(20, "LDAP bind Ok")
|
2010-12-02 10:01:09 +01:00
|
|
|
return True
|
|
|
|
except:
|
2011-02-16 13:53:27 +01:00
|
|
|
log.log(40, "LDAP bind error")
|
2010-12-02 10:01:09 +01:00
|
|
|
return False
|
|
|
|
|
|
|
|
LDAPSERVER = config.get("authLdap", "LDAPServer")
|
|
|
|
LDAPPREPEND = config.get("authLdap", "LDAPPrepend")
|
|
|
|
LDAPAPPEND = config.get("authLdap", "LDAPAppend")
|