From: Kurt Zeilenga Date: Wed, 26 Apr 2000 09:21:19 +0000 (+0000) Subject: Don't depend error handling on exact resultCode. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~3057 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0d1e76246a0ef8b993cbbd6a5295da8c8b02403d;p=openldap Don't depend error handling on exact resultCode. --- diff --git a/clients/ud/find.c b/clients/ud/find.c index 59a89ebf15..a569458caf 100644 --- a/clients/ud/find.c +++ b/clients/ud/find.c @@ -231,12 +231,7 @@ find( char *who, int quiet ) rc = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, NULL, read_attrs, FALSE, &res); ldap_memfree(dn); if (rc != LDAP_SUCCESS) { - int ld_errno = 0; - ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); - if (ld_errno == LDAP_UNAVAILABLE) - printf(" Could not contact the LDAP server to find \"%s\".\n", who); - else - ldap_perror(ld, "ldap_search_s"); + ldap_perror(ld, "ldap_search_s"); return(NULL); } ldap_set_option(ld, LDAP_OPT_DEREF, &savederef); diff --git a/clients/ud/main.c b/clients/ud/main.c index 2aeb8e0c09..794b77d38c 100644 --- a/clients/ud/main.c +++ b/clients/ud/main.c @@ -660,12 +660,7 @@ initialize_client( void ) } if (ldap_bind_s(ld, (char *) default_bind_object, NULL, LDAP_AUTH_SIMPLE) != LDAP_SUCCESS) { - int ld_errno = 0; - ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); - - fprintf(stderr, " The LDAP Directory is temporarily unavailable. Please try again later.\n"); - if (ld_errno != LDAP_UNAVAILABLE) - ldap_perror(ld, " ldap_bind_s"); + ldap_perror(ld, " ldap_bind_s"); exit( EXIT_FAILURE ); /* NOTREACHED */ } diff --git a/clients/ud/mod.c b/clients/ud/mod.c index 759f3f0943..a955b17161 100644 --- a/clients/ud/mod.c +++ b/clients/ud/mod.c @@ -788,23 +788,22 @@ check_URL( char *url ) void mod_perror( LDAP *ld ) { - int ld_errno = 0; + int ld_errno = LDAP_SUCCESS; + char *ld_errtext = NULL; - if(ld != NULL) { - ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); - } + ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno ); - if (( ld == NULL ) || ( ld_errno != LDAP_UNAVAILABLE && - ld_errno != LDAP_UNWILLING_TO_PERFORM )) - { - ldap_perror( ld, "modify" ); - return; - } + if( ld_errno != LDAP_SUCCESS ) { + ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &ld_errtext ); + } - fprintf( stderr, "\n modify: failed because part of the online directory is not able\n" ); - fprintf( stderr, " to be modified right now" ); - if ( ld_errno == LDAP_UNAVAILABLE ) { - fprintf( stderr, " or is temporarily unavailable" ); + fprintf( stderr, " modify failed: %s (%d)\n", + ldap_err2string( ld_errno ), ld_errno ); + + if( ld_errtext != NULL ) { + fprintf( stderr, " additional information: %s\n", + ld_errtext ); } - fprintf( stderr, ".\n Please try again later.\n" ); + + fprintf( stderr, " Please try again later.\n" ); } diff --git a/contrib/whois++/whois++.c b/contrib/whois++/whois++.c index 7e20bcc742..d353408a94 100644 --- a/contrib/whois++/whois++.c +++ b/contrib/whois++/whois++.c @@ -195,13 +195,6 @@ char **argv; case LDAP_SUCCESS: break; - case LDAP_UNAVAILABLE: - printFormatted( lineLength, TRUE, stdout, - "Sorry, the X.500 service is temporarily unavailable. \ -Please try again later." ); - syslog( LOG_NOTICE, "X.500 service temporarily unavailable" ); - exit( 1 ); - default: printFormatted( lineLength, TRUE, stdout, "Bind to Directory failed, %s",