\n"; echo "

". $lang['copy_copying'] . htmlspecialchars( $source_dn ) . "

\n"; echo "

" . $lang['copy_recursive_copy_progress'] ."

\n"; echo "

"; echo "\n"; echo $lang['copy_building_snapshot']; flush(); build_tree( $source_server_id, $source_dn, $snapshot_tree, $filter ); echo " " . $lang['success'] . "
\n"; flush(); // prevent script from bailing early on a long delete @set_time_limit( 0 ); $copy_result = r_copy_dn( $source_server_id, $dest_server_id, $snapshot_tree, $source_dn, $dest_dn ); echo "
\n"; } else { $copy_result = copy_dn( $source_server_id, $source_dn, $dest_server_id, $dest_dn ); } if( $copy_result ) { $edit_url="edit.php?server_id=$dest_server_id&dn=" . rawurlencode( $dest_dn ); $new_rdn = get_rdn( $dest_dn ); $container = get_container( $dest_dn ); 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[$dest_server_id][$container] ) ) { $tree[$dest_server_id][$container][] = $dest_dn; sort( $tree[ $dest_server_id ][ $container ] ); $tree_icons[$dest_server_id][$dest_dn] = get_icon( $dest_server_id, $dest_dn ); $_SESSION['tree'] = $tree; $_SESSION['tree_icons'] = $tree_icons; session_write_close(); } } ?>
" . $lang['copy_view_new_entry'] .""?>




". $lang['copy_copying'] . htmlspecialchars( $root_dn ) . "..."; flush(); $copy_result = copy_dn( $source_server_id, $root_dn, $dest_server_id, $dest_dn ); if( ! $copy_result ) { return false; } echo "".$lang['success']."
\n"; flush(); $children = isset( $tree[ $root_dn ] ) ? $tree[ $root_dn ] : null; if( is_array( $children ) && count( $children ) > 0 ) { foreach( $children as $child_dn ) { $child_rdn = get_rdn( $child_dn ); $new_dest_dn = $child_rdn . ',' . $dest_dn; r_copy_dn( $source_server_id, $dest_server_id, $tree, $child_dn, $new_dest_dn ); } } else { return true; } return true; } function copy_dn( $source_server_id, $source_dn, $dest_server_id, $dest_dn ) { global $ds, $lang; $ds = pla_ldap_connect( $dest_server_id ); pla_ldap_connection_is_error( $ds ); $attrs = get_object_attrs( $source_server_id, $source_dn ); $new_entry = $attrs; // modify the prefix-value (ie "bob" in cn=bob) to match the destination DN's value. $rdn_attr = substr( $dest_dn, 0, strpos( $dest_dn, '=' ) ); $rdn_value = get_rdn( $dest_dn ); $rdn_value = substr( $rdn_value, strpos( $rdn_value, '=' ) + 1 ); $new_entry[ $rdn_attr ] = $rdn_value; // don't need a dn attribute in the new entry unset( $new_entry['dn'] ); // Check the user-defined custom call back first if( true === preEntryCreate( $dest_server_id, $dest_dn, $new_entry ) ) { $add_result = @ldap_add( $ds, $dest_dn, $new_entry ); if( ! $add_result ) { postEntryCreate( $dest_server_id, $dest_dn, $new_entry ); echo "

"; pla_error( $lang['copy_failed'] . $dest_dn, ldap_error( $ds ), ldap_errno( $ds ) ); } return $add_result; } else { return false; } } function build_tree( $source_server_id, $root_dn, &$tree, $filter='(objectClass=*)' ) { $children = get_container_contents( $source_server_id, $root_dn, 0, $filter ); if( is_array( $children ) && count( $children ) > 0 ) { $tree[ $root_dn ] = $children; foreach( $children as $child_dn ) build_tree( $source_server_id, $child_dn, $tree, $filter ); } }