Re: ldap_bind() connectivity

From: Date: Mon, 15 Mar 2010 09:12:52 +0000
Subject: Re: ldap_bind() connectivity
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-302836@lists.php.net to get a copy of this message
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@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, "&laquo; Invalid username or password > &raquo;"); > >      } > >      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>

« previous php.general (#302836) next »