Simple ldap_modify problem?
| From: | Brian | Date: | Thu, 17 Apr 2003 15:05:22 +0000 |
| Subject: | Simple ldap_modify problem? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-144297@lists.php.net to get a copy of this message | ||
I hope someone can help me.
Recently, I ran across an article at DevShed that gives examples of how
to write simple LDAP scripts to add, delete, and modify LDAP entries ...
http://www.devshed.com/Server_Side/PHP/PHPwithLDAP/PHPwithLDAP2/page1.html
The scripts work great for me, except the ldap_modify function. If I
add a user through the scripts, I can modify the entry's cn and sn
values as much as I like, but I can only edit the email address only
once before it no longer allows me to edit it (error no. 32: No such
object).
The index.php establishes a connection and then allows the results to be
passed to edit.php like so:
echo "<td><a href=\"edit.php?mail=" .
urlencode($info[$i]["mail"][0]) .
"\">Edit</a></td>";
edit.php takes those values and POST's them to modify.php:
// prepare data
$info["cn"] = $_POST['cn'];
$info["sn"] = $_POST['sn'];
$info["mail"] = $_POST['mail'];
$info["objectClass"] = "inetOrgPerson";
// prepare DN
$dn = "mail=" . $_POST['mail'] . ", dc=fictional, dc=net";
// modify data in the directory
$result = ldap_modify($conn, $dn, $info);
As I said, this works if you edit the user's email address once. Beyond
that, it fails.
I figured that the problem was the email address that gets sent from
index.php is not the same value at the end (modify.php) which identifies
the entry to change, so using session_start() in edit.php, I made a
variable called $_SESSION['orig.mail'] = $_GET['mail'] (brought in from
that urlencode in index.php) that carried over into modify.php that made
the above line read:
// prepare DN
$dn = "mail=" . $_SESSION['orig.mail'] . ", dc=fictional, dc=net";
Still, no dice. I can echo the contents of the variables and see that
every value is how it is supposed to be, yet something isn't getting
passed properly.
I started up slapd with '-d 255' and logged the results of the
successful ldap_modify and the unsuccessful ldap_modify. They are at:
http://www2.netdoor.com/~brianb/ldap/ldap_modify.works
and
http://www2.netdoor.com/~brianb/ldap/ldap_modify.fails
Any advice would be greatly appreciated.
Brian
--
Brian