]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapcompare.c
Merge remote branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / clients / tools / ldapcompare.c
index 47753525e17166b6a19f4892ec6405a541ffcf3d..831f11674c78bfb66b6eaf1d62d14767fba5eaf8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2012 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * All rights reserved.
@@ -85,6 +85,8 @@ usage( void )
        fprintf( stderr, _("Compare options:\n"));
        fprintf( stderr, _("  -E [!]<ext>[=<extparam>] compare extensions (! indicates criticality)\n"));
        fprintf( stderr, _("             !dontUseCopy                (Don't Use Copy)\n"));
+       fprintf( stderr, _("  -M         enable Manage DSA IT control (-MM to make critical)\n"));
+       fprintf( stderr, _("  -P version protocol version (default: 3)\n"));
        fprintf( stderr, _("  -z         Quiet mode,"
                " don't print anything, use return values\n"));
        tool_common_usage();
@@ -102,7 +104,7 @@ static int docompare LDAP_P((
 
 
 const char options[] = "z"
-       "Cd:D:e:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
+       "Cd:D:e:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
 
 #ifdef LDAP_CONTROL_DONTUSECOPY
 int dontUseCopy = 0;
@@ -228,16 +230,6 @@ main( int argc, char **argv )
 
        ld = tool_conn_setup( 0, 0 );
 
-       if ( pw_file || want_bindpw ) {
-               if ( pw_file ) {
-                       rc = lutil_get_filed_password( pw_file, &passwd );
-                       if( rc ) return EXIT_FAILURE;
-               } else {
-                       passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
-                       passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
-               }
-       }
-
        tool_bind( ld );
 
        if ( 0
@@ -268,9 +260,7 @@ main( int argc, char **argv )
 
        free( bvalue.bv_val );
 
-       tool_unbind( ld );
-       tool_destroy();
-       return rc;
+       tool_exit( ld, rc );
 }
 
 
@@ -288,6 +278,7 @@ static int docompare(
        char            *matcheddn;
        char            *text;
        char            **refs;
+       LDAPControl **ctrls = NULL;
 
        if ( dont ) {
                return LDAP_SUCCESS;
@@ -320,7 +311,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 +341,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 +352,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 );
 }