X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=clients%2Ftools%2Fldapexop.c;h=4e3f48ac6646b30c6db9a2bfbf918e1b745f6fc9;hb=3743a5a68e4d608949d5fd04904733ee5c1ac959;hp=ac8f9be5aaf8a2b1247b32631fdd8bf2b84647c6;hpb=86b5de38be0a84cf2e96fcfd14163761fbab2048;p=openldap
diff --git a/clients/tools/ldapexop.c b/clients/tools/ldapexop.c
index ac8f9be5aa..4e3f48ac66 100644
--- a/clients/tools/ldapexop.c
+++ b/clients/tools/ldapexop.c
@@ -2,7 +2,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2005-2008 The OpenLDAP Foundation.
+ * Copyright 2005-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,9 @@ usage( void )
{
fprintf( stderr, _("Issue LDAP extended operations\n\n"));
fprintf( stderr, _("usage: %s [options] \n"), prog);
+ fprintf( stderr, _(" %s [options] whoami\n"), prog);
+ fprintf( stderr, _(" %s [options] cancel \n"), prog);
+ fprintf( stderr, _(" %s [options] refresh []\n"), prog);
tool_common_usage();
exit( EXIT_FAILURE );
}
@@ -72,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 );
@@ -86,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 );
@@ -152,8 +145,6 @@ main( int argc, char *argv[] )
case 2:
dn.bv_val = argv[ 1 ];
dn.bv_len = strlen( dn.bv_val );
-
- case 1:
break;
default:
@@ -222,7 +213,7 @@ main( int argc, char *argv[] )
struct timeval tv;
if ( tool_check_abandon( ld, id ) ) {
- return LDAP_CANCELLED;
+ tool_exit( ld, LDAP_CANCELLED );
}
tv.tv_sec = 0;
@@ -256,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 );
@@ -303,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;
@@ -327,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 ) {
@@ -357,8 +349,7 @@ main( int argc, char *argv[] )
skip:
/* disconnect from server */
- tool_unbind( ld );
- tool_destroy();
-
- return code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
+ if ( res )
+ ldap_msgfree( res );
+ tool_exit( ld, code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE );
}