[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Changing password from Perl



The script below shows how the crypt function in perl works.  Excuse the
crudness, I'm fairly new to perl and newer to ldap.  I used a few lines from
it to generate {crypt} passwords from clear text and write an ldif file.  Is
there a better, more direct way to modify ldap from perl or through ldap
url's.

    print OUTF "dn: uid=$uid,o=my.com,c=US\n";
    print OUTFG "member: uid=$uid,o=my.com,c=US\n";
    print OUTF "objectclass: newPilotPerson\n";
    print OUTF "uid: $uid\n";
    print OUTF "cn: $gv $sn\n";
    print OUTF "sn: $sn\n";
    $salt=substr(rand 100,0,2);
    $pw=crypt($pwin,$salt);
    print OUTF "userpassword: {crypt}$pw\n";
    print OUTF "\n";





#!/usr/local/bin/perl
#
# Todd Wiersema 4/10/99
#
print "password:";
system ("stty -echo");
$cleartext= <STDIN>;
system ("stty echo");
chop ($cleartext);
srand (time());
$salt=substr(rand 100,0,2);
#
# The clear password is crypted with a 2 character $salt
# The result is a crypted string.
#
$crypttext=crypt($cleartext,$salt);
print "\n\n";
print "salt: $salt\n\n";
print "cleartext= $cleartext\n\n";
print "crypted string = $crypttext\n\n";
# first 2 characters of $et are the random generated $salt
# a guess crypted with $et will yield a match if they are the same
print "guess:";
system ("stty -echo");
$guess= <STDIN>;
system ("stty echo");
chop ($guess);
#
# The first 2 characters of $crypttext are the random generated $salt
# a guess crypted with $crypttext will yield a match if it is the same
# as the original password
#
$n=crypt($guess,$crypttext);
print "\n\n";
print "guess cleartext= $guess\n\n";
print "crypted guess= $n\n\n";
if ( $n eq $crypttext ) {
  print "Guess matched!\n\n";
} else {
  print "Guess failed!\n\n";
}



	> From: 	Borek Lupomesky[SMTP:Borek.Lupomesky@ujep.cz]
	> perl? Crypt would suffice, md5 would be better.