note 37457 added to function.ldap-rename

From: Date: Sat, 15 Nov 2003 23:37:11 +0000
Subject: note 37457 added to function.ldap-rename
Groups: php.notes 
Request: Send a blank email to php-notes+get-60441@lists.php.net to get a copy of this message
ldap_rename can only move leaf nodes of the directory tree. If your ldap entry has any child entries, then ldap_rename is not the tool that you need. We needed to change usernames, but that alters the dn. ldap_rename wouldn't work because each of our user ldap entries has a couple associated child entries. We had to write a function to recursively copy the subtree to the new location, and then delete the original version. Here is the basic algorithm: function recursive_move($old_username, $new_username) ldap_search on the old username to get the correct entry ldap_get_attributes to get an array of values from the ldap entry foreach attribute in array, replace occurences of $old_username with $new_username ldap_add the attribute array into the new location ldap_modify any additional attributes ldap_list each child entry call function recursive_move on each child ldap_delete current entry return ---- Manual Page -- http://www.php.net/manual/en/function.ldap-rename.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37457 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37457&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37457&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60441) next »