Skip to content

Commit acfd765

Browse files
committed
Improve error outputs (#8740)
Makes "ldap operation failed" error messages a little more useful. Also makes the errors unique so it's easier to debug where an error is coming from when one occurs.
1 parent c561656 commit acfd765

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin/credential/ldap/backend.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
9393
if b.Logger().IsDebug() {
9494
b.Logger().Debug("error getting user bind DN", "error", err)
9595
}
96-
return nil, logical.ErrorResponse("ldap operation failed"), nil, nil
96+
return nil, logical.ErrorResponse("ldap operation failed: unable to retrieve user bind DN"), nil, nil
9797
}
9898

9999
if b.Logger().IsDebug() {
@@ -110,7 +110,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
110110
if b.Logger().IsDebug() {
111111
b.Logger().Debug("ldap bind failed", "error", err)
112112
}
113-
return nil, logical.ErrorResponse("ldap operation failed"), nil, nil
113+
return nil, logical.ErrorResponse("ldap operation failed: failed to bind as user"), nil, nil
114114
}
115115

116116
// We re-bind to the BindDN if it's defined because we assume
@@ -120,7 +120,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
120120
if b.Logger().IsDebug() {
121121
b.Logger().Debug("error while attempting to re-bind with the BindDN User", "error", err)
122122
}
123-
return nil, logical.ErrorResponse("ldap operation failed"), nil, nil
123+
return nil, logical.ErrorResponse("ldap operation failed: failed to re-bind with the BindDN user"), nil, nil
124124
}
125125
if b.Logger().IsDebug() {
126126
b.Logger().Debug("re-bound to original binddn")
@@ -135,7 +135,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
135135
if cfg.AnonymousGroupSearch {
136136
c, err = ldapClient.DialLDAP(cfg.ConfigEntry)
137137
if err != nil {
138-
return nil, logical.ErrorResponse("ldap operation failed"), nil, nil
138+
return nil, logical.ErrorResponse("ldap operation failed: failed to connect to LDAP server"), nil, nil
139139
}
140140
defer c.Close() // Defer closing of this connection as the deferal above closes the other defined connection
141141
}

0 commit comments

Comments
 (0)