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

Re: Crypt problem



On  4 Jun, Benoit LEROYER wrote:
> - I've create some entries in my ldap directory like
> 
> dn: cn=LEROYER Benoit, o=mydomain, c=com
> cn: LEROYER Benoit
> mail: benoit@gide.net
> telephonenumber: 0404040404
> userpassword: {crypt}hXftnFjtDk4Y2      --> encrypted password ( example 
> : Mypasswd )
> 
> objectclass: person
> 
> 
> - I would like to use with PHP page like
> 
> <?
> $server = "ldap://benzecri"; ;
> $racine = "o=gide, c=net" ;
> $rootdn = "cn=ldap_admin, o=gide, c=net" ;
> $rootpw = secret;
> 
> $ds=ldap_connect($server);
> if($ds==1)
>   {
>    $r=ldap_bind($ds,$rootdn,$rootpw);
> 
>    $dn = "cn=LEROYER benoit, o=gide, c=net";
> 
>    $value = ;  <-- ( I don't know what i have to put here , crypt 
> password, plain text password ...? )
> 
>    $attr = "userPassword";
> 
>    $result=ldap_compare($ds, $dn, $attr, $value);
>    if ($result === -1) {
>        echo "Error:".ldap_error($ds)."<br/>";
>    }
>    elseif ($result === TRUE) {
>        echo "ok password <br/>";
>    }
>    else  {
>        echo "wrong password <br/>";
>    }
>    ldap_close($ds);
>   }
>   else {
>    echo "Impossible de se connecter au serveur LDAP";
>   }
> ?>
> 
> 
> 
> 
> Which syntax for $value = ?
> 
> 
> Thanks
> 
> 
Why don't you just try to bind to the directory as the specified user?
You need to specify the plaintext password. If the bind is succesfull,
the password was correct. If not, they mismatch.

This also does not require any rootpw to perform the check.

HTH,

Marcel
-- 
---------------------------------------------------------------
ing. Marcel van Dorp (CCDP, CCNP+security)   http://www.wiwo.nl
WiWo Support                                 tel. 071-523 77 91
Postbus 1098                                 fax  071-523 77 94
2340 BB Oegstgeest                           gsm  0653-50 77 76
---------------------------------------------------------------