Post by Guenter Knauf, DevNet SysOp 32Post by BradDoes anyone have any examples of reseting passwords from the
command line?
http://www.gknw.at/nwperl/perlucx/chpasswd.txt
http://www.gknw.at/nwperl/perlucx
and adapt the script for newer UCS/UCX.
Hello Guenter,
I did find your change password script over the weekend.
I was able to modify it for my uses.
I didn't find that list with all those scripts though.
That's great work on all of those. I have lots of new
ideas for administrative tasks now.
Thanks a lot for doing all the base work! :)
I have a few questions and suggestions.
How can I get a list if options when performing
this type of operation:
$uentry->GetFieldValue("xxx");
$uentry->SetPassword
$nwdir->FindEntry($objname)
what other options beside "GetFieldValue", "SetPasword", or "FindEntry"?
Just curious. I haven't seen that any where in the docs.
I have a question I wonder if you or anyone could help with.
I have modified the userQuotas.pl file that is to
set/remove user space restrictions.
I can run it from command line or from a web browser.
However, I just realized today that when the (cluster)
volume moves to the other server I can no longer
set/remove user quotas. I looked through your perl
examples I didn't see any that actually reset user quotas.
I did find one that get restrictions, but when I run it
I get "Unable to get Volume object" I'm still working on
that problem.
Do you know if the UCS/UCX stuff will handle cluster volumes
correctly? The userQuotas.pl uses virtualIO commands:
<virtualIO><datastream
name=\"command\"/></virtualIO><nssRequest><userSpaceRestrictions>"
$command."</userSpaceRestrictions><
so I don't see any way that that could accommodate for cluster volumes.
Also, I have some updated code for your password reset file. I couldn't
get the file to work correctly. For one thing the perl that should
read in a user from the command line and reverse it didn't seem to work.
I don't know that much about string manipulation in perl, so I had a
friend give me a snippit of code that takes an user in this format:
user.container.container.container.organization
and spits it out like this:
NDS:\\TREE\organization\container\container\container\user
here's the perl snippit:
my @arr = split(/\./,$newobje);
$newobj = "NDS:\\\\SLU\\" . join("\\",reverse @arr);
and here's the whole script(minus my admin user/pw):
#!perl
# test script using ucx:NWDir to change users password.
# v0.01 26-Okt-2001 (c) G.Knauf, ***@gknw.de
use UCSExt;
use Getopt::Std;
#getopts('dn:t:u:p:');
my $ADMIN_USERNAME="adminuser.container.organization";
my $ADMIN_PASSWORD = "password";
#$user = $opt_u || die "You must specify a username with -u!\n";
#$opass = $opt_p || die "You must specify an old password with -p!\n";
#$npass = $opt_n || die "You must specify a new password with -n!\n";
$username = $ARGV[0];
$opass ="";
#$newpass =$ARGV[1];
$newpass ="welcome";
change_pw( );
exit;
sub change_pw {
$nwdir = UCSExt->new('UCX:NWDIR') or die "Unable to create NWDir object
\n";
$nwdir->login($ADMIN_USERNAME,$ADMIN_PASSWORD) or die "$ADMIN_USERNAME:
unable to login!\n";
$newobje = $username;
my @arr = split(/\./,$newobje);
$newobj = "NDS:\\\\SLU\\" . join("\\",reverse @arr);
$uentry = $nwdir->FindEntry($newobj) or die "Can't find user: $newobje\n";
print ("Changing password for user: \n", $username);
print "\nPassword Required:\n ";
if ($uentry->GetFieldValue("Password Required")) {
print ("yes \n Minimum Password Length:\n "
$uentry->GetFieldValue("Password Minimum Length"));
} else {
print "no\n";
}
$uentry->SetPassword ($newpass) or die "Failed to change password for
$newobj\n";
print "\nPassword changed to: $newpass\n";
print "\n";
$nwdir->logout;
}
This work beautifully for me when I run it from a server console:
perl sys:resetpw2.pl user.cont.cont.org
I decided to add a user that can only change passwords and hard
code that in the script so i didn't have to authenticate each time
I run the script. I give Guenter all credit for this script.
Without your initial work I would not have been able to get
anywhere.
Thanks
Brad B.