mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-04-24 15:32:22 +08:00
Don't depend error handling on exact resultCode.
This commit is contained in:
parent
92e2453467
commit
0d1e76246a
@ -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);
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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_errno != LDAP_SUCCESS ) {
|
||||
ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &ld_errtext );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
if (( ld == NULL ) || ( ld_errno != LDAP_UNAVAILABLE &&
|
||||
ld_errno != LDAP_UNWILLING_TO_PERFORM ))
|
||||
{
|
||||
ldap_perror( ld, "modify" );
|
||||
return;
|
||||
}
|
||||
|
||||
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, ".\n Please try again later.\n" );
|
||||
fprintf( stderr, " Please try again later.\n" );
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user