summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compat/ldap_compat.h8
-rw-r--r--nslcd/myldap.c14
2 files changed, 19 insertions, 3 deletions
diff --git a/compat/ldap_compat.h b/compat/ldap_compat.h
index 322e232..039932c 100644
--- a/compat/ldap_compat.h
+++ b/compat/ldap_compat.h
@@ -62,4 +62,12 @@ int ldap_passwd_s(LDAP *ld,struct berval *user,struct berval *oldpw,
#define LDAP_SASL_QUIET 2U
#endif /* not LDAP_SASL_QUIET */
+/* on some systems LDAP_OPT_DIAGNOSTIC_MESSAGE isn't there but
+ LDAP_OPT_ERROR_STRING is */
+#ifndef LDAP_OPT_DIAGNOSTIC_MESSAGE
+#ifdef LDAP_OPT_ERROR_STRING
+#define LDAP_OPT_DIAGNOSTIC_MESSAGE LDAP_OPT_ERROR_STRING
+#endif /* LDAP_OPT_ERROR_STRING */
+#endif /* not LDAP_OPT_DIAGNOSTIC_MESSAGE */
+
#endif /* COMPAT__LDAP_COMPAT_H */
diff --git a/nslcd/myldap.c b/nslcd/myldap.c
index 70d5c0b..6232c03 100644
--- a/nslcd/myldap.c
+++ b/nslcd/myldap.c
@@ -378,6 +378,7 @@ static int do_sasl_interact(LDAP UNUSED(*ld),unsigned UNUSED(flags),void *defaul
static int do_bind(LDAP *ld,const char *binddn,const char *bindpw,const char *uri)
{
int rc;
+ char *msg=NULL;
#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
#ifndef HAVE_SASL_INTERACT_T
struct berval cred;
@@ -392,9 +393,16 @@ static int do_bind(LDAP *ld,const char *binddn,const char *bindpw,const char *ur
rc=ldap_start_tls_s(ld,NULL,NULL);
if (rc!=LDAP_SUCCESS)
{
- log_log(LOG_WARNING,"ldap_start_tls_s() failed: %s%s%s (uri=\"%s\")",
- ldap_err2string(rc),(errno==0)?"":": ",
- (errno==0)?"":strerror(errno),uri);
+#ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE
+ ldap_get_option(ld,LDAP_OPT_DIAGNOSTIC_MESSAGE,&msg);
+#endif /* LDAP_OPT_DIAGNOSTIC_MESSAGE */
+ log_log(LOG_WARNING,"ldap_start_tls_s() failed: %s%s%s%s%s (uri=\"%s\")",
+ ldap_err2string(rc),
+ (msg==NULL)?"":": ",(msg==NULL)?"":msg,
+ (errno==0)?"":": ",(errno==0)?"":strerror(errno),
+ uri);
+ if (msg)
+ ldap_memfree(msg);
return rc;
}
}