/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2008 The OpenLDAP Foundation.
+ * Copyright 1998-2012 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation.
newpw.bv_len = strlen( newpw.bv_val );
}
- if ( pw_file ) {
- rc = lutil_get_filed_password( pw_file, &passwd );
- if( rc ) {
- rc = EXIT_FAILURE;
- goto done;
- }
-
- } else if ( want_bindpw ) {
- 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 );
- if ( assertion || authzid || manageDSAit || noop ) {
- tool_server_controls( ld, NULL, 0 );
- }
-
if( user != NULL || oldpw.bv_val != NULL || newpw.bv_val != NULL ) {
/* build the password modify request data */
ber = ber_alloc_t( LBER_USE_DER );
struct timeval tv;
if ( tool_check_abandon( ld, id ) ) {
- return LDAP_CANCELLED;
+ tool_exit( ld, LDAP_CANCELLED );
}
tv.tv_sec = 0;
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
if ( rc < 0 ) {
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
- return rc;
+ tool_exit( ld, rc );
}
if ( rc != 0 ) {
perror( "ber_scanf" );
} else {
printf(_("New password: %s\n"), s);
- free( s );
+ ber_memfree( s );
}
ber_free( ber, 1 );
}
if( verbose || code != LDAP_SUCCESS ||
- matcheddn || text || refs || ctrls )
+ ( matcheddn && *matcheddn ) || ( text && *text ) || refs || ctrls )
{
printf( _("Result: %s (%d)\n"), ldap_err2string( code ), code );
done:
/* disconnect from server */
- if ( ld )
- tool_unbind( ld );
- tool_destroy();
- return rc;
+ tool_exit( ld, rc );
}