ldap_mod_del and php 4.0.2

From: Date: Mon, 23 Oct 2000 09:39:42 +0000
Subject: ldap_mod_del and php 4.0.2
Groups: php.general 
Request: Send a blank email to php-general+get-21753@lists.php.net to get a copy of this message
I have some problems with the LDAP functions in PHP. The manual says int ldap_mod_del (int link_identifier, string dn, array entry) I'm trying to remove the jpegPhoto attribute from an entry in the LDAP database. I haven't succeeded with this yet, because php seg faults. I've tried to set entry to: $ent = "jpegPhoto"; -- $ent[0] = "jpegPhoto"; -- $ent["count"] = 1; $ent[0] = "jpegPhoto"; -- I know that the two first args are ok and that i have write access to this entry (ldapmodify(1) works fine!). Is this maybe a bug in PHP? The second problem is that ldap_first_entry(), ldap_first_attribute() doesn't return something (i.e. false) when i've done a ldap_search(). Even though i know ldap_count_entries($lsock, $search_result) is greater than zero. The code i've been using is something like ldap_connect() ldap_bind() ldap_search() ldap_first_entry)() ldap_first_attribute() ldap_next_attribute() ldap_next_attribute() ldap_unbind() Of course, i've checked for errors. Right after ldap_first_entry() ldap_error() says "Success". PHP prints out "Warning: 0 is not a LDAP result entry index in /usr/local/apache/htdocs/dev/badlib.php on line 40" during my calls to various stuff in for loops. The code is as follows. <snip> $lsock = ldap_connect($server); if(!$lsock) { exit; } $ret = ldap_bind($lsock, "cn=". $bindrdn .",". $basedn, $bindpw); if(!$ret) { ldap_bind($lsock, NULL, NULL); } $sr = ldap_search($lsock, $basedn, $filter); echo "Res: $sr<br>\n"; for($e = ldap_first_entry($lsock, $sr); $e; $e = ldap_next_entry($lsock, $e)); { echo "Entry: $e<br>\n"; echo "Error: ". ldap_error($lsock) ."<br>\n"; for($attr = ldap_first_attribute($lsock, $e, &$ber), $i = 0; $i < 5; /* temp.. */ $attr = ldap_next_attribute($lsock, $e, &$ber), $i++) { echo "Error: ". ldap_error($lsock) ."<br>\n"; $val = ldap_get_values($lsock, $e, $attr); if(!$val) echo "no val!<br>\n"; echo "attr:$attr val:". $val[0] ."count:". $val["count"] ."<br>\n"; } } </snip> What's wrong? I'd appreciate all help i can get. Thanks in advance.

« previous php.general (#21753) next »