ldap_bind() connectivity

------=_NextPart_000_04B5_01CAC3EA.E1380930
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

Thanks to Jochem Mass for helping earlier to the string splitting. Works
great (so far). Now on to my next problem, which has to do with
ldap_bind().



I have the following code:



$ldapconn = [at] ldap_connect($adServer);

$ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappass);



if ($ldapbind) {

/** Successful authentication **/

$_SESSION['username'] = $username;

$_SESSION['password'] = $password;

} else {

/** Authentication failure **/

$form->setError($field, "« Invalid username or password
»");

}

ldap_unbind($ldapconn);



The problem with this is that if the ldap_bind() fails in the second line,
it instantly spits text out to the browser:



Warning: ldap_bind() [function.ldap-bind
<http://www.smartroute.org/contest/include/function.ldap-bind> ]: Unable to
bind to server: Invalid credentials in /home/contest/include/session.php on
line 351



And because it does that, it never reaches the if routine right below it and
everything just bombs. If I call it with [at] ldap_bind($ldapconn .) nothing
happens. The error message gets suppressed but it also doesn't do anything
with the if routine afterwards. It's almost like $ldapbind isn't getting
set at all.



What am I missing here?


------=_NextPart_000_04B5_01CAC3EA.E1380930--
Ashley [ Mo, 15 März 2010 09:54 ] [ ID #2035140 ]

Re: ldap_bind() connectivity

You might want to check what the function outputs with:

var_dump($ldapbind);

after the call to ldap_bing(). That way you'll know what actually got
returned from the function.

On 15 March 2010 09:54, Ashley M. Kirchner <ashley [at] pcraft.com> wrote:
> Thanks to Jochem Mass for helping earlier to the string splitting. =C2=A0=
Works
> great (so far). =C2=A0Now on to my next problem, which has to do with
> ldap_bind().
>
>
>
> I have the following code:
>
>
>
> =C2=A0 =C2=A0 =C2=A0$ldapconn =3D [at] ldap_connect($adServer);
>
> =C2=A0 =C2=A0 =C2=A0$ldapbind =3D ldap_bind($ldapconn, $ldapuser, $ldappa=
ss);
>
>
>
> =C2=A0 =C2=A0 =C2=A0if ($ldapbind) {
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0/** Successful authentication **/
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0$_SESSION['username'] =3D $username;
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0$_SESSION['password'] =3D $password;
>
> =C2=A0 =C2=A0 =C2=A0} else {
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0/** Authentication failure **/
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0$form->setError($field, "« Invalid usern=
ame or password
> »");
>
> =C2=A0 =C2=A0 =C2=A0}
>
> =C2=A0 =C2=A0 =C2=A0ldap_unbind($ldapconn);
>
>
>
> The problem with this is that if the ldap_bind() fails in the second line=
,
> it instantly spits text out to the browser:
>
>
>
> Warning: ldap_bind() [function.ldap-bind
> <http://www.smartroute.org/contest/include/function.ldap-bind> ]: Unable =
to
> bind to server: Invalid credentials in /home/contest/include/session.php =
on
> line 351
>
>
>
> And because it does that, it never reaches the if routine right below it =
and
> everything just bombs. =C2=A0If I call it with [at] ldap_bind($ldapconn .) no=
thing
> happens. =C2=A0The error message gets suppressed but it also doesn't do a=
nything
> with the if routine afterwards. =C2=A0It's almost like $ldapbind isn't ge=
tting
> set at all.
>
>
>
> What am I missing here?
>
>



--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Peter Lind [ Mo, 15 März 2010 10:12 ] [ ID #2035144 ]

RE: ldap_bind() connectivity

> -----Original Message-----
> From: Peter Lind [mailto:peter.e.lind [at] gmail.com]
> Sent: Monday, March 15, 2010 3:13 AM
> To: Ashley M. Kirchner
> Cc: php-general [at] lists.php.net
> Subject: Re: [PHP] ldap_bind() connectivity
>
> You might want to check what the function outputs with:
>
> var_dump($ldapbind);
>
> after the call to ldap_bing(). That way you'll know what actually got
> returned from the function.


SOLVED. As it turned out, it had nothing to do with ldap_bind() ... it =
had to do with the fact that my brain is still adjusting from the time =
change and I missed an 'echo' ...

Thanks all.

A


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ashley [ Mo, 15 März 2010 19:37 ] [ ID #2035168 ]
PHP » gmane.comp.php.general » ldap_bind() connectivity

Vorheriges Thema: how to get the local time
Nächstes Thema: mysqli procedural calls and manual entries ?