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
|
|
|
|
2010-12-02 17:58:56 +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:
|
|
|
|
l=ldap.open(LDAPSERVER, 389)
|
2010-12-02 17:58:56 +01:00
|
|
|
dn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
|
|
|
|
l.simple_bind_s(dn, password);
|
2010-12-02 10:01:09 +01:00
|
|
|
return True
|
|
|
|
except:
|
2010-12-02 17:58:56 +01:00
|
|
|
log.error(sys.exc_info()[0])
|
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")
|