|
|
db96ff |
From e5a7c13c7aa70ebe59764761020fc509dd0ec33a Mon Sep 17 00:00:00 2001
|
|
|
db96ff |
From: Arthur de Jong <arthur@arthurdejong.org>
|
|
|
db96ff |
Date: Sun, 4 May 2014 23:16:03 +0200
|
|
|
db96ff |
Subject: [PATCH 18/23] Also extract policy controls on BIND failure
|
|
|
db96ff |
|
|
|
db96ff |
This ensures that controls returned by an LDAP server as part of a
|
|
|
db96ff |
failed BIND operation are also returned. This makes it possible to
|
|
|
db96ff |
distinguish between a wrong password and an expired password.
|
|
|
db96ff |
|
|
|
db96ff |
This also only logs the BIND operation result on DEBUG level (the error
|
|
|
db96ff |
is logged later on).
|
|
|
db96ff |
|
|
|
db96ff |
(cherry picked from commit ca36a50143eb38c9040c2567172b9bfb9dba1838)
|
|
|
db96ff |
---
|
|
|
db96ff |
nslcd/myldap.c | 19 +++++++++----------
|
|
|
db96ff |
1 file changed, 9 insertions(+), 10 deletions(-)
|
|
|
db96ff |
|
|
|
db96ff |
diff --git a/nslcd/myldap.c b/nslcd/myldap.c
|
|
|
db96ff |
index 9f6b4b0..e33296f 100644
|
|
|
db96ff |
--- a/nslcd/myldap.c
|
|
|
db96ff |
+++ b/nslcd/myldap.c
|
|
|
db96ff |
@@ -565,7 +565,7 @@ static int do_ppolicy_bind(MYLDAP_SESSION *session, LDAP *ld, const char *uri)
|
|
|
db96ff |
ldap_msgfree(result);
|
|
|
db96ff |
return LDAP_TIMEOUT;
|
|
|
db96ff |
}
|
|
|
db96ff |
- /* parse the result from the bind operation (frees result, get controls) */
|
|
|
db96ff |
+ /* parse the result from the bind operation (frees result, gets controls) */
|
|
|
db96ff |
responsectrls = NULL;
|
|
|
db96ff |
parserc = ldap_parse_result(ld, result, &rc, NULL, NULL, NULL, &responsectrls, 1);
|
|
|
db96ff |
if (parserc != LDAP_SUCCESS)
|
|
|
db96ff |
@@ -575,20 +575,19 @@ static int do_ppolicy_bind(MYLDAP_SESSION *session, LDAP *ld, const char *uri)
|
|
|
db96ff |
ldap_controls_free(responsectrls);
|
|
|
db96ff |
return parserc;
|
|
|
db96ff |
}
|
|
|
db96ff |
- if (rc != LDAP_SUCCESS)
|
|
|
db96ff |
- {
|
|
|
db96ff |
- myldap_err(LOG_ERR, ld, rc, "ldap_parse_result() failed");
|
|
|
db96ff |
- if (responsectrls != NULL)
|
|
|
db96ff |
- ldap_controls_free(responsectrls);
|
|
|
db96ff |
- return rc;
|
|
|
db96ff |
- }
|
|
|
db96ff |
- /* check the returned controls */
|
|
|
db96ff |
+ /* handle any returned controls */
|
|
|
db96ff |
if (responsectrls != NULL)
|
|
|
db96ff |
{
|
|
|
db96ff |
handle_ppasswd_controls(session, ld, responsectrls);
|
|
|
db96ff |
- /* free controls */
|
|
|
db96ff |
ldap_controls_free(responsectrls);
|
|
|
db96ff |
}
|
|
|
db96ff |
+ /* return the result of the BIND operation */
|
|
|
db96ff |
+ if (rc != LDAP_SUCCESS)
|
|
|
db96ff |
+ {
|
|
|
db96ff |
+ myldap_err(LOG_DEBUG, ld, rc, "ldap_parse_result() result");
|
|
|
db96ff |
+ return rc;
|
|
|
db96ff |
+ }
|
|
|
db96ff |
+ /* check the returned controls */
|
|
|
db96ff |
return LDAP_SUCCESS;
|
|
|
db96ff |
}
|
|
|
db96ff |
#endif /* no SASL, so no ppolicy */
|
|
|
db96ff |
--
|
|
|
db96ff |
2.20.1
|
|
|
db96ff |
|