2009-06-30 08:05:37 +00:00
|
|
|
<?php
|
2009-06-30 09:24:29 +00:00
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/entry_chooser.php,v 1.23 2005/03/25 16:30:21 wurley Exp $
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:24:29 +00:00
|
|
|
/**
|
|
|
|
* Display a selection (popup window) to pick a DN.
|
|
|
|
*
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
*/
|
2009-06-30 09:22:30 +00:00
|
|
|
|
|
|
|
require './common.php';
|
2009-06-30 08:07:14 +00:00
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
$server_id = isset( $_GET['server_id'] ) ? $_GET['server_id'] : false;
|
2009-06-30 09:24:29 +00:00
|
|
|
$container = isset( $_GET['container'] ) ? rawurldecode( $_GET['container'] ) : false;
|
2009-06-30 08:10:17 +00:00
|
|
|
$return_form_element = isset( $_GET['form_element'] ) ? htmlspecialchars( $_GET['form_element'] ) : null;
|
2009-06-30 09:24:29 +00:00
|
|
|
$rdn = isset( $_GET['rdn'] ) ? htmlspecialchars( $_GET['rdn'] ) : null;
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:24:29 +00:00
|
|
|
include "./header.php";
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
echo "<h3 class=\"subtitle\">" . $lang['entry_chooser_title'] . "</h3>\n";
|
2009-06-30 09:24:29 +00:00
|
|
|
flush(); ?>
|
2009-06-30 09:22:30 +00:00
|
|
|
|
|
|
|
<script language="javascript">
|
2009-06-30 09:24:29 +00:00
|
|
|
function returnDN( dn ) {
|
2009-06-30 09:22:30 +00:00
|
|
|
opener.document.<?php echo $return_form_element; ?>.value = dn;
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2009-06-30 09:24:29 +00:00
|
|
|
<?php if( $container ) {
|
|
|
|
echo $lang['server_colon_pare'] . "<b>" . htmlspecialchars( $servers[ $server_id ][ 'name' ] ) . "</b><br />\n";
|
2009-06-30 08:09:20 +00:00
|
|
|
echo $lang['look_in'] . "<b>" . htmlspecialchars( $container ) . "</b><br />\n";
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
/* Has the use already begun to descend into a specific server tree? */
|
2009-06-30 09:24:29 +00:00
|
|
|
if( $server_id !== false && $container !== false ) {
|
|
|
|
$ldapserver = new LDAPServer($server_id);
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:24:29 +00:00
|
|
|
if( ! $ldapserver->haveAuthInfo())
|
|
|
|
pla_error( $lang['not_enough_login_info'] );
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:24:29 +00:00
|
|
|
$dn_list = get_container_contents( $ldapserver, $container, 0, '(objectClass=*)', get_tree_deref_setting() );
|
2009-06-30 08:09:20 +00:00
|
|
|
sort( $dn_list );
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:24:29 +00:00
|
|
|
foreach ($ldapserver->getBaseDN() as $base_dn) {
|
|
|
|
debug_log(sprintf('%s: Comparing BaseDN [%s] with container [%s]','entry_chooser.php',$base_dn,$container),9);
|
|
|
|
if( 0 == pla_compare_dns( $container, $base_dn ) ) {
|
|
|
|
$parent_container = false;
|
|
|
|
$up_href = sprintf('entry_chooser.php?form_element=%s&rdn=%s',$return_form_element,$rdn);
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$parent_container = get_container( $container );
|
|
|
|
$up_href = sprintf('entry_chooser.php?form_element=%s&rdn=%s&server_id=%s&container=%s',
|
|
|
|
$return_form_element,$rdn,$server_id,rawurlencode( $parent_container ));
|
|
|
|
}
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
2009-06-30 09:24:29 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
echo " <a href=\"$up_href\" style=\"text-decoration:none\">" .
|
|
|
|
"<img src=\"images/up.png\"> ". $lang['back_up_p'] ."</a><br />\n";
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
if( count( $dn_list ) == 0 )
|
2009-06-30 08:09:20 +00:00
|
|
|
echo " (". $lang['no_entries'] .")<br />\n";
|
2009-06-30 09:24:29 +00:00
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
else
|
|
|
|
foreach( $dn_list as $dn ) {
|
2009-06-30 09:24:29 +00:00
|
|
|
$href = sprintf("javascript:returnDN( '%s%s' )",($rdn ? "$rdn," : ''),$dn);
|
|
|
|
echo " <a href=\"entry_chooser.php?form_element=$return_form_element&rdn=$rdn".
|
2009-06-30 08:07:14 +00:00
|
|
|
"&server_id=$server_id&container=" .
|
2009-06-30 08:05:37 +00:00
|
|
|
rawurlencode( $dn ) . "\"><img src=\"images/plus.png\" /></a> " .
|
|
|
|
"<a href=\"$href\">" . htmlspecialchars( $dn ) . "</a><br />\n";
|
|
|
|
}
|
2009-06-30 09:24:29 +00:00
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
/* draw the root of the selection tree (ie, list all the servers) */
|
2009-06-30 09:24:29 +00:00
|
|
|
} else {
|
2009-06-30 08:05:37 +00:00
|
|
|
foreach( $servers as $id => $server ) {
|
2009-06-30 09:24:29 +00:00
|
|
|
|
|
|
|
$ldapserver = new LDAPServer($id);
|
|
|
|
|
|
|
|
if( $ldapserver->isVisible() ) {
|
|
|
|
|
|
|
|
if( ! $ldapserver->haveAuthInfo() )
|
|
|
|
continue;
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
else {
|
2009-06-30 09:24:29 +00:00
|
|
|
echo "<b>" . htmlspecialchars( $ldapserver->name ) . "</b><br />\n";
|
|
|
|
foreach ($ldapserver->getBaseDN() as $dn) {
|
|
|
|
if( ! $dn ) {
|
|
|
|
echo "<small> (". $lang['could_not_det_base_dn'] .")</small><br />";
|
|
|
|
} else {
|
|
|
|
$href = sprintf("javascript:returnDN( '%s%s' )",($rdn ? "$rdn," : ''),$dn);
|
|
|
|
echo " <a href=\"entry_chooser.php?form_element=" .
|
|
|
|
"$return_form_element&rdn=$rdn&server_id=$id&container=" .
|
|
|
|
rawurlencode( $dn ) . "\"><img src=\"images/plus.png\" /></a> " .
|
|
|
|
"<a href=\"$href\">" . htmlspecialchars( $dn ) . "</a><br />\n";
|
|
|
|
}
|
2009-06-30 08:07:14 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
// added by PD. 14082003,
|
|
|
|
// adding the element access allows it to work with javascript arrays
|
|
|
|
|
|
|
|
// the name of the form extracted from the first part of the URL variable.
|
|
|
|
$formpart=substr($return_form_element,0,strpos($return_form_element,"."));
|
|
|
|
|
|
|
|
// the name of the element extracted from the last part of the URL variable (after the dot)
|
|
|
|
$elmpart =substr($return_form_element,strpos($return_form_element,".")+1);
|
|
|
|
|
|
|
|
// rebuilt return value
|
|
|
|
$return_form_element = $formpart . ".elements[\"" . $elmpart . "\"]";
|
2009-06-30 08:05:37 +00:00
|
|
|
?>
|