hash mot de passe ldap fonctionnel.
This commit is contained in:
12
password.pl
12
password.pl
@@ -1,17 +1,18 @@
|
||||
#/usr/bin/perl
|
||||
#
|
||||
# This script will look for any ldap object of type person, with attribute
|
||||
# userPassword set, check wether it's already been hashed and hash it if not
|
||||
|
||||
# Script to crypt all password in ldap
|
||||
use strict;
|
||||
use Net::LDAP;
|
||||
|
||||
my $ldapserver = "localhost";
|
||||
my $binddn = "cn=manager,o=od";
|
||||
my $bindpw = "123Soleil" ;
|
||||
my $base = 'ou=peopleEnt,o=od' ;
|
||||
|
||||
my $ldap = Net::LDAP->new( $ldapserver ) or die "$@" ;
|
||||
|
||||
my $base = 'ou=test,o=od' ;
|
||||
|
||||
my $mesg = $ldap->bind( $binddn,
|
||||
password => $bindpw
|
||||
);
|
||||
@@ -29,9 +30,8 @@ if( $mesg-> count() == 0 ) { exit(0) ; }
|
||||
foreach my $entry ( $mesg-> entries ){
|
||||
my $userPassword = $entry->get_value('userPassword') ;
|
||||
my $sshaPassword = `slappasswd -n -s $userPassword` ;
|
||||
print $userPassword."\t".$sshaPassword."\n" ;
|
||||
if( ($userPassword cmp $sshaPassword)==0 ) {
|
||||
print $entry->dn() . "alteady crypted\n" ;
|
||||
if( $userPassword =~ /^{SSHA/ ) {
|
||||
print $entry->dn() . " already hashed\n" ;
|
||||
next ; }
|
||||
$entry -> replace (
|
||||
userPassword => $sshaPassword,
|
||||
|
||||
Reference in New Issue
Block a user