Instance($server_id_src);
$ldapserver_dst = $ldapservers->Instance($server_id_dst);
if ($ldapserver_dst->isReadOnly())
pla_error($lang['copy_server_read_only']);
if (! $ldapserver_src->haveAuthInfo() || ! $ldapserver_dst->haveAuthInfo())
pla_error($lang['not_enough_login_info']);
$dn_src = $_POST['old_dn'];
$dn_dst = $_POST['new_dn'];
$do_recursive = (isset($_POST['recursive']) && $_POST['recursive'] == 'on') ? true : false;
$do_remove = (isset($_POST['remove']) && $_POST['remove'] == 'yes') ? true : false;
$encoded_dn = rawurlencode($dn_src);
include './header.php';
# Error checking
if (0 == strlen(trim($dn_dst)))
pla_error($lang['copy_dest_dn_blank']);
if (pla_compare_dns($dn_src,$dn_dst) == 0 && $server_id_src == $server_id_dst)
pla_error($lang['copy_source_dest_dn_same']);
if (dn_exists($ldapserver_dst,$dn_dst))
pla_error(sprintf($lang['copy_dest_already_exists'],pretty_print_dn($dn_dst)));
if (! dn_exists($ldapserver_dst,get_container($dn_dst)))
pla_error(sprintf($lang['copy_dest_container_does_not_exist'],pretty_print_dn(get_container($dn_dst))));
if ($do_recursive) {
$filter = isset($_POST['filter']) ? $_POST['filter'] : '(objectClass=*)';
# Build a tree similar to that of the tree browser to give to r_copy_dn
$snapshot_tree = array();
print '
';
printf('%s%s
',$lang['copy_copying'],htmlspecialchars($dn_src));
printf('%s
',$lang['copy_recursive_copy_progress']);
print '
';
print '';
print $lang['copy_building_snapshot'];
flush();
$snapshot_tree = build_tree($ldapserver_src,$dn_src,array(),$filter);
printf('%s
',$lang['success']);
flush();
# Prevent script from bailing early on a long delete
@set_time_limit(0);
$copy_result = r_copy_dn($ldapserver_src,$ldapserver_dst,$snapshot_tree,$dn_src,$dn_dst);
print '';
} else {
$copy_result = copy_dn($ldapserver_src,$ldapserver_dst,$dn_src,$dn_dst);
}
if ($copy_result) {
$edit_url = sprintf('edit.php?server_id=%s&dn=%s',$server_id_dst,rawurlencode($dn_dst));
$new_rdn = get_rdn($dn_dst);
$container = get_container($dn_dst);
if (array_key_exists('tree',$_SESSION)) {
# do we not have a tree and tree icons yet? Build a new ones.
initialize_session_tree();
$tree = $_SESSION['tree'];
$tree_icons = $_SESSION['tree_icons'];
if (isset($tree[$server_id_dst][$container])) {
$tree[$server_id_dst][$container][] = $dn_dst;
sort($tree[$server_id_dst][$container]);
$tree_icons[$server_id_dst][$dn_dst] = get_icon($ldapserver_dst,$dn_dst);
$_SESSION['tree'] = $tree;
$_SESSION['tree_icons'] = $tree_icons;
session_write_close();
}
}
?>
%s',$lang['copy_successful_like_to'],$edit_url,$lang['copy_view_new_entry']) ?>