>From 8cdaad6df509807923c90d1cfd3258ed7690fe83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Mon, 5 Sep 2011 09:54:46 +0200 Subject: [PATCH 1/2] sss_ldap_err2string() - function created https://fedorahosted.org/sssd/ticket/986 --- src/providers/ldap/sdap_async_connection.c | 2 -- src/util/sss_ldap.c | 12 ++++++++++++ src/util/sss_ldap.h | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c index 345bd7c..6ff33b1 100644 --- a/src/providers/ldap/sdap_async_connection.c +++ b/src/providers/ldap/sdap_async_connection.c @@ -29,8 +29,6 @@ #include "providers/ldap/sdap_async_private.h" #include "providers/ldap/ldap_common.h" -#define LDAP_X_SSSD_PASSWORD_EXPIRED 0x555D - errno_t deref_string_to_val(const char *str, int *val) { if (strcasecmp(str, "never") == 0) { diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c index 782597d..4783ee6 100644 --- a/src/util/sss_ldap.c +++ b/src/util/sss_ldap.c @@ -30,6 +30,18 @@ #include "util/sss_ldap.h" #include "util/util.h" +const char* sss_ldap_err2string(int err) +{ + static const char *password_expired = "Password expired"; + + switch (err) { + case LDAP_X_SSSD_PASSWORD_EXPIRED: + return password_expired; + default: + return ldap_err2string(err); + } +} + int sss_ldap_get_diagnostic_msg(TALLOC_CTX *mem_ctx, LDAP *ld, char **_errmsg) { char *errmsg = NULL; diff --git a/src/util/sss_ldap.h b/src/util/sss_ldap.h index 437c937..dbd2bd5 100644 --- a/src/util/sss_ldap.h +++ b/src/util/sss_ldap.h @@ -27,6 +27,8 @@ #include #include +#define LDAP_X_SSSD_PASSWORD_EXPIRED 0x555D + #ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE #define SDAP_DIAGNOSTIC_MESSAGE LDAP_OPT_DIAGNOSTIC_MESSAGE #else @@ -37,6 +39,8 @@ #endif #endif +const char* sss_ldap_err2string(int err); + int sss_ldap_get_diagnostic_msg(TALLOC_CTX *mem_ctx, LDAP *ld, char **_errmsg); -- 1.7.6