Parse server controls on each response, and print them.

This commit is contained in:
Kurt Zeilenga 2007-07-18 17:38:30 +00:00
parent 0bb7d51883
commit 206b1aed55
5 changed files with 33 additions and 9 deletions

View File

@ -288,6 +288,7 @@ static int docompare(
char *matcheddn;
char *text;
char **refs;
LDAPControl **ctrls = NULL;
if ( dont ) {
return LDAP_SUCCESS;
@ -320,7 +321,7 @@ static int docompare(
}
}
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 1 );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n",
@ -350,10 +351,6 @@ static int docompare(
}
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
/* if we were told to be quiet, use the return value. */
if ( !quiet ) {
if ( code == LDAP_COMPARE_TRUE ) {
@ -365,6 +362,15 @@ static int docompare(
}
}
if ( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
return( code );
}

View File

@ -210,6 +210,7 @@ static int dodelete(
int id;
int rc, code;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
LDAPControl **ctrls = NULL;
LDAPMessage *res;
if ( verbose ) {
@ -254,7 +255,7 @@ static int dodelete(
}
}
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 1 );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n",
@ -286,6 +287,11 @@ static int dodelete(
}
}
if (ctrls) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );

View File

@ -70,6 +70,7 @@ main( int argc, char *argv[] )
LDAP *ld = NULL;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
LDAPControl **ctrls = NULL;
int id, code;
LDAPMessage *res;
@ -240,7 +241,7 @@ main( int argc, char *argv[] )
}
rc = ldap_parse_result( ld, res,
&code, &matcheddn, &text, &refs, NULL, 0 );
&code, &matcheddn, &text, &refs, &ctrls, 0 );
if ( rc == LDAP_SUCCESS ) {
rc = code;
}
@ -345,6 +346,11 @@ main( int argc, char *argv[] )
}
}
if (ctrls) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );

View File

@ -1296,7 +1296,7 @@ static int process_response(
if ( matched ) ldap_memfree( matched );
if ( text ) ber_memvfree( (void **)refs );
if ( ctrls != NULL ) {
if ( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}

View File

@ -241,6 +241,7 @@ static int domodrdn(
{
int rc, code, id;
char *matcheddn=NULL, *text=NULL, **refs=NULL;
LDAPControl **ctrls = NULL;
LDAPMessage *res;
if ( verbose ) {
@ -284,7 +285,7 @@ static int domodrdn(
}
}
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 1 );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n",
@ -314,6 +315,11 @@ static int domodrdn(
}
}
if (ctrls) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );