static struct berval newpw = { 0, NULL };
static struct berval oldpw = { 0, NULL };
+static int want_bindearly = 0;
static int want_newpw = 0;
static int want_oldpw = 0;
fprintf( stderr,_("usage: %s [options] [user]\n"), prog);
fprintf( stderr, _(" user: the authentication identity, commonly a DN\n"));
fprintf( stderr, _("Password change options:\n"));
+ fprintf( stderr, _(" -E bind early\n"));
fprintf( stderr, _(" -a secret old password\n"));
fprintf( stderr, _(" -A prompt for old password\n"));
fprintf( stderr, _(" -t file read file for old password\n"));
}
-const char options[] = "a:As:St:T:"
+const char options[] = "Ea:As:St:T:"
"d:D:e:h:H:InNO:o:p:QR:U:vVw:WxX:y:Y:Z";
int
}
#endif
+ case 'E': /* bind to the LDAP server before other actions */
+ want_bindearly++;
+ break;
+
+
case 'a': /* old password (secret) */
oldpw.bv_val = strdup( optarg );
{
user = NULL;
}
+ if( want_bindearly ) {
+ /* bind */
+ ld = tool_conn_setup( 0, 0 );
+
+ tool_bind( ld );
+ }
+
if( oldpwfile ) {
rc = lutil_get_filed_password( oldpwfile, &oldpw );
if( rc ) {
newpw.bv_len = strlen( newpw.bv_val );
}
- ld = tool_conn_setup( 0, 0 );
+ if( ! want_bindearly ) {
+ /* bind */
+ ld = tool_conn_setup( 0, 0 );
- tool_bind( ld );
+ tool_bind( ld );
+ }
if( user != NULL || oldpw.bv_val != NULL || newpw.bv_val != NULL ) {
/* build the password modify request data */