Quellcode durchsuchen

Use a simple getattr to get the LDAP scope

Guillaume Ayoub vor 14 Jahren
Ursprung
Commit
74c16e6402
1 geänderte Dateien mit 1 neuen und 6 gelöschten Zeilen
  1. 1 6
      radicale/acl/LDAP.py

+ 1 - 6
radicale/acl/LDAP.py

@@ -34,12 +34,7 @@ ATTRIBUTE = config.get("acl", "ldap_attribute")
 CONNEXION = ldap.initialize(config.get("acl", "ldap_url"))
 BINDDN = config.get("acl", "ldap_binddn")
 PASSWORD = config.get("acl", "ldap_password")
-
-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
+SCOPE = getattr(ldap, "SCOPE_%s" % config.get("acl", "ldap_scope").upper())
 
 
 def has_right(owner, user, password):