X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=login.cgi;h=60358a686228270d4abdfa181cfce1576447c25f;hb=b62107bcdbc4fb5311f981999d838de38243e46f;hp=c1615e343e873c319422468e27194c1c54b12cfb;hpb=03b5d4275693c3f5a701b9e22e04af8ef57d0a58;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/login.cgi b/login.cgi index c1615e3..60358a6 100755 --- a/login.cgi +++ b/login.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: login.cgi,v 1.2 1999/09/26 01:20:39 tausq Exp $ +# $Id: login.cgi,v 1.6 2000/05/06 06:10:05 tausq Exp $ # (c) 1999 Randolph Chung. Licensed under the GPL. use lib '.'; @@ -36,14 +36,34 @@ my $mesg = $ldap->bind($binddn, password => $password); $mesg->sync; if ($mesg->code == LDAP_SUCCESS) { + # HACK HACK HACK + # Check for md5 password, and update as necessary + $mesg = $ldap->search(base => $config{basedn}, + filter => "(uid=$username)"); + $mesg->code && &Util::HTMLError($mesg->error); + my $entries = $mesg->as_struct; + my $dn = (keys %$entries)[0]; + my $oldpassword = $entries->{$dn}->{userpassword}->[0]; + if ($oldpassword !~ /^{crypt}\$1\$/) { + # Update their password to md5 + open (LOG, ">$config{weblogfile}"); + print LOG scalar(localtime); + print LOG ": Updating MD5 password for $dn\n"; + close LOG; + my $newpassword = '{crypt}'.crypt($password, &Util::CreateCryptSalt(1)); + &Util::LDAPUpdate($ldap, $dn, 'userPassword', $newpassword); + } + ## END HACK HACK HACK + my $cryptid = &Util::SavePasswordToFile($username, $password, $cipher); if ($query->param('update')) { - my $url = "$proto://$ENV{SERVER_NAME}/$config{webupdateurl}?id=$username&authtoken=$cryptid:$hrkey&editdn="; + my $url = "$proto://$ENV{SERVER_NAME}/$config{webupdateurl}?id=$username&authtoken=$cryptid,$hrkey&editdn="; $url .= uri_escape("uid=$username,$config{basedn}", "\x00-\x40\x7f-\xff"); print "Location: $url\n\n"; } else { - print "Location: $proto://$ENV{SERVER_NAME}/$config{websearchurl}?id=$username&authtoken=$cryptid:$hrkey\n\n"; + my $url = "$proto://$ENV{SERVER_NAME}/$config{websearchurl}?id=$username&authtoken=$cryptid,$hrkey"; + print "Location: $url\n\n"; } $ldap->unbind; @@ -51,3 +71,4 @@ if ($mesg->code == LDAP_SUCCESS) { print "Content-type: text/html\n\n"; print "

Not authenticated

\n"; } +