Lpasswd.pl
From In The Wings
This changes the password for an LDAP user. More could be done with it to set it to something random, but this does well for now.
#!/usr/bin/perl
#
use Net::LDAP;
use Net::LDAP::Util;
$userName = $ARGV[0];
$newPassword = $ARGV[1];
print "Updating " . $userName . "\n";
$ldapServer = "ldap.ufhpc";
$rdn = "cn=slapman";
$base = "dc=hpc,dc=ufl,dc=edu";
$bindPasswd = '';
$searchBase = "ou=People," . $base;
$dn = "uid=" . $userName . "," . $searchBase;
$BindDn = $rdn . "," . $base;
$ldap = Net::LDAP->new( $ldapServer );
$bindDc = $rdn . "," . $base;
$mesg = $ldap->bind( $BindDn, password => $bindPasswd, version => 3);
if ( $mesg->is_error() ) {
print "Error: bind failed.\n";
exit;
}
$shadowLastChange = int(time / 86400);
$shadowExpire = $shadowLastChange + 180;
$result = $ldap->modify($dn, replace => { "userPassword" => $newPassword,
"shadowLastChange" => $shadowLastChange
});
