mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-12-29 06:25:40 +00:00
Adding the ability to use 'LDAP_USERNAMEFIELD' and 'LDAP_FILTER' in case of use with Active Directory for authorization
This commit is contained in:
parent
b0caf0ca48
commit
0436d69ea6
@ -187,11 +187,13 @@ class User(db.Model):
|
|||||||
logging.error('LDAP authentication is disabled')
|
logging.error('LDAP authentication is disabled')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
searchFilter = "(&(objectcategory=person)(samaccountname=%s))" % self.username
|
if LDAP_TYPE == 'ad':
|
||||||
if LDAP_TYPE == 'ldap':
|
searchFilter = "(&(objectcategory=person)(%s=%s)(%s))" % (LDAP_USERNAMEFIELD, self.username, LDAP_FILTER)
|
||||||
searchFilter = "(&(%s=%s)(%s))" % (LDAP_USERNAMEFIELD, self.username, LDAP_FILTER)
|
|
||||||
logging.info('Ldap searchFilter "%s"' % searchFilter)
|
|
||||||
|
|
||||||
|
elif LDAP_TYPE == 'ldap':
|
||||||
|
searchFilter = "(&(%s=%s)(%s))" % (LDAP_USERNAMEFIELD, self.username, LDAP_FILTER)
|
||||||
|
|
||||||
|
logging.info('Ldap searchFilter "%s"' % searchFilter)
|
||||||
result = self.ldap_search(searchFilter, LDAP_SEARCH_BASE)
|
result = self.ldap_search(searchFilter, LDAP_SEARCH_BASE)
|
||||||
if not result:
|
if not result:
|
||||||
logging.warning('User "%s" does not exist' % self.username)
|
logging.warning('User "%s" does not exist' % self.username)
|
||||||
|
Loading…
Reference in New Issue
Block a user