From 206b1aed557abd1b29b9fc296d6d7ce3c0eba899 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 18 Jul 2007 17:38:30 +0000 Subject: [PATCH] Parse server controls on each response, and print them. --- clients/tools/ldapcompare.c | 16 +++++++++++----- clients/tools/ldapdelete.c | 8 +++++++- clients/tools/ldapexop.c | 8 +++++++- clients/tools/ldapmodify.c | 2 +- clients/tools/ldapmodrdn.c | 8 +++++++- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/clients/tools/ldapcompare.c b/clients/tools/ldapcompare.c index 47753525e1..18f9179476 100644 --- a/clients/tools/ldapcompare.c +++ b/clients/tools/ldapcompare.c @@ -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 ); } diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index 8133a2d3a0..635db793fa 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -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 ); diff --git a/clients/tools/ldapexop.c b/clients/tools/ldapexop.c index 5a53b5be7e..6de7ec2bd0 100644 --- a/clients/tools/ldapexop.c +++ b/clients/tools/ldapexop.c @@ -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 ); diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index dcd522c28b..db600c1298 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -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 ); } diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index 9b03471f47..477b74e365 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -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 ); -- 2.39.5