Browse Source

Merge pull request #1285 from srenatus/sr/ldap/treat-bind-constraint-violation-as-bad-login

connectors/ldap: treat 'constraint violation' on bind as bad credentials
pull/1282/merge
Stephan Renatus 8 years ago committed by GitHub
parent
commit
974617a426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      connector/ldap/ldap.go

9
connector/ldap/ldap.go

@ -409,12 +409,17 @@ func (c *ldapConnector) Login(ctx context.Context, s connector.Scopes, username,
if err := conn.Bind(user.DN, password); err != nil {
// Detect a bad password through the LDAP error code.
if ldapErr, ok := err.(*ldap.Error); ok {
if ldapErr.ResultCode == ldap.LDAPResultInvalidCredentials {
switch ldapErr.ResultCode {
case ldap.LDAPResultInvalidCredentials:
c.logger.Errorf("ldap: invalid password for user %q", user.DN)
incorrectPass = true
return nil
case ldap.LDAPResultConstraintViolation:
c.logger.Errorf("ldap: constraint violation for user %q: %s", user.DN, ldapErr.Error())
incorrectPass = true
return nil
}
}
} // will also catch all ldap.Error without a case statement above
return fmt.Errorf("ldap: failed to bind as dn %q: %v", user.DN, err)
}
return nil

Loading…
Cancel
Save