Prev: Event Handling
Next: Using Mono library from PHP
From: "Ashley M. Kirchner" on 15 Mar 2010 04:54 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 = @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 @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?
From: Peter Lind on 15 Mar 2010 05:12 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(a)pcraft.com> wrote: > 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 = @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 @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? > > -- <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>
From: chamila gayan on 15 Mar 2010 05:58 if you sure you have valid credentials check your account and sure it hasn't locked, perhaps it may locked. On Mon, Mar 15, 2010 at 2:42 PM, Peter Lind <peter.e.lind(a)gmail.com> wrote: > 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(a)pcraft.com> wrote: > > 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 = @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 @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? > > > > > > > > -- > <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 > >
From: "Ashley M. Kirchner" on 15 Mar 2010 14:37 > -----Original Message----- > From: Peter Lind [mailto:peter.e.lind(a)gmail.com] > Sent: Monday, March 15, 2010 3:13 AM > To: Ashley M. Kirchner > Cc: php-general(a)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
|
Pages: 1 Prev: Event Handling Next: Using Mono library from PHP |