mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
improve tester_ldap_error
This commit is contained in:
parent
c9b3cf7fab
commit
4c39d2c5a0
@ -53,16 +53,59 @@ tester_uri( char *uri, char *host, int port )
|
||||
void
|
||||
tester_ldap_error( LDAP *ld, const char *fname )
|
||||
{
|
||||
int err;
|
||||
const char *text = "Success";
|
||||
int err;
|
||||
char *text = NULL;
|
||||
LDAPControl **ctrls = NULL;
|
||||
|
||||
ldap_get_option( ld, LDAP_OPT_RESULT_CODE, (void *)&err );
|
||||
if ( err != LDAP_SUCCESS ) {
|
||||
ldap_get_option( ld, LDAP_OPT_ERROR_STRING, (void *)&text );
|
||||
}
|
||||
|
||||
fprintf( stderr, "%s: %s: (%d) %s\n",
|
||||
progname, fname, err, text == NULL ? "" : text );
|
||||
fprintf( stderr, "%s: %s: %s (%d) %s\n",
|
||||
progname, fname, ldap_err2string( err ), err,
|
||||
text == NULL ? "" : text );
|
||||
|
||||
if ( text ) {
|
||||
ldap_memfree( text );
|
||||
text = NULL;
|
||||
}
|
||||
|
||||
ldap_get_option( ld, LDAP_OPT_MATCHED_DN, (void *)&text );
|
||||
if ( text != NULL ) {
|
||||
fprintf( stderr, "\tmatched: %s\n", text );
|
||||
ldap_memfree( text );
|
||||
text = NULL;
|
||||
}
|
||||
|
||||
ldap_get_option( ld, LDAP_OPT_SERVER_CONTROLS, (void *)&ctrls );
|
||||
if ( ctrls != NULL ) {
|
||||
int i;
|
||||
|
||||
fprintf( stderr, "\tcontrols:\n" );
|
||||
for ( i = 0; ctrls[ i ] != NULL; i++ ) {
|
||||
fprintf( stderr, "\t\t%s\n", ctrls[ i ]->ldctl_oid );
|
||||
}
|
||||
ldap_controls_free( ctrls );
|
||||
ctrls = NULL;
|
||||
}
|
||||
|
||||
if ( err == LDAP_REFERRAL ) {
|
||||
char **refs = NULL;
|
||||
|
||||
ldap_get_option( ld, LDAP_OPT_REFERRAL_URLS, (void *)&refs );
|
||||
|
||||
if ( refs ) {
|
||||
int i;
|
||||
|
||||
fprintf( stderr, "\treferral:\n" );
|
||||
for ( i = 0; refs[ i ] != NULL; i++ ) {
|
||||
fprintf( stderr, "\t\t%s\n", refs[ i ] );
|
||||
}
|
||||
|
||||
ber_memvfree( (void **)refs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user