diff mbox

[05/17] libnsdb: Remove *ldaperr argument from nsdb_open_nsdb()

Message ID 20140102202737.2964.72166.stgit@seurat.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever Jan. 2, 2014, 8:27 p.m. UTC
Simplify nsdb_open_nsdb() by removing the *ldaperr argument.
Instead, the ldaperr value can be extracted with the new
nsdb_ldaperr() function when it is needed.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 src/fedfsd/svc.c             |    2 +-
 src/include/nsdb.h           |    3 +--
 src/libnsdb/fileserver.c     |    6 ++++--
 src/libnsdb/nsdb.c           |   12 ++++++------
 src/nfsref/add.c             |    7 +++----
 src/nfsref/lookup.c          |    4 ++--
 src/nfsref/remove.c          |    6 +++---
 src/nsdbc/nsdb-annotate.c    |    6 +++---
 src/nsdbc/nsdb-create-fsl.c  |    6 +++---
 src/nsdbc/nsdb-create-fsn.c  |    6 +++---
 src/nsdbc/nsdb-delete-fsl.c  |    6 +++---
 src/nsdbc/nsdb-delete-fsn.c  |    6 +++---
 src/nsdbc/nsdb-delete-nsdb.c |    6 +++---
 src/nsdbc/nsdb-describe.c    |    6 +++---
 src/nsdbc/nsdb-list.c        |    4 ++--
 src/nsdbc/nsdb-nces.c        |    4 ++--
 src/nsdbc/nsdb-remove-nci.c  |    6 +++---
 src/nsdbc/nsdb-resolve-fsn.c |    4 ++--
 src/nsdbc/nsdb-simple-nce.c  |    6 +++---
 src/nsdbc/nsdb-update-fsl.c  |    6 +++---
 src/nsdbc/nsdb-update-nci.c  |    6 +++---
 src/plug-ins/nfs-plugin.c    |    4 ++--
 22 files changed, 61 insertions(+), 61 deletions(-)
diff mbox

Patch

diff --git a/src/fedfsd/svc.c b/src/fedfsd/svc.c
index 391583b..3aa4314 100644
--- a/src/fedfsd/svc.c
+++ b/src/fedfsd/svc.c
@@ -918,7 +918,7 @@  again:
 	case FEDFS_RESOLVE_NONE:
 		break;
 	case FEDFS_RESOLVE_NSDB:
-		result.status = nsdb_open_nsdb(host, NULL, NULL, &ldap_err);
+		result.status = nsdb_open_nsdb(host, NULL, NULL);
 		if (result.status != FEDFS_OK)
 			break;
 
diff --git a/src/include/nsdb.h b/src/include/nsdb.h
index d1aafe1..56a26a2 100644
--- a/src/include/nsdb.h
+++ b/src/include/nsdb.h
@@ -244,8 +244,7 @@  FedFsStatus	 nsdb_delete_nsdb(const char *hostname,
  * Connect an nsdb_t object to the server it represents
  */
 FedFsStatus	 nsdb_open_nsdb(nsdb_t host, const char *binddn,
-				const char *passwd,
-				unsigned int *ldap_err);
+				const char *passwd);
 
 /**
  * Finish a previously opened connection
diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index 872d10c..f6a6e53 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -2038,9 +2038,11 @@  nsdb_ping_s(const char *hostname, const unsigned short port,
 	if (retval != FEDFS_OK)
 		return retval;
 
-	retval = nsdb_open_nsdb(host, NULL, NULL, ldap_err);
-	if (retval != FEDFS_OK)
+	retval = nsdb_open_nsdb(host, NULL, NULL);
+	if (retval != FEDFS_OK) {
+		*ldap_err = (unsigned int)nsdb_ldaperr(host);
 		goto out_free;
+	}
 
 	retval = nsdb_ping_nsdb_s(host, ldap_err);
 	nsdb_close_nsdb(host);
diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c
index 31cf5ce..7320b05 100644
--- a/src/libnsdb/nsdb.c
+++ b/src/libnsdb/nsdb.c
@@ -1505,7 +1505,6 @@  nsdb_delete_nsdb(const char *hostname, const unsigned short port)
  * @param host an initialized nsdb_t object
  * @param binddn NUL-terminated UTF-8 C string containing DN to which to bind
  * @param passwd NUL-terminated UTF-8 C string containing bind password
- * @param ldap_err OUT: possibly an LDAP error code
  * @return a FedFsStatus code
  *
  * This function may ask for a password on stdin if "binddn" is
@@ -1514,13 +1513,13 @@  nsdb_delete_nsdb(const char *hostname, const unsigned short port)
  * When false is returned, the nsdb_t object remains closed.
  */
 FedFsStatus
-nsdb_open_nsdb(nsdb_t host, const char *binddn, const char *passwd,
-		unsigned int *ldap_err)
+nsdb_open_nsdb(nsdb_t host, const char *binddn, const char *passwd)
 {
 	FedFsStatus retval;
 	LDAP *ld;
 
-	retval = nsdb_open(host->fn_hostname, host->fn_port, &ld, ldap_err);
+	retval = nsdb_open(host->fn_hostname, host->fn_port, &ld,
+				&host->fn_ldaperr);
 	if (retval != FEDFS_OK)
 		return retval;
 
@@ -1528,7 +1527,8 @@  nsdb_open_nsdb(nsdb_t host, const char *binddn, const char *passwd,
 	case FEDFS_SEC_NONE:
 		break;
 	case FEDFS_SEC_TLS:
-		retval = nsdb_start_tls(ld, nsdb_certfile(host), ldap_err);
+		retval = nsdb_start_tls(ld, nsdb_certfile(host),
+						&host->fn_ldaperr);
 		if (retval != FEDFS_OK)
 			goto out_unbind;
 		break;
@@ -1539,7 +1539,7 @@  nsdb_open_nsdb(nsdb_t host, const char *binddn, const char *passwd,
 		goto out_unbind;
 	}
 
-	retval = nsdb_bind(ld, binddn, passwd, ldap_err);
+	retval = nsdb_bind(ld, binddn, passwd, &host->fn_ldaperr);
 	if (retval != FEDFS_OK)
 		goto out_unbind;
 
diff --git a/src/nfsref/add.c b/src/nfsref/add.c
index 8e925cc..4d527da 100644
--- a/src/nfsref/add.c
+++ b/src/nfsref/add.c
@@ -559,7 +559,6 @@  nfsref_add_nfs_fedfs(const char *junct_path, char **argv, int optind)
 {
 	char *binddn, *nsdbname, *nce;
 	unsigned short nsdbport;
-	unsigned int ldap_err;
 	FedFsStatus retval;
 	nsdb_t host = NULL;
 	int status = EXIT_FAILURE;
@@ -600,7 +599,7 @@  nfsref_add_nfs_fedfs(const char *junct_path, char **argv, int optind)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -616,7 +615,7 @@  nfsref_add_nfs_fedfs(const char *junct_path, char **argv, int optind)
 			"NSDB %s:%u", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			xlog(L_ERROR, "Incorrect password for DN %s",
 				binddn);
@@ -624,7 +623,7 @@  nfsref_add_nfs_fedfs(const char *junct_path, char **argv, int optind)
 		default:
 			xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s",
 				nsdbname, nsdbport,
-				ldap_err2string(ldap_err));
+				nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nfsref/lookup.c b/src/nfsref/lookup.c
index 1271e3d..273663b 100644
--- a/src/nfsref/lookup.c
+++ b/src/nfsref/lookup.c
@@ -353,7 +353,7 @@  nfsref_lookup_resolve_fsn(const char *fsn_uuid, nsdb_t host)
 		__func__, fsn_uuid, nsdb_hostname(host), nsdb_port(host));
 
 again:
-	retval = nsdb_open_nsdb(host, NULL, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, NULL, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -368,7 +368,7 @@  again:
 	case FEDFS_ERR_NSDB_LDAP_VAL:
 		xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s",
 			nsdb_hostname(host), nsdb_port(host),
-			ldap_err2string(ldap_err));
+			nsdb_ldaperr2string(host));
 		return status;
 	default:
 		xlog(L_ERROR, "Failed to open NSDB %s:%u: %s",
diff --git a/src/nfsref/remove.c b/src/nfsref/remove.c
index b4394c1..aa8249e 100644
--- a/src/nfsref/remove.c
+++ b/src/nfsref/remove.c
@@ -136,7 +136,7 @@  nfsref_remove_delete_fsn(const char *junct_path)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -152,7 +152,7 @@  nfsref_remove_delete_fsn(const char *junct_path)
 			"to NSDB %s:%u", nsdb_hostname(host), nsdb_port(host));
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			xlog(L_ERROR, "Incorrect password for DN %s",
 				binddn);
@@ -160,7 +160,7 @@  nfsref_remove_delete_fsn(const char *junct_path)
 		default:
 			xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s",
 				nsdb_hostname(host), nsdb_port(host),
-				ldap_err2string(ldap_err));
+				nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-annotate.c b/src/nsdbc/nsdb-annotate.c
index d35c7a4..6d10465 100644
--- a/src/nsdbc/nsdb-annotate.c
+++ b/src/nsdbc/nsdb-annotate.c
@@ -244,7 +244,7 @@  main(int argc, char **argv)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -260,14 +260,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-create-fsl.c b/src/nsdbc/nsdb-create-fsl.c
index 06134e9..a538eb1 100644
--- a/src/nsdbc/nsdb-create-fsl.c
+++ b/src/nsdbc/nsdb-create-fsl.c
@@ -248,7 +248,7 @@  main(int argc, char **argv)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -264,14 +264,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-create-fsn.c b/src/nsdbc/nsdb-create-fsn.c
index d6c39ea..8c99b26 100644
--- a/src/nsdbc/nsdb-create-fsn.c
+++ b/src/nsdbc/nsdb-create-fsn.c
@@ -224,7 +224,7 @@  main(int argc, char **argv)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -240,14 +240,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-delete-fsl.c b/src/nsdbc/nsdb-delete-fsl.c
index f64a8fd..5e19e8d 100644
--- a/src/nsdbc/nsdb-delete-fsl.c
+++ b/src/nsdbc/nsdb-delete-fsl.c
@@ -206,7 +206,7 @@  main(int argc, char **argv)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -222,14 +222,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-delete-fsn.c b/src/nsdbc/nsdb-delete-fsn.c
index 3060c24..42073e8 100644
--- a/src/nsdbc/nsdb-delete-fsn.c
+++ b/src/nsdbc/nsdb-delete-fsn.c
@@ -208,7 +208,7 @@  main(int argc, char **argv)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -224,14 +224,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-delete-nsdb.c b/src/nsdbc/nsdb-delete-nsdb.c
index 2e793bf..673170f 100644
--- a/src/nsdbc/nsdb-delete-nsdb.c
+++ b/src/nsdbc/nsdb-delete-nsdb.c
@@ -181,7 +181,7 @@  main(int argc, char **argv)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -197,14 +197,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-describe.c b/src/nsdbc/nsdb-describe.c
index ec060be..eca70b1 100644
--- a/src/nsdbc/nsdb-describe.c
+++ b/src/nsdbc/nsdb-describe.c
@@ -201,7 +201,7 @@  main(int argc, char **argv)
 		goto out_free;
 	}
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -217,14 +217,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-list.c b/src/nsdbc/nsdb-list.c
index e6de357..5cc20a7 100644
--- a/src/nsdbc/nsdb-list.c
+++ b/src/nsdbc/nsdb-list.c
@@ -361,7 +361,7 @@  main(int argc, char **argv)
 	}
 
 again:
-	retval = nsdb_open_nsdb(host, NULL, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, NULL, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -375,7 +375,7 @@  again:
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+			nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to open NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-nces.c b/src/nsdbc/nsdb-nces.c
index c67fd18..f7b405c 100644
--- a/src/nsdbc/nsdb-nces.c
+++ b/src/nsdbc/nsdb-nces.c
@@ -166,7 +166,7 @@  main(int argc, char **argv)
 		goto out;
 	}
 
-	retval = nsdb_open_nsdb(host, NULL, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, NULL, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -180,7 +180,7 @@  main(int argc, char **argv)
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+			nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to open NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-remove-nci.c b/src/nsdbc/nsdb-remove-nci.c
index f6b58c9..d5d44a2 100644
--- a/src/nsdbc/nsdb-remove-nci.c
+++ b/src/nsdbc/nsdb-remove-nci.c
@@ -176,7 +176,7 @@  main(int argc, char **argv)
 
 	if (binddn == NULL)
 		binddn = (char *)nsdb_default_binddn(host);
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -192,14 +192,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-resolve-fsn.c b/src/nsdbc/nsdb-resolve-fsn.c
index 1230e6d..6baac28 100644
--- a/src/nsdbc/nsdb-resolve-fsn.c
+++ b/src/nsdbc/nsdb-resolve-fsn.c
@@ -335,7 +335,7 @@  main(int argc, char **argv)
 	}
 
 again:
-	retval = nsdb_open_nsdb(host, NULL, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, NULL, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -349,7 +349,7 @@  again:
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+			nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to open NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-simple-nce.c b/src/nsdbc/nsdb-simple-nce.c
index 75c0386..dce4b31 100644
--- a/src/nsdbc/nsdb-simple-nce.c
+++ b/src/nsdbc/nsdb-simple-nce.c
@@ -176,7 +176,7 @@  main(int argc, char **argv)
 
 	if (binddn == NULL)
 		binddn = (char *)nsdb_default_binddn(host);
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -192,14 +192,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-update-fsl.c b/src/nsdbc/nsdb-update-fsl.c
index f5a4cb9..17514c2 100644
--- a/src/nsdbc/nsdb-update-fsl.c
+++ b/src/nsdbc/nsdb-update-fsl.c
@@ -217,7 +217,7 @@  main(int argc, char **argv)
 	if (nce == NULL)
 		nce = (char *)nsdb_default_nce(host);
 
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -233,14 +233,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-update-nci.c b/src/nsdbc/nsdb-update-nci.c
index 2da0aa1..f2b0295 100644
--- a/src/nsdbc/nsdb-update-nci.c
+++ b/src/nsdbc/nsdb-update-nci.c
@@ -184,7 +184,7 @@  main(int argc, char **argv)
 
 	if (binddn == NULL)
 		binddn = (char *)nsdb_default_binddn(host);
-	retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, binddn, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -200,14 +200,14 @@  main(int argc, char **argv)
 			"to NSDB %s:%u\n", nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		switch (ldap_err) {
+		switch (nsdb_ldaperr(host)) {
 		case LDAP_INVALID_CREDENTIALS:
 			fprintf(stderr, "Incorrect password for DN %s\n",
 				binddn);
 			break;
 		default:
 			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
-				nsdbname, nsdbport, ldap_err2string(ldap_err));
+				nsdbname, nsdbport, nsdb_ldaperr2string(host));
 		}
 		goto out_free;
 	default:
diff --git a/src/plug-ins/nfs-plugin.c b/src/plug-ins/nfs-plugin.c
index dbe84d9..25e97e2 100644
--- a/src/plug-ins/nfs-plugin.c
+++ b/src/plug-ins/nfs-plugin.c
@@ -395,7 +395,7 @@  nfs_jp_resolve_fsn(const char *fsn_uuid, nsdb_t host,
 	int fsn_ttl;
 
 again:
-	retval = nsdb_open_nsdb(host, NULL, NULL, &ldap_err);
+	retval = nsdb_open_nsdb(host, NULL, NULL);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
@@ -410,7 +410,7 @@  again:
 	case FEDFS_ERR_NSDB_LDAP_VAL:
 		nfs_jp_debug("%s: Failed to bind to NSDB %s:%u: %s\n",
 			nsdb_hostname(host), nsdb_port(host),
-			ldap_err2string(ldap_err));
+			nsdb_ldaperr2string(host));
 		return JP_NSDBLOCAL;
 	default:
 		nfs_jp_debug("%s: Failed to open NSDB %s:%u: %s\n",