mirror of
https://github.com/Kozea/Radicale.git
synced 2025-07-29 18:08:31 +00:00
Merge with radicale/master
This commit is contained in:
parent
96bded2bbc
commit
c890d6e55a
3 changed files with 27 additions and 74 deletions
|
@ -1,28 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys, ldap, syslog
|
||||
|
||||
from radicale import config, log
|
||||
|
||||
def has_right(owner, user, password):
|
||||
if user == None:
|
||||
user=""
|
||||
if password == None:
|
||||
password=""
|
||||
if owner != user:
|
||||
return False
|
||||
try:
|
||||
log.log(10, "Open LDAP server connexion")
|
||||
l=ldap.open(LDAPSERVER, 389)
|
||||
cn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
|
||||
log.log(10, "LDAP bind with dn: %s" %(cn))
|
||||
l.simple_bind_s(cn, password);
|
||||
log.log(20, "LDAP bind Ok")
|
||||
return True
|
||||
except:
|
||||
log.log(40, "LDAP bind error")
|
||||
return False
|
||||
import sys
|
||||
import ldap
|
||||
import radicale
|
||||
|
||||
LDAPSERVER = config.get("authLdap", "LDAPServer")
|
||||
LDAPPREPEND = config.get("authLdap", "LDAPPrepend")
|
||||
LDAPAPPEND = config.get("authLdap", "LDAPAppend")
|
||||
|
||||
def has_right(owner, user, password):
|
||||
if user == None:
|
||||
user=""
|
||||
if password == None:
|
||||
password=""
|
||||
if owner != user:
|
||||
return False
|
||||
try:
|
||||
radicale.log.LOGGER.info("Open LDAP server connexion")
|
||||
l=ldap.open(LDAPSERVER, 389)
|
||||
cn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
|
||||
radicale.log.LOGGER.info("LDAP bind with dn: %s" % (cn))
|
||||
l.simple_bind_s(cn, password);
|
||||
radicale.log.LOGGER.info("LDAP bind ok")
|
||||
return True
|
||||
except:
|
||||
radicale.log.LOGGER.info("Nu such credential")
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue