2
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/rename.php,v 1.33.2.1 2007/12/26 09:26:32 wurley Exp $
2
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/rename.php,v 1.33.2.3 2008/12/12 12:20:22 wurley Exp $
5
5
* Renames a DN to a different name.
18
18
require './common.php';
20
20
if ($ldapserver->isReadOnly())
21
pla_error(_('You cannot perform updates while server is in read-only mode'));
21
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
23
23
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_rename'))
24
pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('rename entry')));
24
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('rename entry')),'error','index.php');
26
$dn = get_request('dn');
27
27
if (! $ldapserver->isBranchRenameEnabled()) {
28
28
# we search all children, not only the visible children in the tree
29
29
$children = $ldapserver->getContainerContents($dn);
30
30
if (count($children) > 0)
31
pla_error(_('You cannot rename an entry which has children entries (eg, the rename operation is not allowed on non-leaf entries)'));
31
error(_('You cannot rename an entry which has children entries (eg, the rename operation is not allowed on non-leaf entries)'),'error','index.php');
34
$new_rdn = ($_POST['new_rdn']);
34
$new_rdn = get_request('new_rdn');
35
35
$container = get_container($dn);
36
36
$new_dn = sprintf('%s,%s',$new_rdn,$container);
38
38
if ($new_dn == $dn)
39
pla_error(_('You did not change the RDN'));
39
error(_('You did not change the RDN'),'error','index.php');
41
41
$old_dn_attr = explode('=',$dn);
42
42
$old_dn_attr = $old_dn_attr[0];
44
44
$new_dn_value = explode('=',$new_rdn,2);
46
46
if (count($new_dn_value) != 2 || ! isset($new_dn_value[1]))
47
pla_error(_('Invalid RDN value'));
47
error(_('Invalid RDN value'),'error','index.php');
49
49
$new_dn_attr = $new_dn_value[0];
50
50
$new_dn_value = $new_dn_value[1];
58
58
$success = $ldapserver->rename($dn,$new_rdn,$container,$deleteoldrdn);
61
pla_error(_('Could not rename the entry') );
61
error(_('Could not rename the entry'),'error','index.php');