]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapexop.c
Merge remote branch 'origin/mdb.master'
[openldap] / clients / tools / ldapexop.c
index e9f5d285dec5535bd4a2370d2108afd723c38ade..6fc4d1e3c6b3a1f93746ff3f6bbf92fb85a52e9e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2005-2009 The OpenLDAP Foundation.
+ * Copyright 2005-2011 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -75,7 +75,7 @@ main( int argc, char *argv[] )
        char            *matcheddn = NULL, *text = NULL, **refs = NULL;
        LDAPControl **ctrls = NULL;
        int             id, code;
-       LDAPMessage     *res;
+       LDAPMessage     *res = NULL;
 
        tool_init( TOOL_EXOP );
        prog = lutil_progname( "ldapexop", argc, argv );
@@ -89,16 +89,6 @@ main( int argc, char *argv[] )
                usage();
        }
 
-       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;
-               }
-       }
-
        ld = tool_conn_setup( 0, 0 );
 
        tool_bind( ld );
@@ -257,7 +247,7 @@ main( int argc, char *argv[] )
                char            *retoid = NULL;
                struct berval   *retdata = NULL;
 
-               rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 1 );
+               rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 0 );
 
                if ( rc != LDAP_SUCCESS ) {
                        tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL );
@@ -304,7 +294,7 @@ main( int argc, char *argv[] )
                        printf(_("# extended operation response\n"));
                }
 
-               rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 1 );
+               rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 0 );
                if ( rc != LDAP_SUCCESS ) {
                        tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL );
                        rc = EXIT_FAILURE;
@@ -328,7 +318,8 @@ main( int argc, char *argv[] )
                }
        }
 
-       if( verbose || ( code != LDAP_SUCCESS ) || matcheddn || text || refs ) {
+       if( verbose || code != LDAP_SUCCESS ||
+               ( matcheddn && *matcheddn ) || ( text && *text ) || refs ) {
                printf( _("Result: %s (%d)\n"), ldap_err2string( code ), code );
 
                if( text && *text ) {
@@ -358,6 +349,8 @@ main( int argc, char *argv[] )
 
 skip:
        /* disconnect from server */
+       if ( res )
+               ldap_msgfree( res );
        tool_unbind( ld );
        tool_destroy();