mirror of
https://github.com/Kozea/Radicale.git
synced 2025-07-23 17:48:30 +00:00
Adding LDAP authentification
This commit is contained in:
parent
673da6a90a
commit
8a86f57304
1 changed files with 24 additions and 0 deletions
24
radicale/acl/authLdap.py
Normal file
24
radicale/acl/authLdap.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys, ldap
|
||||
|
||||
from radicale import config
|
||||
|
||||
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)
|
||||
cn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
|
||||
l.simple_bind_s(cn, password);
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
LDAPSERVER = config.get("authLdap", "LDAPServer")
|
||||
LDAPPREPEND = config.get("authLdap", "LDAPPrepend")
|
||||
LDAPAPPEND = config.get("authLdap", "LDAPAppend")
|
Loading…
Add table
Add a link
Reference in a new issue