Skip to content

Commit 6bd1760

Browse files
committed
Improve some LDAP authentication error messages
1 parent ce75457 commit 6bd1760

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/backend/libpq/auth.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,7 @@ CheckLDAPAuth(Port *port)
21612161
char *attributes[2];
21622162
char *dn;
21632163
char *c;
2164+
int count;
21642165

21652166
/*
21662167
* Disallow any characters that we would otherwise need to escape,
@@ -2223,17 +2224,21 @@ CheckLDAPAuth(Port *port)
22232224
return STATUS_ERROR;
22242225
}
22252226

2226-
if (ldap_count_entries(ldap, search_message) != 1)
2227+
count = ldap_count_entries(ldap, search_message);
2228+
if (count != 1)
22272229
{
2228-
if (ldap_count_entries(ldap, search_message) == 0)
2230+
if (count == 0)
22292231
ereport(LOG,
2230-
(errmsg("LDAP search failed for filter \"%s\" on server \"%s\": no such user",
2231-
filter, port->hba->ldapserver)));
2232+
(errmsg("LDAP user \"%s\" does not exist", port->user_name),
2233+
errdetail("LDAP search for filter \"%s\" on server \"%s\" returned no entries.",
2234+
filter, port->hba->ldapserver)));
22322235
else
22332236
ereport(LOG,
2234-
(errmsg("LDAP search failed for filter \"%s\" on server \"%s\": user is not unique (%ld matches)",
2235-
filter, port->hba->ldapserver,
2236-
(long) ldap_count_entries(ldap, search_message))));
2237+
(errmsg("LDAP user \"%s\" is not unique", port->user_name),
2238+
errdetail_plural("LDAP search for filter \"%s\" on server \"%s\" returned %d entry.",
2239+
"LDAP search for filter \"%s\" on server \"%s\" returned %d entries.",
2240+
count,
2241+
filter, port->hba->ldapserver, count)));
22372242

22382243
pfree(filter);
22392244
ldap_msgfree(search_message);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy