Merge pull request #8 from indication/master

Add ldap_support_extended configuration
This commit is contained in:
Marco Huenseler 2019-08-06 12:43:42 +02:00 committed by GitHub
commit c399db0c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -31,4 +31,8 @@ ldap_password = verysecurepassword
# LDAP scope of the search # LDAP scope of the search
ldap_scope = LEVEL ldap_scope = LEVEL
# LDAP extended option
# If the server is samba, ldap_support_extended is should be no
ldap_support_extended = yes
``` ```

View File

@ -44,6 +44,7 @@ class Auth(BaseAuth):
BINDDN = self.configuration.get("auth", "ldap_binddn") BINDDN = self.configuration.get("auth", "ldap_binddn")
PASSWORD = self.configuration.get("auth", "ldap_password") PASSWORD = self.configuration.get("auth", "ldap_password")
SCOPE = self.configuration.get("auth", "ldap_scope") SCOPE = self.configuration.get("auth", "ldap_scope")
SUPPORT_EXTENDED = self.configuration.getboolean("auth", "ldap_support_extended", fallback=True)
if BINDDN and PASSWORD: if BINDDN and PASSWORD:
conn = ldap3.Connection(SERVER, BINDDN, PASSWORD) conn = ldap3.Connection(SERVER, BINDDN, PASSWORD)
@ -80,8 +81,12 @@ class Auth(BaseAuth):
conn = ldap3.Connection(SERVER, user_dn, password) conn = ldap3.Connection(SERVER, user_dn, password)
conn.bind() conn.bind()
self.logger.debug(conn.result) self.logger.debug(conn.result)
if SUPPORT_EXTENDED:
whoami = conn.extend.standard.who_am_i() whoami = conn.extend.standard.who_am_i()
self.logger.debug("LDAP whoami: %s" % whoami) self.logger.debug("LDAP whoami: %s" % whoami)
else:
self.logger.debug("LDAP skip extended: call whoami")
whoami = conn.result['result'] == 0
if whoami: if whoami:
self.logger.debug("LDAP bind OK") self.logger.debug("LDAP bind OK")
return True return True