Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ldap_bind problem on authentication

Status
Not open for further replies.

Exode

Programmer
Feb 17, 2004
14
CA
Hi all,

I've run in a little problem this morning and wasn't able to find the answer so far, so I hope you guys can help me.

I'm trying to do a ldap_bind then test the value of the bind to make the authentication, but the the bind always return nothing (isn't it supposed to return true or false ?)
My dn and pass are ok, the connection works so I really don't know what I'm doing wrong. Here's my code:

$conLDAP = ldap_connect($ldap_var[db][host], $ldap_var[db][port])
$dn = $sArrayRechLdap[0][7];
$bindLDAP = @ldap_bind($conLDAP, $dn, $mdp);

if ($bindLDAP)
{
$sArrayLDAP = array(trim($sArrayRechLdap[0][0]),
trim($sArrayRechLdap[0][1]),
trim($sArrayRechLdap[0][2]),
trim($sArrayRechLdap[0][3]),
trim($sArrayRechLdap[0][4]),
trim($sArrayRechLdap[0][5]),
trim($sArrayRechLdap[0][6]));
$bGoodLogin = 1;
}

the $dn returns uid=atfrank,ou=Employee,ou=Person,dc=csaff,dc=qc,dc=ca
and the $mdp returns the correct password. However, the it never goes through the If because the $BindLDAP is always nothing.

Hope someone can help me out with this.Thanks for your time and help.
Frank
 
Hi there,
I'm not sure if you copy/pasted your code, but you're missing a semi-colon at the end of your first line:
$conLDAP = ldap_connect($ldap_var[db][host], $ldap_var[db][port]);

why don't you separate your code a bit, so you can isolate the point of failure?

Try:

Code:
if (!($conLDAP = ldap_connect($ldap_var[db][host],$ldap_var[db][port]))) { 
  die ("Could not connect to LDAP server");
}

if (!($bindLDAP = @ldap_bind($ldap, $dn, $mdp))) {
	  die ("Invalid username or password: Please try again");
}

I realize this may not solve your problem, but may assist in isolating where the problem occurs.


[cheers]
Cheers!
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top