A kind of perl script that i use to change the user password from an sql database, but It's easy with perl to parse a csv file.<br><br>use Net::LDAP;<br>use DBI();<br>use Encode;<br>use MIME::Base64;<br>use SHA;<br><br>
<br>my $dbh = DBI->connect("DBI:mysql:database=user;host=localhost","admin", "password",{RaiseError => 1});<br><br> $ldup = Net::LDAP->new( '<a href="http://ldap.server.com">ldap.server.com
</a>' ) or die "$@";<br> $masg = $ldup->bind ; # an anonymous bind<br> $masg = $ldup->search( # perform a search<br> base => "ou=People,dc=test,dc=com",
<br> scope => 'sub',<br> filter => "(uid=*)",<br> attrs => ['uid']
<br> );<br><br> $masg->code && die $masg->error;<br><br> foreach $entry ($masg->entries)<br> {<br> $uid="NULL";<br> $dn=$entry->dn();
<br> foreach $attr ($entry->attributes)<br> {<br> if($attr eq uid)<br> {<br> $uid=$entry->get_value($attr);<br> # print "\n".$uid;
<br> }<br> }<br> $az=$dbh->prepare("select * from passwd where nom = \"$uid\" ORDER BY stamptime DESC");<br> $az->execute;<br> $passwd = $az->fetchrow_hashref;
<br> if ($passwd->{passwd}) {<br> $sha = new SHA;<br> $salt = (shift, pack ("H*", shift));<br> $label = "{SSHA}";
<br> $hash = $sha->hash ($passwd->{passwd} . $salt);<br> $hashpass = $label. encode_base64 ($hash . $salt, "");<br> $ldop = Net::LDAP->new( '
<a href="http://ldap.server.com">ldap.server.com</a>' );<br> $misg = $ldop->bind( 'cn=directory manager',password => 'password');<br> $misg = $ldop->modify( $dn, delete => [userPassword] );
<br> $misg = $ldop->modify( $dn, add => { userPassword => $hashpass } );<br> undef $hashpass;<br> $misg->code && warn "failed to add entry: ", $misg->error ;
<br> $misg = $ldop->unbind;<br> print $uid.":".$passwd->{passwd}."\n";<br> }<br> }<br><br>$mesg = $ldup->unbind; # take down session
<br><br>Fabrice<br><br><div><span class="gmail_quote">2007/12/4, Glenn <<a href="mailto:glenn@mail.txwes.edu">glenn@mail.txwes.edu</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Howdy, Guys - I need a shell script that will read a file of user IDs and<br>passwords and enter the passwords into Fedora Directory. The users are<br>already in FD; we just need to change all their passwords at once. The file
<br>will be formatted so the user ID is in column one and the password is in<br>column two. We have about 8,000 users. Any help appreciated. Thanks. -<br>Glenn.<br><br>--<br>Fedora-directory-users mailing list<br><a href="mailto:Fedora-directory-users@redhat.com">
Fedora-directory-users@redhat.com</a><br><a href="https://www.redhat.com/mailman/listinfo/fedora-directory-users">https://www.redhat.com/mailman/listinfo/fedora-directory-users</a><br></blockquote></div><br>