NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP/LDAP

Hans Zaunere zaunere at yahoo.com
Wed Aug 28 14:10:13 EDT 2002


--- 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.

Sorry I couldn't be more help, though.

H



> 
> Basic code is as follows:
> 
> ----
> <?
> $ds=ldap_connect("ldapmachine.bnl.gov");
> 
> if (!$ds)
> {
>   echo "No connect! Result was ".$ds;
>   exit;
> }
> 
> #non-anon bind, since we have to update stuff.
> 
> $nab=ldap_bind($ds,"cn=admin,dc=bnl,dc=gov","password");
> if (!$nab)
> {
>   echo "Bind failed! Exiting...";
>   exit;
> }
> 
> $searchstring="(uid=".$uid.")";
> $sr=ldap_search($ds,"dc=bnl,dc=gov","$searchstring");
> 
> echo "Search String: <b>$searchstring</b><br>";
> 
> $info=ldap_get_entries($ds,$sr);
> $dn=$info["dn"];
> 
> echo $dn;
> 
> #$info1["objectClass"]="inetLocalMailRecipient";
> 
> 
> 
> $bla=ldap_mod_add($ds,"$dn",$info1);
> 
> ldap_close($ds);
> ----
> 
> Now, this is just test code, but it should work. $uid gets
> passed from a form, and I just want to add an objectClass,
> and 2 attributes. What I get is this from PHP:
> 
> Warning: LDAP: modify operation could not be completed. in
> /var/www/ldap/mklabmail.php on line 33
> 
> 
> And this from LDAP:
> 
> Aug 28 08:47:58 ldapmachine slapd[243]: conn=84871 op=0 BIND
> dn="CN=ADMIN,DC=BNL,DC=GOV" method=128 
> Aug 28 08:47:58 ldapmachine slapd[243]: conn=84871 op=0 RESULT tag=97
> err=0 text= 
> Aug 28 08:47:58 ldapmachine slapd[245]: conn=84871 op=1 SRCH
> base="dc=bnl,dc=gov" scope=2 filter="(uid=krl2)" 
> Aug 28 08:47:58 ldapmachine slapd[245]: conn=84871 op=1 SEARCH RESULT
> tag=101 err=0 text= 
> Aug 28 08:47:58 ldapmachine slapd[344]: do_modify: root dse! 
> Aug 28 08:47:58 ldapmachine slapd[344]: conn=84871 op=2 RESULT
> tag=103 err=53 text=modify upon the root DSE not supported 
> Aug 28 08:47:58 ldapmachine slapd[345]: conn=84871 op=3 UNBIND 
> Aug 28 08:47:58 ldapmachine slapd[345]: conn=-1 fd=15 closed 
> 
> I'm *not trying* to change the root dse! What am I stupidly doing
> wrong?
> 
> Tim
> 
> -- 
> Tim Sailer <sailer at bnl.gov> 
> Application Services
> Information Technology Division
> Brookhaven National Laboratory  (631) 344-3001
> 


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



More information about the talk mailing list