Skip to content

Commit

Permalink
Update builtin/credential/ldap/backend.go
Browse files Browse the repository at this point in the history
Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>
  • Loading branch information
remilapeyre and calvn committed May 20, 2022
1 parent ae7e2e9 commit 04d8cb9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions builtin/credential/ldap/backend.go
Expand Up @@ -195,15 +195,16 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
// Policies from each group may overlap
policies = strutil.RemoveDuplicates(policies, true)

entityAliasAttribute := username
if !usernameAsAlias {
entityAliasAttribute, err = ldapClient.GetUserAliasAttributeValue(cfg.ConfigEntry, c, username)
if err != nil {
return "", nil, logical.ErrorResponse(err.Error()), nil, nil
}
if entityAliasAttribute == "" {
return "", nil, logical.ErrorResponse("missing entity alias attribute value"), nil, nil
}
if usernameAsAlias {
return username, policies, ldapResponse, allGroups, nil
}

entityAliasAttribute, err = ldapClient.GetUserAliasAttributeValue(cfg.ConfigEntry, c, username)
if err != nil {
return "", nil, logical.ErrorResponse(err.Error()), nil, nil
}
if entityAliasAttribute == "" {
return "", nil, logical.ErrorResponse("missing entity alias attribute value"), nil, nil
}

return entityAliasAttribute, policies, ldapResponse, allGroups, nil
Expand Down

0 comments on commit 04d8cb9

Please sign in to comment.