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

RE: Crypt problem



> -----Original Message-----
> From: owner-openldap-software@OpenLDAP.org
> [mailto:owner-openldap-software@OpenLDAP.org]On Behalf Of Benoit LEROYER
 
> - 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

Don't do this. This is not a good use for ldap_compare.
> 
> <?
> $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)
>   {

Instead of this...
>    $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);

Do this, with the plain text password in $value:
     $result=ldap_bind($ds, $dn, $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";
>   }
> ?>

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support