X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=clients%2Ftools%2Fldapexop.c;h=6fc4d1e3c6b3a1f93746ff3f6bbf92fb85a52e9e;hb=8917b774f71562cdfaaddd7641889ab79ef95273;hp=03ec8fae01977b2cb3544c5d632fc26fb2e76e2c;hpb=b7c41e655ffc263ff826d4c9b577b205480d96ab;p=openldap
diff --git a/clients/tools/ldapexop.c b/clients/tools/ldapexop.c
index 03ec8fae01..6fc4d1e3c6 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-2006 The OpenLDAP Foundation.
+ * Copyright 2005-2011 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,13 +43,16 @@ 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 );
}
const char options[] = ""
- "d:D:e:h:H:InO:o:p:QR:U:vVw:WxX:y:Y:Z";
+ "d:D:e:h:H:InNO:o:p:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
@@ -66,13 +69,13 @@ int
main( int argc, char *argv[] )
{
int rc;
- char *user = NULL;
LDAP *ld = NULL;
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 );
@@ -104,18 +97,6 @@ main( int argc, char *argv[] )
argc -= optind;
if ( strcasecmp( argv[ 0 ], "whoami" ) == 0 ) {
- switch ( argc ) {
- case 2:
- user = argv[ 1 ];
-
- case 1:
- break;
-
- default:
- fprintf( stderr, "need [user]\n\n" );
- usage();
- }
-
tool_server_controls( ld, NULL, 0 );
rc = ldap_whoami( ld, NULL, NULL, &id );
@@ -164,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:
@@ -253,7 +232,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;
}
@@ -268,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 );
@@ -315,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;
@@ -339,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,12 +338,19 @@ 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 );
skip:
/* disconnect from server */
+ if ( res )
+ ldap_msgfree( res );
tool_unbind( ld );
tool_destroy();