Skip to content

Commit

Permalink
Allow authinticatied bind for listing LDAP groups
Browse files Browse the repository at this point in the history
  • Loading branch information
amendlik committed Jan 17, 2018
1 parent 288575f commit c297b95
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions salt/auth/ldap.py
Expand Up @@ -292,8 +292,9 @@ def auth(username, password):
if _config('binddn', mandatory=False) and _config('bindpw', mandatory=False):
bind = _bind_for_search(anonymous=_config('anonymous', mandatory=False))
else:
bind = _bind(username, password, anonymous=_config('auth_by_group_membership_only', mandatory=False) and
_config('anonymous', mandatory=False))
bind = _bind(username, password,
anonymous=_config('auth_by_group_membership_only', mandatory=False)
and _config('anonymous', mandatory=False))

if bind:
log.debug('LDAP authentication successful')
Expand All @@ -320,8 +321,13 @@ def groups(username, **kwargs):
'''
group_list = []

# Perform un-authenticated bind to determine group membership
bind = _bind_for_search(anonymous=_config('anonymous', mandatory=False))
# If bind credentials are configured, use them instead of user's
if _config('binddn', mandatory=False) and _config('bindpw', mandatory=False):
bind = _bind_for_search(anonymous=_config('anonymous', mandatory=False))
else:
bind = _bind(username, kwargs.get('password', ''),
anonymous=_config('auth_by_group_membership_only', mandatory=False)
and _config('anonymous', mandatory=False))

if bind:
log.debug('ldap bind to determine group membership succeeded!')
Expand Down

0 comments on commit c297b95

Please sign in to comment.