NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP/LDAP

Hans Zaunere zaunere at yahoo.com
Wed Aug 28 15:03:28 EDT 2002


--- Tim Sailer <sailer at bnl.gov> wrote:
> On Wed, Aug 28, 2002 at 02:10:17PM -0400, Hans Zaunere wrote:
> > 
> > --- Tim Sailer <sailer at bnl.gov> wrote: 
> > > I need some guidance from the LDAP gurus, I think.  I've long
> been
> > > able to get PHP to read from LDAP, but now I have the need to
> write,
> > > and I'm running up against a strange problem.
> > 
> > I've been lucky enough to only have to read from LDAP myself, but I
> did
> > run into the fact that the LDAP functions can be picky about what
> is
> > pased to them; ie, references, arrays, etc.  The code certainly
> looks
> > reasonable, however, I noticed a stray #, although I'm probably
> just
> > nit-picking.
> 
> Huh. I found out how to make it work, but I'm not sure why this
> kludge... I ran up etheral, and sniffed the packets, since it knows
> LDAP packets. In the modify request, the DN was blank! So, poking
> around
> some more, I got the bright idea to go from:
> 
> $dn=$info["dn"];
> 
> to
> 
> $dn=$info[0]["dn"];
> 

I run into these types of things all the time, and find print_r() or
var_dump() invaluable to assure I know what I'm actually working with. 
Sometimes they don't fit just right, however, so I wrote a little
wrapper which will save some of the output buffering bothers and
optionaly put it to a log file instead of the browser.  I've included
it below.

H


function trigger_dump( $mixed,$error = 1 ) {
   if( $error === 0 ) {
      echo '<pre>';
      print_r($mixed);
      echo '</pre>';
   } else {
      ob_start();
      print_r($mixed);
      trigger_error(ob_get_contents());
      ob_end_clean();
   }
}



__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com



More information about the talk mailing list