From 1b0e773ceb678210c79d88a65738d4f8253d4952 Mon Sep 17 00:00:00 2001 From: Livio Spring Date: Tue, 25 Jun 2024 21:04:10 +0200 Subject: [PATCH] fix(ldap): add more logs (#8197) # Which Problems Are Solved In case the user bind (user password check for LDAP IdP) fails, there's no information about what went wrong. This makes it hard to even impossible to find the cause. # How the Problems Are Solved Added logging of the error. # Additional Changes Additionally added a log in case no single user (none / multiple) are found. # Additional Context - reported internally --- internal/idp/providers/ldap/session.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/idp/providers/ldap/session.go b/internal/idp/providers/ldap/session.go index 6bd32525dd..13d2bb6793 100644 --- a/internal/idp/providers/ldap/session.go +++ b/internal/idp/providers/ldap/session.go @@ -10,6 +10,7 @@ import ( "time" "github.com/go-ldap/ldap/v3" + "github.com/zitadel/logging" "golang.org/x/text/language" "github.com/zitadel/zitadel/internal/domain" @@ -172,12 +173,14 @@ func trySearchAndUserBind( return nil, err } if len(sr.Entries) != 1 { + logging.WithFields("entries", len(sr.Entries)).Info("ldap: no single user found") return nil, ErrNoSingleUser } user := sr.Entries[0] // Bind as the user to verify their password if err = conn.Bind(user.DN, password); err != nil { + logging.WithFields("userDN", user.DN).WithError(err).Info("ldap user bind failed") return nil, ErrFailedLogin } return user, nil