Use a simple getattr to get the LDAP scope

This commit is contained in:
Guillaume Ayoub 2011-11-29 12:58:28 +01:00
parent 5d55b2868f
commit 74c16e6402

View File

@ -34,12 +34,7 @@ ATTRIBUTE = config.get("acl", "ldap_attribute")
CONNEXION = ldap.initialize(config.get("acl", "ldap_url")) CONNEXION = ldap.initialize(config.get("acl", "ldap_url"))
BINDDN = config.get("acl", "ldap_binddn") BINDDN = config.get("acl", "ldap_binddn")
PASSWORD = config.get("acl", "ldap_password") PASSWORD = config.get("acl", "ldap_password")
SCOPE = getattr(ldap, "SCOPE_%s" % config.get("acl", "ldap_scope").upper())
SCOPE = ldap.SCOPE_ONELEVEL
if config.get("acl", "ldap_scope").lower() == 'subtree':
SCOPE = ldap.SCOPE_SUBTREE
elif config.get("acl", "ldap_scope").lower() == 'base':
SCOPE = ldap.SCOPE_BASE
def has_right(owner, user, password): def has_right(owner, user, password):