Compare commits

...

15 Commits

Author SHA1 Message Date
Deon George
53188cc24d RELEASE 0.9.8.5 2009-06-30 21:28:38 +10:00
Deon George
c3713350e2 RELEASE 0.9.8.5 2009-06-30 20:28:51 +10:00
Deon George
c131e8b479 RELEASE 0.9.8.4 2009-06-30 20:28:19 +10:00
Deon George
a01f7c8289 RELEASE 0.9.8.3 2009-06-30 20:27:56 +10:00
Deon George
7741110caf RELEASE 0.9.8.2 2009-06-30 20:27:11 +10:00
Deon George
abc62c7fdc RELEASE 0.9.8.1 2009-06-30 20:26:45 +10:00
Deon George
fdee1bdbd1 RELEASE 0.9.8 2009-06-30 20:26:08 +10:00
Deon George
1f7f96122f RELEASE 0.9.7.2 2009-06-30 19:41:11 +10:00
Deon George
b443271175 RELEASE 0.9.7.1 2009-06-30 19:40:37 +10:00
Deon George
bbcd2cb3b6 Moved files 2009-06-30 19:39:45 +10:00
Deon George
df48b8ff9b RELEASE 0.9.7 2009-06-30 19:29:51 +10:00
Deon George
d12096bbd3 RELEASE 0.9.5 2009-06-30 19:22:30 +10:00
Deon George
0a07abd27a RELEASE 0.9.3 2009-06-30 18:10:17 +10:00
Deon George
92be67a1bf RELEASE 0.9.2 2009-06-30 18:09:20 +10:00
Deon George
082c6b5fee Moved files 2009-06-30 18:08:51 +10:00
536 changed files with 58725 additions and 8798 deletions

58
INSTALL
View File

@@ -1,49 +1,23 @@
These instructions assume that you have a working install of:
a. A web server (Apache, IIS, etc).
b. PHP (with LDAP support)
For install instructions in non-English languages, see the wiki:
http://wiki.phpldapadmin.info
* Installing phpLDAPadmin in 4 easy steps:
* Requirements
1. Untar the archive (if you're reading this, you already did that).
phpLDAPadmin requires the following:
a. A web server (Apache, IIS, etc).
b. PHP 4.1.0 or newer (with LDAP support)
* To install
1. Unpack the archive (if you're reading this, you already did that).
2. Put the resulting 'phpldapadmin' directory somewhere in your webroot.
3. Copy 'config.php.example' to 'config.php' and edit to taste.
3. Copy 'config.php.example' to 'config.php' and edit to taste (this is in the config/ directory).
4. Then, point your browser to the phpldapadmin directory.
* Browser Notes
* For additional help
phpLDAPadmin was developed on Mozilla, and will most likely run best thereon.
However, testing has been done on Internet Explorer, and it should work
well also. No testing has been done on either Konqueror (or any khtml-based
browser like Safari) or Opera. If you find a browser incompatibility,
please report it.
* Contributors (thank you!)
Project Developers:
- David Smith Maintainer
- Xavier Renard LDIF master
- Nate Rotschafer Release manager
Patch writers:
- Bayu Irawan userPassword hash, html fixes, ldap_modify fixes
- Uwe Ebel short_open_tags fix
- Andrew Tipton SUP support in schema parser
- Eigil Bj<42>rgum UTF-8 support
- Brandon Lederer DNS entry template
Nathan Rotschafer
- Steve Rigler Password hash patch
- Chric Jackson Blowfish and md5crypt passwords
- Marius Rieder Enhanced schema parser
- Nick Burch Many realpath() fixes
Translators:
- Uwe Ebel German
- Xavier Renard French
- Dave Smith English ;)
If you can help translate, please join the phpldapadmin-devel mailing list:
https://lists.sourceforge.net/mailman/listinfo/phpldapadmin-devel
See the wiki:
http://wiki.phpldapadmin.info
Join our mailing list:
https://lists.sourceforge.net/lists/listinfo/phpldapadmin-devel

View File

@@ -1 +1 @@
0.9.1
$Name: RELEASE-0_9_8_5 $

View File

@@ -1,57 +0,0 @@
<?php
/*
* add_oclass.php
* Adds an objectClass to the specified dn.
* Variables that come in as POST vars:
*
* Note, this does not do any schema violation checking. That is
* performed in add_oclass_form.php.
*
* Vars that come in as POST:
* - dn (rawurlencoded)
* - server_id
* - new_oclass
* - new_attrs (array, if any)
*/
require 'common.php';
$dn = rawurldecode( $_POST['dn'] );
$encoded_dn = rawurlencode( $dn );
$new_oclass = $_POST['new_oclass'];
$server_id = $_POST['server_id'];
$new_attrs = $_POST['new_attrs'];
if( is_server_read_only( $server_id ) )
pla_error( $lang['no_updates_in_read_only_mode'] );
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
$new_entry = array();
$new_entry['objectClass'] = $new_oclass;
$new_attrs_entry = array();
$new_oclass_entry = array( 'objectClass' => $new_oclass );
if( is_array( $new_attrs ) && count( $new_attrs ) > 0 )
foreach( $new_attrs as $attr => $val )
$new_entry[ $attr ] = $val;
//echo "<pre>";
//print_r( $new_entry );
//exit;
$ds = pla_ldap_connect( $server_id ) or pla_error( $lang['could_not_connect'] );
$add_res = @ldap_mod_add( $ds, $dn, $new_entry );
if( ! $add_res )
{
pla_error( $lang['could_not_perform_ldap_mod_add'], ldap_error( $ds ), ldap_errno( $ds ) );
}
else
{
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn" );
}
?>

View File

@@ -1,110 +0,0 @@
<?php
/*
* add_oclass_form.php
* This page may simply add the objectClass and take you back to the edit page,
* but, in one condition it may prompt the user for input. That condition is this:
*
* If the user has requested to add an objectClass that requires a set of
* attributes with 1 or more not defined by the object. In that case, we will
* present a form for the user to add those attributes to the object.
*
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - server_id
* - new_oclass
*/
require 'common.php';
$dn = rawurldecode( $_POST['dn'] );
$encoded_dn = rawurlencode( $dn );
$new_oclass = $_POST['new_oclass'];
$server_id = $_POST['server_id'];
if( is_server_read_only( $server_id ) )
pla_error( $lang['no_updates_in_read_only_mode'] );
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
/* Ensure that the object has defined all MUST attrs for this objectClass.
* If it hasn't, present a form to have the user enter values for all the
* newly required attrs. */
$entry = get_object_attrs( $server_id, $dn, true );
$current_attrs = array();
foreach( $entry as $attr => $junk )
$current_attrs[] = strtolower($attr);
// grab the required attributes for the new objectClass
$must_attrs = get_schema_objectclasses( $server_id );
$must_attrs = $must_attrs[ strtolower($new_oclass) ]['must_attrs'];
sort( $must_attrs );
// build a list of the attributes that this new objectClass requires,
// but that the object does not currently contain
$needed_attrs = array();
foreach( $must_attrs as $attr )
if( ! in_array( strtolower($attr), $current_attrs ) )
$needed_attrs[] = $attr;
if( count( $needed_attrs ) > 0 )
{
include 'header.php'; ?>
<body>
<h3 class="title"><?php echo $lang['new_required_attrs']; ?></h3>
<h3 class="subtitle"><?php echo $lang['requires_to_add'] . ' ' . count($needed_attrs) .
' ' . $lang['new attributes']; ?></h3>
<small>
<?php
echo $lang['new_required_attrs_instructions'];
echo ' ' . count( $needed_attrs ) . ' ' . $lang['new_attributes'] . ' ';
echo $lang['that_this_oclass_requires']; ?>
</small>
<br />
<br />
<form action="add_oclass.php" method="post">
<input type="hidden" name="new_oclass" value="<?php echo htmlspecialchars( $new_oclass ); ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<table class="edit_dn" cellspacing="0">
<tr><th colspan="2"><?php echo $lang['new_required_attrs']; ?></th></tr>
<?php foreach( $needed_attrs as $count => $attr ) { ?>
<?php if( $count % 2 == 0 ) { ?>
<tr class="row1">
<?php } else { ?>
<tr class="row2">
<?php } ?>
<td class="attr"><b><?php echo htmlspecialchars($attr); ?></b></td>
<td class="val"><input type="text" name="new_attrs[<?php echo htmlspecialchars($attr); ?>]" value="" size="40" />
</tr>
<?php } ?>
</table>
<br />
<br />
<center><input type="submit" value="<?php echo $lang['add_oclass_and_attrs']; ?>" /></center>
</form>
</body>
</html>
<?php
}
else
{
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server." );
$add_res = @ldap_mod_add( $ds, $dn, array( 'objectClass' => $new_oclass ) );
if( ! $add_res )
pla_error( "Could not perform ldap_mod_add operation.", ldap_error( $ds ), ldap_errno( $ds ) );
else
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn" );
}
?>

View File

@@ -1,56 +0,0 @@
<?php
/*
* add_value.php
* Adds a value to an attribute for a given dn.
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
* - server_id
* - new_value (form element)
* - binary
*
* On success, redirect to the edit_dn page.
* On failure, echo an error.
*/
require 'common.php';
$dn = rawurldecode( $_POST['dn'] );
$encoded_dn = rawurlencode( $dn );
$attr = $_POST['attr'];
$encoded_attr = rawurlencode( $attr );
$server_id = $_POST['server_id'];
$new_value = $_POST['new_value'];
$new_value = utf8_encode($new_value);
$is_binary_val = isset( $_POST['binary'] ) ? true : false;
if( is_server_read_only( $server_id ) )
pla_error( $lang['no_updates_in_read_only_mode'] );
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
$ds = pla_ldap_connect( $server_id ) or pla_error( $lang['could_not_connect'] );
// special case for binary attributes:
// we must go read the data from the file.
if( $is_binary_val )
{
$file = $_FILES['new_value']['tmp_name'];
$f = fopen( $file, 'r' );
$binary_value = fread( $f, filesize( $file ) );
fclose( $f );
$new_value = $binary_value;
}
$new_entry = array( $attr => $new_value );
$add_result = @ldap_mod_add( $ds, $dn, $new_entry );
if( ! $add_result )
pla_error( $lang['could_not_perform_ldap_mod_add'], ldap_error( $ds ), ldap_errno( $ds ) );
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&updated_attr=$encoded_attr" );
?>

View File

@@ -1,160 +0,0 @@
<?php
/*
* add_value_form.php
* Displays a form to allow the user to enter a new value to add
* to the existing list of values for a multi-valued attribute.
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
* - server_id
*
*/
require 'common.php';
require 'config.php';
require_once 'functions.php';
$dn = $_GET['dn'];
$encoded_dn = rawurlencode( $dn );
$server_id = $_GET['server_id'];
$rdn = pla_explode_dn( $dn );
$rdn = $rdn[0];
$server_name = $servers[$server_id]['name'];
$attr = $_GET['attr'];
$encoded_attr = rawurlencode( $attr );
$current_values = get_object_attr( $server_id, $dn, $attr );
$num_current_values = ( is_array($current_values) ? count($current_values) : 1 );
$is_object_class = ( 0 == strcasecmp( $attr, 'objectClass' ) ) ? true : false;
$is_jpeg_photo = ( 0 == strcasecmp( $attr, 'jpegPhoto' ) ) ? true : false;
if( is_server_read_only( $server_id ) )
pla_error( $lang['no_updates_in_read_only_mode'] );
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
if( $is_object_class ) {
// fetch all available objectClasses and remove those from the list that are already defined in the entry
$schema_oclasses = get_schema_objectclasses( $server_id );
foreach( $current_values as $oclass )
unset( $schema_oclasses[ strtolower( $oclass ) ] );
} else {
$schema_attr = get_schema_attribute( $server_id, $attr );
}
?>
<?php include 'header.php'; ?>
<body>
<h3 class="title">
<?php echo $lang['add_new']; ?>
<b><?php echo htmlspecialchars($attr); ?></b>
<?php echo $lang['value_to']; ?>
<b><?php echo htmlentities($rdn); ?></b></h3>
<h3 class="subtitle">
<?php echo $lang['server']; ?>:
<b><?php echo $server_name; ?></b> &nbsp;&nbsp;&nbsp;
<?php echo $lang['distinguished_name']; ?>: <b><?php echo htmlspecialchars( $dn ); ?></b></h3>
<?php echo $lang['current_list_of']; ?> <b><?php echo $num_current_values; ?></b>
<?php echo $lang['values_for_attribute']; ?> <b><?php echo htmlspecialchars($attr); ?></b>:
<?php if( $is_jpeg_photo ) { ?>
<table><td>
<?php draw_jpeg_photos( $server_id, $dn ); ?>
</td></table>
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
<p><small>
<?php echo $lang['inappropriate_matching_note']; ?>
</small></p>
<!-- End of temporary warning -->
<?php } else if( is_attr_binary( $server_id, $attr ) ) { ?>
<ul>
<?php if( is_array( $vals ) ) { for( $i=1; $i<=count($vals); $i++ ) {
$href = "download_binary_attr.php?server_id=$server_id&amp;dn=$encoded_dn&amp;attr=$attr&amp;value_num=" . ($i-1); ?>
<li><a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value'] . ' ' . $i; ?>)</a></li>
<?php } } else {
$href = "download_binary_attr.php?server_id=$server_id&amp;dn=$encoded_dn&amp;attr=$attr"; ?>
<li><a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value']; ?></a></li>
<?php } ?>
</ul>
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
<p><small>
<?php echo $lang['inappropriate_matching_note']; ?>
</small></p>
<!-- End of temporary warning -->
<?php } else { ?>
<ul class="current_values">
<?php if( is_array( $current_values ) ) /*$num_current_values > 1 )*/ {
foreach( $current_values as $val ) { ?>
<li><nobr><?php echo htmlspecialchars(utf8_decode($val)); ?></nobr></li>
<?php } ?>
<?php } else { ?>
<li><nobr><?php echo htmlspecialchars(utf8_decode($current_values)); ?></nobr></li>
<?php } ?>
</ul>
<?php } ?>
<?php echo $lang['enter_value_to_add']; ?>
<br />
<br />
<?php if( $is_object_class ) { ?>
<form action="add_oclass_form.php" method="post" class="new_value">
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<select name="new_oclass">
<?php foreach( $schema_oclasses as $oclass => $desc ) { ?>
<option value="<?php echo $desc['name']; ?>"><?php echo $desc['name']; ?></option>
<?php } ?>
</select> <input type="submit" value="Add new objectClass" />
<br /><small><?php echo $lang['new_required_attrs_note']; ?></small>
<?php } else { ?>
<form action="add_value.php" method="post" class="new_value" <?php
if( is_attr_binary( $server_id, $attr ) ) echo "enctype=\"multipart/form-data\""; ?>>
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="attr" value="<?php echo $encoded_attr; ?>" />
<?php if( is_attr_binary( $server_id, $attr ) ) { ?>
<input type="file" name="new_value" />
<input type="hidden" name="binary" value="true" />
<?php } else { ?>
<input type="text" name="new_value" size="40" value="" />
<?php } ?>
<input type="submit" name="submit" value="Add New Value" />
<br />
<small><?php echo $lang['syntax']; ?>: <?php echo $schema_attr->getType(); ?></small><br />
<?php if( $schema_attr->getMaxLength() ) { ?>
<small>Max length: <?php echo number_format( $schema_attr->getMaxLength() ); ?>
characters</small>
<?php } ?>
</form>
<?php } ?>
</body>
</html>

View File

@@ -1,51 +0,0 @@
<?php
/*
* collapse.php
* This script alters the session variable 'tree', collapsing it
* at the dn specified in the query string.
*
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - server_id
*
* Note: this script is equal and opposite to expand.php
*/
require 'common.php';
$dn = $_GET['dn'];
$encoded_dn = rawurlencode( $dn );
$server_id = $_GET['server_id'];
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
session_start();
// dave commented this out since it was being triggered for weird reasons
//session_is_registered( 'tree' ) or pla_error( "Your session tree is not registered. That's weird. Shouldn't ever happen".
// ". Just go back and it should be fixed automagically." );
$tree = $_SESSION['tree'];
// and remove this instance of the dn as well
unset( $tree[$server_id][$dn] );
$_SESSION['tree'] = $tree;
session_write_close();
// This is for Opera. By putting "random junk" in the query string, it thinks
// that it does not have a cached version of the page, and will thus
// fetch the page rather than display the cached version
$time = gettimeofday();
$random_junk = md5( strtotime( 'now' ) . $time['usec'] );
// If cookies were disabled, build the url parameter for the session id.
// It will be append to the url to be redirect
$id_session_param="";
if(SID != ""){
$id_session_param = "&".session_name()."=".session_id();
}
header( "Location:tree.php?foo=$random_junk%23{$server_id}_{$encoded_dn}$id_session_param" );
?>

View File

@@ -1,53 +0,0 @@
<?php
/*
* common.php
* Contains code to be executed at the top of each phpLDAPadmin page.
* include this file at the top of every PHP file.
*/
if( file_exists( realpath( 'config.php' ) ) ) {
require realpath( 'config.php' );
}
require_once realpath( 'functions.php' );
require_once realpath( 'schema_functions.php' );
// grab the language file configured in config.php
if( ! isset( $language ) )
$language = 'english';
if( file_exists( realpath( "lang/$language.php" ) ) )
include realpath( "lang/$language.php" );
// Turn off notices about referencing arrays and such, but leave everything else on.
error_reporting( E_ALL ^ E_NOTICE );
if( ! isset( $templates ) || ! is_array( $templates ) )
$tempaltes = array();
// Always including the 'custom' template (the most generic and flexible)
$templates['custom'] =
array( 'desc' => 'Custom',
'icon' => 'images/object.png',
'handler' => 'custom.php' );
// Strip slashes from GET, POST, and COOKIE variables if this
// PHP install is configured to automatically addslashes()
if ( get_magic_quotes_gpc() && ( ! isset( $slashes_stripped ) || ! $slashes_stripped ) ) {
if( ! function_exists( "array_stripslashes" ) ) {
function array_stripslashes(&$array) {
if( is_array( $array ) )
while ( list( $key ) = each( $array ) )
if ( is_array( $array[$key] ) && $key != $array )
array_stripslashes( $array[$key] );
else
$array[$key] = stripslashes( $array[$key] );
}
}
array_stripslashes($_POST);
array_stripslashes($_GET);
array_stripslashes($_COOKIES);
$slashes_stripped = true;
}
?>

View File

@@ -1,176 +0,0 @@
<?php
/*
* The phpLDAPadmin config file
*
* This is where you customize phpLDAPadmin. The most important
* part is immediately below: The "LDAP Servers" section.
* You must specify at least one LDAP server there. You may add
* as many as you like. You can also specify your language, and
* many other options.
*
*/
// Your LDAP servers
$i=0;
$servers = array();
$servers[$i]['name'] = 'My LDAP Server'; /* A convenient name that will appear in the tree viewer */
$servers[$i]['host'] = 'ldap.example.com'; /* Examples: 'ldap.example.com', 'ldaps://ldap.example.com/'
Note: Leave blank to remove it from the list of servers in the
tree viewer*/
$servers[$i]['base'] = 'dc=example,dc=com';/* The base DN of your LDAP server. Leave this blank to have phpLDAPadmin
auto-detect it for you. */
$servers[$i]['port'] = 389; /* The port your LDAP server listens on (no quotes) */
$servers[$i]['auth_type'] = 'config'; /* 2 options: 'form': you will be prompted, and a cookie stored
with your login dn and password. 'config': specify your login dn
and password here. In both cases, use caution! */
$servers[$i]['login_dn'] = 'cn=Manager,dc=example,dc=com'; /* For anonymous binds, leave the login_dn and
login_pass blank */
$servers[$i]['login_pass'] = 'secret'; /* Your password (only if you specified 'config' for 'auth_type' */
$servers[$i]['tls'] = false; /* Use TLS to connect. Requires PHP 4.2 or greater */
$servers[$i]['default_hash'] = 'crypt'; /* Default password hashing algorith: one of md5, sha, md5crpyt, blowfish or
leave blank for now default algorithm. */
$servers[$i]['login_attr'] = 'dn'; /* If you specified 'form' as the auth_type above, you can optionally
specify here an attribute to use when logging in. If you enter 'uid',
then login as 'dsmith', phpLDAPadmin will search for uid=dsmith and
log in as such. Leave blank or specify 'dn' to use full DN for logging in .*/
$servers[$i]['read_only'] = false; /* Specify true If you want phpLDAPadmin to not display or permit any
modification to the LDAP server. */
/* If you want to configure additional LDAP servers, do so below. */
$i++;
$servers[$i]['name'] = 'Another server';
$servers[$i]['host'] = '';
$servers[$i]['base'] = 'dc=example,dc=com';
$servers[$i]['port'] = 389;
$servers[$i]['auth_type'] = 'config';
$servers[$i]['login_dn'] = '';
$servers[$i]['login_pass'] = '';
$servers[$i]['tls'] = false;
$servers[$i]['default_hash'] = 'crypt';
$servers[$i]['login_attr'] = '';
$servers[$i]['read_only'] = false;
// If you want to configure more LDAP servers, copy and paste the above (including the "$i++;")
// The temporary storage directory where we will put jpegPhoto data
// This directory must be readable and writable by your web server
$jpeg_temp_dir = "/tmp"; // Example for Unix systems
//$jpeg_temp_dir = "c:\\temp"; // Example for Windows systems
/** **/
/** Appearance and Behavior **/
/** **/
// The language setting. Right now, 'english', 'german' and 'french' are available
// Localization is not complete yet, but most strings have been translated.
// Please help by writing language files. See lang/english.php for an example.
$language = 'english';
// Set to true if you want LDAP data to be displayed read-only (without input fields)
// when a user logs in to a server anonymously
$anonymous_bind_implies_read_only = true;
// If you used auth_type 'form' in the servers list, you can adjust how long the cookie will last
// (default is 0 seconds, which expires when you close the browser)
$cookie_time = 0; // seconds
// How many pixels wide do you want your left frame view (for the tree browser)
$tree_width = 300; // pixels
// How long to keep jpegPhoto temporary files in the jpeg_temp_dir directory (in seconds)
$jpeg_tmp_keep_time = 120; // seconds
/** **/
/** Simple Search Form Config **/
/** **/
// Which attributes to include in the drop-down menu of the simple search form (comma-separated)
// Change this to suit your needs for convenient searching. Be sure to change the correlating
// list below ($search_attributes_display)
$search_attributes = "uid, cn, gidNumber, objectClass";
// This list correlates to the list directly above. If you want to present more readable names
// for your search attributes, do so here. Both lists must have the same number of entries.
$search_attributes_display = "User Name, Common Name, Group ID, objectClass";
// The list of attributes to display in each search result entry summary
$search_result_attributes = "dn, cn";
/** **/
/** Templates for entry creation **/
/** **/
$templates = array();
// Fill in this array with templates that you can create to suit your needs.
// Each entry defines a description (to be displayed in the template list) and
// a handler, which is a file that will be executed with certain POST vars set.
// See the templates provided here for examples of how to make your own template.
$templates[] =
array( 'desc' => 'User Account',
'icon' => 'images/user.png',
'handler' => 'new_user_template.php' );
$templates[] =
array( 'desc' => 'Address Book Entry (inetOrgPerson)',
'icon' => 'images/user.png',
'handler' => 'new_address_template.php' );
$templates[] =
array( 'desc' => 'Organizational Unit',
'icon' => 'images/ou.png',
'handler' => 'new_ou_template.php' );
$templates[] =
array( 'desc' => 'Posix Group',
'icon' => 'images/ou.png',
'handler' => 'new_posix_group_template.php' );
$templates[] =
array( 'desc' => 'Samba NT Machine',
'icon' => 'images/nt.png',
'handler' => 'new_nt_machine.php' );
$templates[] =
array( 'desc' => 'Samba User',
'icon' => 'images/user.png',
'handler' => 'new_smbuser_template.php' );
$templates[] =
array( 'desc' => 'DNS Entry',
'icon' => 'images/dc.png',
'handler' => 'new_dns_entry.php' );
$templates[] =
array( 'desc' => 'Posix Group',
'icon' => 'images/ou.png',
'handler' => 'new_posix_group_template.php' );
/** **/
/** User-friendly attribute translation **/
/** **/
$friendly_attrs = array();
// Use this array to map attribute names to user friendly names. For example, if you
// don't want to see "facsimileTelephoneNumber" but rather "Fax".
$friendly_attrs[ 'facsimileTelephoneNumber' ] = 'Fax';
$friendly_attrs[ 'telephoneNumber' ] = 'Phone';
/** **/
/** Hidden attributes **/
/** **/
// You may want to hide certain attributes from being displayed in the editor screen
// Do this by adding the desired attributes to this list (and uncomment it). This
// only affects the editor screen. Attributes will still be visible in the schema
// browser and elsewhere. An example is provided below:
//$hidden_attrs = array( 'jpegPhoto', 'objectClass' );
?>

381
config/config.php.example Normal file
View File

@@ -0,0 +1,381 @@
<?php
/** NOTE **
** Make sure that <?php is the FIRST line of this file!
** IE: There should NOT be any blank lines or spaces BEFORE <?php
**/
/**
* The phpLDAPadmin config file
*
* This is where you can customise some of the phpLDAPadmin defaults
* that are defined in config_default.php.
*
* To override a default, use the $config->custom variable to do so.
* For example, the default for defining the language in config_default.php
*
* $this->default->appearance['lang'] = array(
* 'desc'=>'Language',
* 'default'=>'auto');
*
* to override this, use $config->custom->appearance['lang'] = 'en';
*
* This file is also used to configure your LDAP server connections.
*
* You must specify at least one LDAP server there. You may add
* as many as you like. You can also specify your language, and
* many other options.
*
* NOTE: Commented out values in this file prefixed by //, represent the
* defaults that have been defined in config_default.php.
* Commented out values prefixed by #, dont reflect their default value, you can
* check config_default.php if you want to see what the default is.
*
* DONT change config_default.php, you changes will be lost by the next release
* of PLA. Instead change this file - as it will NOT be replaced by a new
* version of phpLDAPadmin.
*/
/*********************************************/
/* Useful important configuration overrides */
/*********************************************/
/* If you are asked to put pla in debug mode, this is how you do it: */
# $config->custom->debug['level'] = 255;
# $config->custom->debug['syslog'] = true;
# $config->custom->debug['file'] = '/tmp/pla_debug.log';
/* phpLDAPadmin can encrypt the content of sensitive cookies if you set this
to a big random string. */
$config->custom->session['blowfish'] = '';
/* The language setting. If you set this to 'auto', phpLDAPadmin will attempt
to determine your language automatically. Otherwise, available lanaguages
are: 'ct', 'de', 'en', 'es', 'fr', 'it', 'nl', and 'ru'
Localization is not complete yet, but most strings have been translated.
Please help by writing language files. See lang/en.php for an example. */
// $config->custom->appearance['language'] = 'auto';
/* The temporary storage directory where we will put jpegPhoto data
This directory must be readable and writable by your web server. */
// $config->custom->jpeg['tmpdir'] = "/tmp"; // Example for Unix systems
# $config->custom->jpeg['tmpdir'] = "c:\\temp"; // Example for Windows systems
/*********************************************/
/* Define your LDAP servers in this section */
/*********************************************/
$i=0;
$ldapservers = new LDAPServers;
/* A convenient name that will appear in the tree viewer and throughout
phpLDAPadmin to identify this LDAP server to users. */
$ldapservers->SetValue($i,'server','name','My LDAP Server');
/* Examples:
'ldap.example.com',
'ldaps://ldap.example.com/',
'ldapi://%2fusr%local%2fvar%2frun%2fldapi'
(Unix socket at /usr/local/var/run/ldap) */
// $ldapservers->SetValue($i,'server','host','127.0.0.1');
/* The port your LDAP server listens on (no quotes). 389 is standard. */
// $ldapservers->SetValue($i,'server','port','389');
/* Array of base DNs of your LDAP server. Leave this blank to have phpLDAPadmin
auto-detect it for you. */
// $ldapservers->SetValue($i,'server','base',array(''));
/* Three options for auth_type:
1. 'cookie': you will login via a web form, and a client-side cookie will
store your login dn and password.
2. 'session': same as cookie but your login dn and password are stored on the
web server in a persistent session variable.
3. 'config': specify your login dn and password here in this config file. No
login will be required to use phpLDAPadmin for this server.
Choose wisely to protect your authentication information appropriately for
your situation. If you choose 'cookie', your cookie contents will be
encrypted using blowfish and the secret your specify above as
session['blowfish']. */
// $ldapservers->SetValue($i,'server','auth_type','cookie');
/* The DN of the user for phpLDAPadmin to bind with. For anonymous binds or
'cookie' or 'session' auth_types, LEAVE THE LOGIN_DN AND LOGIN_PASS BLANK. If
you specify a login_attr in conjunction with a cookie or session auth_type,
then you can also specify the login_dn/login_pass here for searching the
directory for users (ie, if your LDAP server does not allow anonymous binds. */
// $ldapservers->SetValue($i,'login','dn','');
# $ldapservers->SetValue($i,'login','dn','cn=Manager,dc=example,dc=com');
/* Your LDAP password. If you specified an empty login_dn above, this MUST also
be blank. */
// $ldapservers->SetValue($i,'login','pass','');
# $ldapservers->SetValue($i,'login','pass','secret');
/* Use TLS (Transport Layer Security) to connect to the LDAP server. */
// $ldapservers->SetValue($i,'server','tls',false);
/* If the link between your web server and this LDAP server is slow, it is
recommended that you set 'low_bandwidth' to true. This will enable
phpLDAPadmin to forego some "fancy" features to conserve bandwidth. */
// $ldapservers->SetValue($i,'server','low_bandwidth',false);
/* Default password hashing algorithm. One of md5, ssha, sha, md5crpyt, smd5,
blowfish, crypt or leave blank for now default algorithm. */
// $ldapservers->SetValue($i,'appearance','password_hash','md5');
/* If you specified 'cookie' or 'session' as the auth_type above, you can
optionally specify here an attribute to use when logging in. If you enter
'uid' and login as 'dsmith', phpLDAPadmin will search for (uid=dsmith)
and log in as that user.
Leave blank or specify 'dn' to use full DN for logging in. Note also that if
your LDAP server requires you to login to perform searches, you can enter the
DN to use when searching in 'login_dn' and 'login_pass' above. You may also
specify 'string', in which case you can provide a string to use for logging
users in. See 'login_string' directly below. */
// $ldapservers->SetValue($i,'login','attr','dn');
/* If you specified 'cookie' or 'session' as the auth_type above, and you
specified 'string' for 'login_attr' above, you must provide a string here for
logging users in. If, for example, I have a lot of user entries with DNs like
"uid=dsmith,ou=People,dc=example,dc=com", then I can specify a string
"uid=<username>,ou=People,dc=example,dc=com" and my users can login with
their user names alone, ie: "dsmith" in this case. */
# $ldapservers->SetValue($i,'login','string','uid=<username>,ou=People,dc=example,dc=com');
/* If 'login_attr' is used above such that phpLDAPadmin will search for your DN
at login, you may restrict the search to a specific objectClass. EG, set this
to 'posixAccount' or 'inetOrgPerson', depending upon your setup. */
// $ldapservers->SetValue($i,'login','class',null);
/* Specify true If you want phpLDAPadmin to not display or permit any
modification to the LDAP server. */
// $ldapservers->SetValue($i,'server','read_only',false);
/* Specify false if you do not want phpLDAPadmin to draw the 'Create new' links
in the tree viewer. */
// $ldapservers->SetValue($i,'appearance','show_create',true);
/* This feature allows phpLDAPadmin to automatically determine the next
available uidNumber for a new entry. */
// $ldapservers->SetValue($i,'auto_number','enable',true);
/* The mechanism to use when finding the next available uidNumber. Two possible
values: 'uidpool' or 'search'.
The 'uidpool' mechanism uses an existing uidPool entry in your LDAP server to
blindly lookup the next available uidNumber. The 'search' mechanism searches
for entries with a uidNumber value and finds the first available uidNumber
(slower). */
// $ldapservers->SetValue($i,'auto_number','mechanism','search');
/* The DN of the search base when the 'search' mechanism is used above. */
# $ldapservers->SetValue($i,'auto_number','search_base','ou=People,dc=example,dc=com');
/* The minimum number to use when searching for the next available UID number
(only when 'search' is used for auto_uid_number_mechanism' */
// $ldapservers->SetValue($i,'auto_number','min','1000');
/* The DN of the uidPool entry when 'uidpool' mechanism is used above. */
# $servers[$i]['auto_uid_number_uid_pool_dn'] = 'cn=uidPool,dc=example,dc=com';
/* If you set this, then phpldapadmin will bind to LDAP with this user ID when
searching for the uidnumber. The idea is, this user id would have full
(readonly) access to uidnumber in your ldap directory (the logged in user
may not), so that you can be guaranteed to get a unique uidnumber for your
directory. */
// $ldapservers->SetValue($i,'auto_number','dn',null);
/* The password for the dn above. */
// $ldapservers->SetValue($i,'auto_number','pass',null);
/* Enable anonymous bind login. */
// $ldapservers->SetValue($i,'login','anon_bind',true);
/* Use customized page with prefix when available. */
# $ldapservers->SetValue($i,'custom','pages_prefix','custom_');
/* If you set this, then phpldapadmin will bind to LDAP with this user when
testing for unique attributes (as set in unique_attrs array). If you want to
enforce unique attributes, than this id should have full (readonly) access
to the attributes in question (the logged in user may not have enough access)
*/
// $ldapservers->SetValue($i,'unique_attrs','dn',null);
/* The password for the dn above */
// $ldapservers->SetValue($i,'unique_attrs','pass',null);
/* If you set this, then only these DNs are allowed to log in. This array can
contain individual users, groups or ldap search filter(s). Keep in mind that
the user has not authenticated yet, so this will be an anonymous search to
the LDAP server, so make your ACLs allow these searches to return results! */
# $ldapservers->SetValue($i,'login','allowed_dns',array(
# 'uid=stran,ou=People,dc=example,dc=com',
# '(&(gidNumber=811)(objectClass=groupOfNames))',
# '(|(uidNumber=200)(uidNumber=201))',
# 'cn=callcenter,ou=Group,dc=example,dc=com'));
/* Set this if you dont want this LDAP server to show in the tree */
// $ldapservers->SetValue($i,'appearance','visible',true);
/* This is the time out value in minutes for the server. After as many minutes
of inactivity you will be automatically logged out. If not set, the default
value will be ( session_cache_expire()-1 ) */
# $ldapservers->SetValue($i,'login','timeout',30);
/* Set this if you want phpldapadmin to perform rename operation on entry which
has children. Certain servers are known to allow it, certain are not */
// $ldapservers->SetValue($i,'server','branch_rename',false);
/**************************************************************************
* If you want to configure additional LDAP servers, do so below. *
* Remove the commented lines and use this section as a template for all *
* your other LDAP servers. *
**************************************************************************/
/*
$i++;
$ldapservers->SetValue($i,'server','name','LDAP Server');
$ldapservers->SetValue($i,'server','host','127.0.0.1');
$ldapservers->SetValue($i,'server','port','389');
$ldapservers->SetValue($i,'server','base',array(''));
$ldapservers->SetValue($i,'server','auth_type','cookie');
$ldapservers->SetValue($i,'login','dn','');
$ldapservers->SetValue($i,'login','pass','');
$ldapservers->SetValue($i,'server','tls',false);
$ldapservers->SetValue($i,'server','low_bandwidth',false);
$ldapservers->SetValue($i,'appearance','password_hash','md5');
$ldapservers->SetValue($i,'login','attr','dn');
$ldapservers->SetValue($i,'login','string',null);
$ldapservers->SetValue($i,'login','class',null);
$ldapservers->SetValue($i,'server','read_only',false);
$ldapservers->SetValue($i,'appearance','show_create',true);
$ldapservers->SetValue($i,'auto_number','enable',true);
$ldapservers->SetValue($i,'auto_number','mechanism','search');
$ldapservers->SetValue($i,'auto_number','search_base',null);
$ldapservers->SetValue($i,'auto_number','min','1000');
$ldapservers->SetValue($i,'auto_number','dn',null);
$ldapservers->SetValue($i,'auto_number','pass',null);
$ldapservers->SetValue($i,'login','anon_bind',true);
$ldapservers->SetValue($i,'custom','pages_prefix','custom_');
$ldapservers->SetValue($i,'unique_attrs','dn',null);
$ldapservers->SetValue($i,'unique_attrs','pass',null);
*/
/*********************************************/
/* User-friendly attribute translation */
/*********************************************/
/* Use this array to map attribute names to user friendly names. For example, if
you don't want to see "facsimileTelephoneNumber" but rather "Fax". */
$friendly_attrs = array();
$friendly_attrs['facsimileTelephoneNumber'] = 'Fax';
$friendly_attrs['telephoneNumber'] = 'Phone';
/*********************************************/
/* Support for attrs display order */
/*********************************************/
/* Use this array if you want to have your attributes displayed in a specific
order. You can use default attribute names or their fridenly names.
For example, "sn" will be displayed right after "givenName". All the other
attributes that are not specified in this array will be displayed after in
alphabetical order. */
# $attrs_display_order = array(
# 'givenName',
# 'sn',
# 'cn',
# 'displayName',
# 'uid',
# 'uidNumber',
# 'gidNumber',
# 'homeDirectory',
# 'mail',
# 'userPassword'
# );
/*********************************************/
/* Hidden attributes */
/*********************************************/
/* You may want to hide certain attributes from being displayed in the editor
screen. Do this by adding the desired attributes to this list (and uncomment
it). This only affects the editor screen. Attributes will still be visible in
the schema browser and elsewhere. An example is provided below:
NOTE: The user must be able to read the hidden_except_dn entry to be
excluded. */
# $hidden_attrs = array( 'jpegPhoto', 'objectClass' );
# $hidden_except_dn = "cn=PLA UnHide,ou=Groups,c=AU";
/* Hidden attributes in read-only mode. If undefined, it will be equal to
$hidden_attrs. */
# $hidden_attrs_ro = array(
# 'objectClass','shadowWarning', 'shadowLastChange', 'shadowMax',
# 'shadowFlag', 'shadowInactive', 'shadowMin', 'shadowExpire');
/** **/
/** Read-only attributes **/
/** **/
/* You may want to phpLDAPadmin to display certain attributes as read only,
meaning that users will not be presented a form for modifying those
attributes, and they will not be allowed to be modified on the "back-end"
either. You may configure this list here:
NOTE: The user must be able to read the read_only_except_dn entry to be
excluded. */
# $read_only_attrs = array( 'objectClass' );
# $read_only_except_dn = "cn=PLA ReadWrite,ou=Groups,c=AU";
/* An example of how to specify multiple read-only attributes: */
# $read_only_attrs = array( 'jpegPhoto', 'objectClass', 'someAttribute' );
/*********************************************/
/* Unique attributes */
/*********************************************/
/* You may want phpLDAPadmin to enforce some attributes to have unique values
(ie: not belong to other entries in your tree. This (together with
unique_attrs['dn'] and unique_attrs['pass'] option will not let updates to
occur with other attributes have the same value.
NOTE: Currently the unique_attrs is NOT enforced when copying a dn. (Need to
present a user with the option of changing the unique attributes. */
# $unique_attrs = array('uid','uidNumber','mail');
/*********************************************/
/* Predefined Queries (canned views) */
/*********************************************/
/* To make searching easier, you may setup predefined queries below: */
$q=0;
$queries = array();
/* The name that will appear in the simple search form */
$queries[$q]['name'] = 'User List';
/* The base to search on */
$queries[$q]['base'] = 'dc=example,dc=com';
/* The search scope (sub, base, one) */
$queries[$q]['scope'] = 'sub';
/* The LDAP filter to use */
$queries[$q]['filter'] = '(&(objectClass=posixAccount)(uid=*))';
/* The attributes to return */
$queries[$q]['attributes'] = 'cn, uid, homeDirectory, telephonenumber, jpegphoto';
/* If you want to configure more pre-defined queries, copy and paste the above (including the "$q++;") */
$q++;
$queries[$q]['name'] = 'Samba Users';
$queries[$q]['base'] = 'dc=example,dc=com';
$queries[$q]['scope'] = 'sub';
$queries[$q]['filter'] = '(&(|(objectClass=sambaAccount)(objectClass=sambaSamAccount))(objectClass=posixAccount)(!(uid=*$)))';
$queries[$q]['attributes'] = 'uid, smbHome, uidNumber';
$q++;
$queries[$q]['name'] = 'Samba Computers';
$queries[$q]['base'] = 'dc=example,dc=com';
$queries[$q]['scope'] = 'sub';
$queries[$q]['filter'] = '(&(objectClass=sambaAccount)(uid=*$))';
$queries[$q]['attributes'] = 'uid, homeDirectory';
?>

170
copy.php
View File

@@ -1,170 +0,0 @@
<?php
/*
* copy.php
* Copies a given object to create a new one.
*
* Vars that come in as POST vars
* - source_dn (rawurlencoded)
* - new_dn (form element)
* - server_id
*/
require 'common.php';
session_start();
$source_dn = rawurldecode( $_POST['old_dn'] );
$dest_dn = utf8_encode( $_POST['new_dn'] );
$encoded_dn = rawurlencode( $old_dn );
$source_server_id = $_POST['server_id'];
$dest_server_id = $_POST['dest_server_id'];
$do_recursive = ( isset( $_POST['recursive'] ) && $_POST['recursive'] == 'on' ) ? true : false;
if( is_server_read_only( $dest_server_id ) )
pla_error( "You cannot perform updates while server is in read-only mode" );
check_server_id( $source_server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $source_server_id ) );
have_auth_info( $source_server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
check_server_id( $dest_server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $dest_server_id ) );
have_auth_info( $dest_server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
include 'header.php';
/* Error checking */
if( 0 == strlen( trim( $dest_dn ) ) )
pla_error( "You left the destination DN blank." );
if( strcasecmp( $source_dn,$dest_dn ) == 0 && $source_server_id == $dest_server_id )
pla_error( "The source and destination DN are the same." );
if( $do_recursive ) {
// build a tree similar to that of the tree browser to give to r_copy_dn
$snapshot_tree = array();
include 'header.php';
echo "<body>\n";
echo "<h3 class=\"title\">Copying " . htmlspecialchars( $source_dn ) . "</h3>\n";
echo "<h3 class=\"subtitle\">Recursive copy progress</h3>\n";
echo "<br /><br />";
echo "<small>\n";
echo "Building snapshot of tree to copy... ";
flush();
build_tree( $source_server_id, $source_dn, $snapshot_tree );
echo " <span style=\"color:green\">Success</span><br />\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 "</small>\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( session_is_registered( '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();
}
}
?>
<!-- refresh the tree view (with the new DN renamed)
and redirect to the edit_dn page -->
<script language="javascript">
parent.left_frame.location.reload();
</script>
<br />
Copy successful! Would you like to <a href="<?php echo $edit_url; ?>">view the new entry</a>?
<br />
<br />
<br />
<br />
</body>
</html>
<?php
}
else
{
exit;
}
function r_copy_dn( $source_server_id, $dest_server_id, &$tree, $root_dn, $dest_dn )
{
echo "<nobr>Copying " . htmlspecialchars( $root_dn ) . "...";
flush();
$copy_result = copy_dn( $source_server_id, $root_dn, $dest_server_id, $dest_dn );
if( ! $copy_result ) {
global $R_COPY_ERROR;
return false;
}
echo "<span style=\"color:green\">Success</span></nobr><br />\n";
flush();
$children = $tree[ $root_dn ];
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;
$ds = pla_ldap_connect( $dest_server_id ) or pla_error( "Could not connect to LDAP server" );
$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'] );
$add_result = @ldap_add( $ds, $dest_dn, $new_entry );
if( ! $add_result ) {
echo "</small><br /><br />";
pla_error( "Failed to copy $source_dn (server: $source_server_id) to " .
"$dest_dn (server: $dest_server_id)", ldap_error( $ds ), ldap_errno( $ds ) );
}
return $add_result;
}
function build_tree( $source_server_id, $root_dn, &$tree )
{
$children = get_container_contents( $source_server_id, $root_dn );
if( is_array( $children ) && count( $children ) > 0 )
{
$tree[ $root_dn ] = $children;
foreach( $children as $child_dn )
build_tree( $source_server_id, $child_dn, $tree );
}
}

View File

@@ -1,85 +0,0 @@
<?php
/*
* copy_form.php
* Copies a given object to create a new one.
*
* - dn (rawurlencoded)
* - server_id
*/
require 'common.php';
$dn = rawurldecode( $_GET['dn'] );
$encoded_dn = rawurlencode( $dn );
$server_id = $_GET['server_id'];
$rdn = pla_explode_dn( $dn );
$container = $rdn[ 1 ];
for( $i=2; $i<count($rdn)-1; $i++ )
$container .= ',' . $rdn[$i];
$rdn = $rdn[0];
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
$attrs = get_object_attrs( $server_id, $dn );
$server_name = $servers[$server_id]['name'];
$select_server_html = "";
foreach( $servers as $id => $server )
{
if( $server['host'] )
{
$select_server_html .= "<option value=\"$id\"". ($id==$server_id?" selected":"") .">" . $server['name'] . "</option>\n";
}
}
$children = get_container_contents( $server_id, $dn );
?>
<?php include 'header.php'; ?>
<body>
<h3 class="title">Copy <?php echo utf8_decode( $rdn ); ?></h3>
<h3 class="subtitle">Server: <b><?php echo $server_name; ?></b> &nbsp;&nbsp;&nbsp; Distinguished Name: <b><?php echo $dn; ?></b></h3>
<center>
Copy <b><?php echo htmlspecialchars( utf8_decode( $rdn )); ?></b> to a new object:<br />
<br />
<form action="copy.php" method="post" name="copy_form">
<input type="hidden" name="old_dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<table>
<tr>
<td>Destination DN:</td>
<td>
<input type="text" name="new_dn" size="45" value="<?php echo htmlspecialchars( utf8_decode( $dn ) ); ?>" />
<?php draw_chooser_link( 'copy_form.new_dn' ); ?></td>
</td>
</tr>
<tr>
<td>Destination Server:</td>
<td><select name="dest_server_id"><?php echo $select_server_html; ?></select></td>
</tr>
<tr>
<td colspan="2"><small>Note: Copying between different servers only works if there are no schema violations</small></td>
</tr>
<?php if( is_array( $children ) && count( $children ) > 0 ) { ?>
<tr>
<td colspan="2"><input type="checkbox" name="recursive" />
Recursively copy all children of this object as well.</td>
</tr>
<?php } ?>
<tr>
<td colspan="2" align="right"><input type="submit" value="Copy" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>

View File

@@ -1,136 +0,0 @@
<?php
/*
* create.php
* Creates a new object.
*
* Variables that come in as POST vars:
* - new_dn
* - attrs (an array of attributes)
* - vals (an array of values for the above attrs)
* - required_attrs (an array with indices being the attributes,
* and the values being their respective values)
* - object_classes (rawurlencoded, and serialized array of objectClasses)
* - server_id
*/
require 'common.php';
$new_dn = $_POST['new_dn'];
//$new_dn = utf8_encode( $new_dn );
$encoded_dn = rawurlencode( $new_dn );
$server_id = $_POST['server_id'];
$vals = $_POST['vals'];
$attrs = $_POST['attrs'];
$required_attrs = isset( $_POST['required_attrs'] ) ? $_POST['required_attrs'] : false;
$object_classes = unserialize( rawurldecode( $_POST['object_classes'] ) );
$container = get_container( $new_dn );
if( is_server_read_only( $server_id ) )
pla_error( "You cannot perform updates while server is in read-only mode" );
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
// build the new entry
$new_entry = array();
if( isset( $required_attrs ) && is_array( $required_attrs ) )
{
foreach( $required_attrs as $attr => $val )
{
if( $val == '' )
pla_error( "Error, you left the value for required attribute <b>" .
htmlspecialchars( $attr ) . "</b> blank." );
$new_entry[ $attr ][] = utf8_encode( $val );
}
}
if( isset( $vals ) && is_array( $vals ) )
{
foreach( $vals as $i => $val )
{
$attr = $attrs[$i];
if( is_attr_binary( $server_id, $attr ) ) {
if( $_FILES['vals']['name'][$i] != '' ) {
// read in the data from the file
$file = $_FILES['vals']['tmp_name'][$i];
//echo "Reading in file $file...\n";
$f = fopen( $file, 'r' );
$binary_data = fread( $f, filesize( $file ) );
fclose( $f );
$val = $binary_data;
$new_entry[ $attr ][] = $val;
}
} else {
if( trim($val) )
$new_entry[ $attr ][] = utf8_encode( $val );
}
}
}
$new_entry['objectClass'] = $object_classes;
if( ! in_array( 'top', $new_entry['objectClass'] ) )
$new_entry['objectClass'][] = 'top';
// UTF-8 magic. Must decode the values that have been passed to us
foreach( $new_entry as $attr => $vals )
if( is_array( $vals ) )
foreach( $vals as $i => $v )
$new_entry[ $attr ][ $i ] = utf8_decode( $v );
else
$new_entry[ $attr ] = utf8_decode( $vals );
//echo "<pre>"; var_dump( $new_dn );print_r( $new_entry ); echo "</pre>";
$ds = pla_ldap_connect( $server_id );
$add_result = @ldap_add( $ds, $new_dn, $new_entry );
if( $add_result )
{
$edit_url="edit.php?server_id=$server_id&dn=" . rawurlencode( $new_dn );
// update the session tree to reflect the change
session_start();
if( session_is_registered( 'tree' ) )
{
$tree = $_SESSION['tree'];
$tree_icons = $_SESSION['tree_icons'];
if( isset( $tree[$server_id][$container] ) ) {
$tree[$server_id][$container][] = $new_dn;
sort( $tree[$server_id][$container] );
$tree_icons[$server_id][$new_dn] = get_icon( $server_id, $new_dn );
}
$_SESSION['tree'] = $tree;
$_SESSION['tree_icons'] = $tree_icons;
session_write_close();
}
?>
<html>
<head>
<?php if( isset( $tree[$server_id][$container] ) ) { ?>
<!-- refresh the tree view (with the new DN renamed)
and redirect to the edit_dn page -->
<script language="javascript">
parent.left_frame.location.reload();
</script>
<?php } ?>
<meta http-equiv="refresh" content="0; url=<?php echo $edit_url; ?>" />
</head>
<body>
Redirecting... <a href="<?php echo $edit_url; ?>">here</a>.
</body>
</html>
<?php
}
else
{
pla_error( "Could not add the object to the LDAP server.", ldap_error( $ds ), ldap_errno( $ds ) );
}
?>

View File

@@ -1,83 +0,0 @@
<?php
/*
* create_form.php
* The menu where the user chooses an RDN, Container, and Template for creating a new entry.
* After submitting this form, the user is taken to their chosen Template handler.
*
* Variables that come in as GET vars
* - server_id (optional)
* - container (rawurlencoded) (optional)
*/
require 'common.php';
$server_id = $_REQUEST['server_id'];
$step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : 1; // defaults to 1
$container = $_REQUEST['container'];
if( is_server_read_only( $server_id ) )
pla_error( "You cannot perform updates while server is in read-only mode" );
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
$server_name = $servers[$server_id]['name'];
// build the server drop-down html
$server_menu_html = '<select name="server_id">';
$js_dn_list = '';
foreach( $servers as $id => $server ) {
if( $server['host'] ) {
$server_menu_html .= '<option value="'.$id.'"' . ( $id==$server_id? ' selected' : '' ) . '>';
$server_menu_html .= $server['name'] . '</option>';
}
}
$server_menu_html .= '</select>';
?>
<?php include 'header.php'; ?>
<body>
<h3 class="title">Create Object</h3>
<h3 class="subtitle">Choose a template</h3>
<center><h3>Select a template for the creation process</h3></center>
<form action="creation_template.php" method="post">
<input type="hidden" name="container" value="<?php echo htmlspecialchars( $container ); ?>" />
<table class="create">
<tr>
<td class="heading">Server:</td>
<td><?php echo $server_menu_html; ?></td>
</tr>
<tr>
<td class="heading">Template:</td>
<td>
<table class="templates">
<?php foreach( $templates as $name => $template ) { ?>
<tr>
<td><input type="radio"
name="template"
value="<?php echo htmlspecialchars($name);?>"
id="<?php echo htmlspecialchars($name); ?>" /></td>
<td><label for="<?php echo htmlspecialchars($name);?>">
<img src="<?php echo $template['icon']; ?>" /></label></td>
<td><label for="<?php echo htmlspecialchars($name);?>">
<?php echo htmlspecialchars( $template['desc'] ); ?></label></td>
</tr>
<?php } ?>
</table>
</td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" name="submit" value="Proceed &gt;&gt;" /></center></td>
</tr>
</table>
</form>
</body>
</html>

View File

@@ -1,47 +0,0 @@
<?php
/* file: creation_template.php
* This file simply acts as a plugin grabber for the creator templates in
* the directory templates/creation/
*
* Expected POST vars:
* server_id
* template
*/
require 'common.php';
$template = $_POST['template'];
$template = $templates[$template];
$server_id = $_POST['server_id'];
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
$server_name = $servers[ $server_id ][ 'name' ];
if( is_server_read_only( $server_id ) )
pla_error( "You cannot perform updates while server is in read-only mode" );
include 'header.php';
?>
<body>
<h3 class="title">Create Object</h3>
<h3 class="subtitle">On server '<?php echo htmlspecialchars( $server_name ); ?>',
using template '<?php echo htmlspecialchars( $template['desc'] ); ?>'</h3>
<?php
if( ! isset( $_POST['template'] ) )
pla_error( "No template specified in POST variables.\n" );
$handler = 'templates/creation/' . $template['handler'];
$handler = realpath( $handler );
if( file_exists( $handler ) )
include $handler;
else
pla_error( "Your config specifies a handler of <b>" . htmlspecialchars( $template['handler'] ) .
"</b> for this template. But, this handler does not exist in the 'templates/creation' directory." );

View File

@@ -1,67 +0,0 @@
<?php
/*
* delete.php
* Deletes a DN and presents a "job's done" message.
*
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - server_id
*/
require 'common.php';
$encoded_dn = $_POST['dn'];
$dn = rawurldecode( $encoded_dn );
$server_id = $_POST['server_id'];
if( $dn === null )
pla_error( "You must specify a DN." );
if( is_server_read_only( $server_id ) )
pla_error( "You cannot perform updates while server is in read-only mode" );
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
$del_result = @ldap_delete( $ds, $dn );
if( $del_result )
{
// kill the DN from the tree browser session variable and
// refresh the tree viewer frame (left_frame)
session_start();
if( session_is_registered( 'tree' ) )
{
$tree = $_SESSION['tree'];
// does it have children? (it shouldn't, but hey, you never know)
if( isset( $tree[$server_id][$dn] ) )
unset( $tree[$server_id][$dn] );
// search and destroy
foreach( $tree[$server_id] as $tree_dn => $subtree )
foreach( $subtree as $key => $sub_tree_dn )
if( 0 == strcasecmp( $sub_tree_dn, $dn ) )
unset( $tree[$server_id][$tree_dn][$key] );
}
$_SESSION['tree'] = $tree;
session_write_close();
?>
<script language="javascript">
parent.left_frame.location.reload();
</script>
Object deleted successfully.
<?php
} else {
pla_error( "Could not delete the object: " . htmlspecialchars( utf8_decode( $dn ) ), ldap_error( $ds ), ldap_errno( $ds ) );
}

View File

@@ -1,42 +0,0 @@
<?php
/*
* delete_attr.php
* Deletes an attribute from an entry with NO confirmation.
*
* On success, redirect to edit.php
* On failure, echo an error.
*/
require 'common.php';
if( is_server_read_only( $server_id ) )
pla_error( "You cannot perform updates while server is in read-only mode" );
$server_id = $_POST['server_id'];
$dn = rawurldecode( $_POST['dn'] );
$encoded_dn = rawurlencode( $dn );
$attr = $_POST['attr'];
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
if( ! $attr ) pla_error( "No attribute name specified in POST variables" );
if( ! $dn ) pla_error( "No DN name specified in POST variables" );
$update_array = array();
$update_array[$attr] = array();
$ds = pla_ldap_connect( $server_id );
$res = @ldap_modify( $ds, $dn, $update_array );
if( $res )
{
$redirect_url = "edit.php?server_id=$server_id&dn=$encoded_dn";
foreach( $update_array as $attr => $junk )
$redirect_url .= "&modified_attrs[]=$attr";
header( "Location: $redirect_url" );
}
else
{
pla_error( "Could not perform ldap_modify operation.", ldap_error( $ds ), ldap_errno( $ds ) );
}
?>

View File

@@ -1,159 +0,0 @@
<?php
/*
* delete_form.php
* Displays a last chance confirmation form to delete a dn.
*
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - server_id
*/
require 'common.php';
$dn = $_GET['dn'];
$encoded_dn = rawurlencode( $dn );
$server_id = $_GET['server_id'];
$rdn = pla_explode_dn( $dn );
$rdn = $rdn[0];
$server_name = $servers[$server_id]['name'];
if( is_server_read_only( $server_id ) )
pla_error( "You cannot perform updates while server is in read-only mode" );
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
$children = get_container_contents( $server_id, $dn );
$has_children = count($children)>0 ? true : false;
?>
<?php include 'header.php'; ?>
<body>
<h3 class="title">Delete <b><?php echo htmlspecialchars( utf8_decode( $rdn ) ); ?></b></h3>
<h3 class="subtitle">Server: <b><?php echo $server_name; ?></b> &nbsp;&nbsp;&nbsp; Distinguished Name: <b><?php echo htmlspecialchars( utf8_decode( $dn ) ); ?></b></h3>
<?php if( 0 == strcasecmp( $dn, $servers[$server_id]['base'] ) ) { ?>
<center><b>You cannot delete the base <acronym title="Distinguished Name">DN</acronym> entry of the LDAP server.</b></center>
</body>
</html>
<?php exit; ?>
<?php } ?>
<?php if( $has_children ) { ?>
<center><b>Permanently delete all children also?</b><br /><br />
<?php
flush(); // so the user can get something on their screen while we figure out how many children this object has
if( $has_children ) {
// get the total number of child objects (whole sub-tree)
$s = pla_ldap_search( $server_id, 'objectClass=*', $dn, array('dn'), 'sub' );
$sub_tree_count = count( $s );
}
?>
<table class="delete_confirm">
<td>
<p>This object is the root of a sub-tree containing <a href="search.php?search=true&amp;server_id=<?php echo $server_id; ?>&amp;filter=<?php echo rawurlencode('objectClass=*'); ?>&amp;base_dn=<?php echo $encoded_dn; ?>&amp;form=advanced&amp;scope=sub"><?php echo ($sub_tree_count); ?> objects</a>
phpLDAPadmin can recursively delete this object and all <?php echo ($sub_tree_count-1); ?> of its children. See below for a list of DNs
that this will delete. Do you want to do this?<br />
<br />
<small>Note: This is potentially very dangerous and you do this at your own risk. This operation cannot be undone.
Take into consideration aliases and other such things that may cause problems.</small>
<br />
<br />
<table width="100%">
<tr>
<td>
<center>
<form action="rdelete.php" method="post">
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="submit" class="scary" value="Delete all <?php echo ($sub_tree_count); ?> objects" />
</form>
</td>
<td>
<center>
<form action="edit.php" method="get">
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="submit" name="submit" value="Cancel" class="cancel" />
</form>
</center>
</td>
</tr>
</table>
</td>
</table>
<?php flush(); ?>
<br />
<br />
A list of all the <?php echo ($sub_tree_count); ?> <acronym title="Distinguished Name">DN</acronym>s that this action will delete:<br />
<select size="<?php echo min( 10, $sub_tree_count );?>" multiple disabled style="background:white; color:black;width:500px" >
<?php $i=0; ?>
<?php foreach( $s as $dn => $junk ) { ?>
<?php $i++; ?>
<option><?php echo $i; ?>. <?php echo htmlspecialchars( utf8_decode( $dn ) ); ?></option>
<?php } ?>
</select>
<br />
<?php } else { ?>
<center>
<table class="delete_confirm">
<td>
Are you sure you want to permanently delete this object?<br />
<br />
<nobr><acronym title="Distinguished Name">DN</acronym>: <b><?php echo htmlspecialchars(utf8_decode($dn)); ?></b><nobr><br />
<nobr>Server: <b><?php echo htmlspecialchars($server_name); ?></b></nobr><br />
<br />
<table width="100%">
<tr>
<td>
<center>
<form action="delete.php" method="post">
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="submit" name="submit" value="Delete It" class="scary" />
</center>
</form>
</td>
<td>
<center>
<form action="edit.php" method="get">
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="submit" name="submit" value="Cancel" class="cancel" />
</form>
</center>
</td>
</tr>
</table>
</td>
</table>
</center>
<?php } ?>
</body>
</html>

View File

@@ -0,0 +1,2 @@
Please see http://wiki.phpldapadmin.info/Translating now for information on
translating PLA.

67
doc/pla-test-i18n.ldif Normal file
View File

@@ -0,0 +1,67 @@
# $Header: /cvsroot/phpldapadmin/phpldapadmin/doc/pla-test-i18n.ldif,v 1.4 2004/03/19 20:22:54 i18phpldapadmin Exp $
# This is a Test-File for characters / encoding
# 1. Change the
# ,dc=example,dc=com
# to avalue for your organisation
# 2. Import it with phpldapadmin
#
# pla-i18n, example.com
#
dn: ou=pla-i18n,dc=example,dc=com
ou: pla-i18n
objectClass: top
objectClass: organizationalUnit
# pl, pla-i18n, example.com
dn: ou=pl,ou=pla-i18n,dc=example,dc=com
description:: IGRvcMOza2k=
description:: xITFu8WaxbnEhsWDxYHDk8SYIMSFxbzFm8W6xIfFhMWCw7PEmQ==
description:: V3NrYXrDs3drYQ==
objectClass: top
objectClass: organizationalUnit
ou: pl
# ru, pla-i18n, example.com
dn: ou=ru,ou=pla-i18n,dc=example,dc=com
description:: 0LfQstGD0YfQuNGCINC/0L7QtNC+0LHQvdC+
description:: 0J/RgNC+0YHRgtCw0Y8g0YTQvtGA0LzQsCDQv9C+0LjRgdC6
objectClass: top
objectClass: organizationalUnit
ou: ru
# jp, pla-i18n, example.com
dn: ou=jp,ou=pla-i18n,dc=example,dc=com
ou: jp
objectClass: top
objectClass: organizationalUnit
description:: SVNPLTIwMjItSlDjga7lpJrlm73nsY3oqIDoqp7jgbjjga7mi6HlvLXmgKc=
# pt-br, pla-i18n, example.com
dn: ou=pt-br,ou=pla-i18n,dc=example,dc=com
ou: pt-br
objectClass: top
objectClass: organizationalUnit
description:: VmVyIGFzIHJlcXVpc2nDp8O1ZXMgZW0gYWJlcnRv
# de, pla-i18n, example.com
dn: ou=de,ou=pla-i18n,dc=example,dc=com
ou: de
objectClass: top
objectClass: organizationalUnit
description:: U29uZGVyemVpY2hlbiDDtsOkw7zDnyDDlsOEw5w=
description:: w5bDliDDnMOcIMOEw4Q=
# sv, pla-i18n, example.com
dn: ou=sv,ou=pla-i18n,dc=example,dc=com
ou: sv
objectClass: top
objectClass: organizationalUnit
description:: U8O2a29tZsOlbmc=
description:: bMOldGVyIHNvbQ==
# ca, pla-i18n, example.com
dn: ou=ca,ou=pla-i18n,dc=example,dc=com
ou: ca
objectClass: top
objectClass: organizationalUnit
description:: RXMgdGluZHLDoSBxdWUgY29uZmlybWFyIGFxdWVzdGEgZGVjaXNpw7M=

View File

@@ -1,28 +0,0 @@
<?php
require 'common.php';
$server_id = $_GET['server_id'];
$dn = rawurldecode( $_GET['dn'] );
$attr = $_GET['attr'];
// if there are multiple values in this attribute, which one do you want to see?
$value_num = isset( $_GET['value_num'] ) ? $_GET['value_num'] : 0;
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
$ds = pla_ldap_connect( $server_id ) or pla_error( "Coult not connect to LDAP server." );
$search = ldap_read( $ds, $dn, "(objectClass=*)", array( $attr ), 0, 200, 0, LDAP_DEREF_ALWAYS );
$entry = ldap_first_entry( $ds, $search );
$attrs = ldap_get_attributes( $ds, $entry );
$attr = ldap_first_attribute( $ds, $entry, $attrs );
$values = ldap_get_values_len( $ds, $entry, $attr );
$count = $values['count'];
unset( $values['count'] );
Header( "Content-type: octet-stream" );
Header( "Content-disposition: attachment; filename=$attr" );
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
echo $values[$value_num];
?>

613
edit.php
View File

@@ -1,613 +0,0 @@
<?php
/*
* edit.php
* Displays the specified dn from the specified server for editing
*
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - server_id
* - modified_attrs (optional) an array of attributes to highlight as
* they were changed by the last operation
*/
/** If an entry has more children than this, stop searching and display this amount with a '+' */
$max_children = 100;
require 'common.php';
$dn= $_GET['dn'];
$decoded_dn = rawurldecode( $dn );
$encoded_dn = rawurlencode( $decoded_dn );
$modified_attrs = isset( $_GET['modified_attrs'] ) ? $_GET['modified_attrs'] : false;
$server_id = $_GET['server_id'];
$show_internal_attrs = isset( $_GET['show_internal_attrs'] ) ? true : false;
$rdn = pla_explode_dn( $dn );
$rdn = $rdn[0];
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
pla_ldap_connect( $server_id ) or pla_error( "Coult not connect to LDAP server." );
$friendly_attrs = process_friendly_attr_table();
$attrs = get_object_attrs( $server_id, $dn );
pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
$system_attrs = get_entry_system_attrs( $server_id, $dn );
if( ! $attrs )
pla_error( "No such dn, " . htmlspecialchars( utf8_decode( $dn ) ) );
$server_name = $servers[$server_id]['name'];
// build a list of attributes available for this object based on its objectClasses
$oclasses = get_object_attr( $server_id, $dn, 'objectClass' );
if( ! is_array( $oclasses ) )
$oclasses = array( $oclasses );
$avail_attrs = array();
$schema_oclasses = get_schema_objectclasses( $server_id, true );
$schema_attrs = get_schema_attributes( $server_id );
foreach( $oclasses as $oclass ) {
$avail_attrs = array_merge(
$schema_oclasses[ strtolower( $oclass ) ]['must_attrs'],
$schema_oclasses[ strtolower( $oclass ) ]['may_attrs'],
$avail_attrs );
}
$avail_attrs = array_unique( $avail_attrs );
$avail_attrs = array_filter( $avail_attrs, "not_an_attr" );
sort( $avail_attrs );
$avail_binary_attrs = array();
foreach( $avail_attrs as $i => $attr ) {
if( is_attr_binary( $server_id, $attr ) ) {
$avail_binary_attrs[] = $attr;
unset( $avail_attrs[ $i ] );
}
}
?>
<?php include 'header.php'; ?>
<body>
<h3 class="title"><?php echo htmlspecialchars( utf8_decode( $rdn ) ); ?></h3>
<h3 class="subtitle">Server: <b><?php echo $server_name; ?></b> &nbsp;&nbsp;&nbsp; Distinguished Name: <b><?php echo htmlspecialchars( utf8_decode( $dn ) ); ?></b></h3>
<table class="edit_dn_menu">
<tr>
<?php $time = gettimeofday(); $random_junk = md5( strtotime( 'now' ) . $time['usec'] ); ?>
<td><img src="images/refresh.png" /></td>
<td><a href="edit.php?server_id=<?php echo $server_id; ?>&amp;dn=<?php echo $encoded_dn; ?>&amp;random=<?php
echo $random_junk; ?>"
title="<?php echo $lang['refresh_this_entry']; ?>"><?php echo $lang['refresh']; ?></a></td>
</tr>
<?php if( ! is_server_read_only( $server_id ) && 0 != strcasecmp( $dn, $servers[$server_id]['base'] ) ) { ?>
<?php /* We won't allow them to delete the base dn of the server */ ?>
<tr>
<td><img src="images/trash.png" /></td>
<td><a href="delete_form.php?server_id=<?php echo $server_id; ?>&amp;dn=<?php echo $encoded_dn; ?>"
title="<?php echo $lang['delete_this_entry_tooltip']; ?>"><?php echo $lang['delete_this_entry']; ?></a></td>
</tr>
<?php } ?>
<tr>
<td><img src="images/cut.png" /></td>
<td><a href="copy_form.php?server_id=<?php echo $server_id; ?>&amp;dn=<?php echo $encoded_dn?>"
title="<?php echo $lang['copy_this_entry_tooltip']; ?>"><?php echo $lang['copy_this_entry']; ?></a></td>
</tr>
<tr>
<td><img src="images/save.png" /></td>
<?php $ldif_url = "ldif_export.php?server_id=$server_id&amp;dn=$encoded_dn&amp;scope=base"; ?>
<td><a href="<?php echo $ldif_url; ?>" title="<?php echo $lang['export_to_ldif_tooltip']; ?>"><?php echo $lang['export_to_ldif']; ?></a>
(<a href="<?php echo $ldif_url; ?>&amp;format=mac"
title="<?php echo $lang['export_to_ldif_mac']; ?>">mac</a>)
(<a href="<?php echo $ldif_url; ?>&amp;format=win"
title="<?php echo $lang['export_to_ldif_win']; ?>">win</a>)
(<a href="<?php echo $ldif_url; ?>&amp;format=unix"
title="<?php echo $lang['export_to_ldif_unix']; ?>">unix</a>)
</td>
</tr>
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<tr>
<td><img src="images/star.png" /></td>
<td><a href="<?php echo "create_form.php?server_id=$server_id&amp;container=$encoded_dn"; ?>"><?php echo $lang['create_a_child_entry']; ?></a></td>
</tr>
<?php } ?>
<?php flush(); ?>
<?php $children = get_container_contents( $server_id, $dn, $max_children );
if( ($children_count = count( $children ) ) > 0 ) {
if( $children_count == $max_children )
$children_count = $children_count . '+';
?>
<tr>
<td><img src="images/children.png" /></td>
<td><a href="search.php?search=true&amp;server_id=<?php echo $server_id; ?>&amp;filter=<?php echo rawurlencode('objectClass=*'); ?>&amp;base_dn=<?php echo $encoded_dn; ?>&amp;form=advanced&amp;scope=one"><?php echo $lang['view']; ?> <?php echo $children_count; ?> <?php echo ($children_count==1?'child':'children');?></a></td>
</tr>
<?php } ?>
<?php if( $children_count > 0 ) { ?>
<tr>
<td><img src="images/save.png" /></td>
<?php $ldif_url = "ldif_export.php?server_id=$server_id&amp;dn=$encoded_dn&amp;scope=sub"; ?>
<td><a href="<?php echo $ldif_url; ?>"
title="<?php echo $lang['export_subtree_to_ldif_tooltip']; ?>"><?php echo $lang['export_subtree_to_ldif']; ?></a>
(<a href="<?php echo $ldif_url; ?>&amp;format=mac" title="<?php echo $lang['export_to_ldif_mac'];?>">mac</a>)
(<a href="<?php echo $ldif_url; ?>&amp;format=win" title="<?php echo $lang['export_to_ldif_win'];?>">win</a>)
(<a href="<?php echo $ldif_url; ?>&amp;format=unix" title="<?php echo $lang['export_to_ldif_unix'];?>">unix</a>)
</td>
</tr>
<?php } ?>
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<tr>
<td><img src="images/light.png" /></td>
<td><?php echo $lang['delete_hint']; ?></td>
</tr>
<?php } ?>
<?php if( is_server_read_only( $server_id ) ) { ?>
<tr>
<td><img src="images/light.png" /></td>
<td><?php echo $lang['viewing_read_only']; ?></td>
</tr>
<?php } ?>
</table>
<br />
<table class="edit_dn" cellspacing="0">
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<!-- Form to rename this entry -->
<tr class="row1">
<td class="heading"><acronym title="<?php echo $lang['change_entry_rdn']; ?> "><?php echo $lang['rename_entry']; ?></acronym></td>
<td class="heading" align="right">
<nobr>
<form action="rename.php" method="post" class="edit_dn" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="text" name="new_rdn" size="30" value="<?php echo htmlspecialchars( utf8_decode( $rdn ) ); ?>" />
<input class="update_dn" type="submit" value="<?php echo $lang['rename']; ?>" />
</form>
</nobr>
</td>
<?php } ?>
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<!-- Form to add a new attribute to this entry -->
<tr class="spacer"><td colspan="2"></td></tr>
<form action="new_attr.php" method="post">
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<tr class="row1">
<td class="heading">
<nobr>
<acronym title="<?php echo $lang['add_new_attribute_tooltip']; ?>"><?php echo $lang['add_new_attribute']; ?></acronym>
</nobr>
</td>
<td class="heading" align="right"><nobr>
<?php if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
<select name="attr">
<?php foreach( $avail_attrs as $a ) {
// is there a user-friendly translation available for this attribute?
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
htmlspecialchars($a) . ")";
} else {
$attr_display = htmlspecialchars( $a );
}
echo $attr_display;
$attr_select_html .= "<option>$attr_display</option>\n";
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
} ?>
</select>
<input type="text" name="val" size="20" />
<input type="submit" name="submit" value="<?php echo $lang['add']; ?>" class="update_dn" />
<?php } else { ?>
<small>(<?php echo $lang['no_new_attrs_available']; ?>)</small>
<?php } ?>
</nobr></td>
</form>
</tr>
<?php } ?>
<?php flush(); ?>
<?php if( ! is_server_read_only( $server_id ) && count( $avail_binary_attrs ) > 0 ) { ?>
<!-- Form to add a new BINARY attribute to this entry -->
<tr class="spacer"><td colspan="2"></td></tr>
<form action="new_attr.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="binary" value="true" />
<tr class="row1">
<td class="heading">
<nobr>
<acronym title="<?php echo $lang['add_new_binary_attr_tooltip']; ?>">
<?php echo $lang['add_new_binary_attr']; ?></acronym>
</nobr>
</td>
<td class="heading" align="right"><nobr>
<select name="attr">
<?php foreach( $avail_binary_attrs as $a ) {
// is there a user-friendly translation available for this attribute?
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
htmlspecialchars($a) . ")";
} else {
$attr_display = htmlspecialchars( $a );
}
echo $attr_display;
$attr_select_html .= "<option>$attr_display</option>\n";
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
} ?>
</select>
<input type="file" name="val" size="20" />
<input type="submit" name="submit" value="<?php echo $lang['add']; ?>" class="update_dn" />
</nobr></td>
</form>
</tr>
<?php } ?>
<tr class="spacer"><td colspan="2"></td></tr>
<tr class="row1">
<td class="heading" colspan="2">
<nobr>
<?php if( $show_internal_attrs ) { ?>
<a href="edit.php?server_id=<?php echo $server_id; ?>&amp;dn=<?php echo $encoded_dn; ?>"
><img src="images/minus.png" title="<?php echo $lang['hide_internal_attrs']; ?>" /></a>
<acronym title="<?php echo $lang['internal_attrs_tooltip'];?>"><?php echo $lang['internal_attributes']; ?></acronym>
<?php } else { ?>
<a href="edit.php?server_id=<?php echo $server_id; ?>&amp;dn=<?php echo $encoded_dn; ?>&amp;show_internal_attrs=true">
<img src="images/plus.png" title="<?php echo $lang['show_internal_attrs']; ?>" /></a>
<acronym title="<?php echo $lang['internal_attrs_tooltip']; ?> (<?php echo $lang['click_to_display']; ?>)"><?php echo $lang['internal_attributes']; ?></acronym>
<small>(<?php echo $lang['hidden']; ?>)</small>
<?php } ?>
</nobr>
</td>
</tr>
<?php
if( $show_internal_attrs ) {
$counter = 0;
foreach( get_entry_system_attrs( $server_id, $dn ) as $attr => $vals ) {
$counter++
?>
<tr class="<?php echo ($counter%2==0?'row1':'row2');?>">
<td class="attr"><b><?php echo htmlspecialchars( $attr ); ?></b></td>
<td class="val">
<?php foreach( $vals as $v ) {?>
<?php echo htmlspecialchars( $v ); ?><br />
<?php } ?>
</td>
</tr>
<?php }
if( $counter == 0 )
echo "<tr class=\"row2\"><td colspan=\"2\"><center>(" . $lang['none'] . ")</center></td></tr>\n";
}
?>
<?php flush(); ?>
<tr class="spacer"><td colspan="2"></td></tr>
<!-- Table of attributes/values to edit -->
<tr class="row1">
<td class="heading" colspan="2">
<nobr><?php echo $lang['entry_attributes']; ?></nobr>
</td>
</tr>
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<form action="update_confirm.php" method="post">
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $dn; ?>" />
<?php } ?>
<?php $counter=0; ?>
<?php /* Prepare the hidden_attrs array by lower-casing it. */
if( isset( $hidden_attrs ) && is_array( $hidden_attrs ) && count( $hidden_attrs ) > 0 )
foreach( $hidden_attrs as $i => $attr_name )
$hidden_attrs[$i] = strtolower( $attr_name );
else
$hidden_attrs = array();
?>
<?php foreach( $attrs as $attr => $vals ) {
if( isset( $schema_attrs[ strtolower($attr) ] ) )
$attr_syntax = $schema_attrs[ strtolower( $attr ) ]->getSyntaxOID();
flush();
if( 0 == strcasecmp( $attr, 'dn' ) )
continue;
// has the config.php specified that this attribute is to be hidden?
if( in_array( strtolower( $attr ), $hidden_attrs ) )
continue;
// is there a user-friendly translation available for this attribute?
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) {
$attr_display = "<acronym title=\"" . $lang['alias_for'] . "$attr\">" .
$friendly_attrs[ strtolower( $attr ) ] . "</acronym>";
} else {
$attr_display = $attr;
}
?>
<?php if( is_array( $modified_attrs ) && in_array( $attr, $modified_attrs ) ) { ?>
<tr class="updated_attr">
<?php } else { ?>
<?php if( $counter++ % 2 == 0 ) { ?>
<tr class="row2">
<?php } else { ?>
<tr class="row1">
<?php } ?>
<?php } ?>
<?php
if( ! is_server_read_only( $server_id ) ) {
$add_href = "add_value_form.php?server_id=$server_id&amp;dn=$encoded_dn&amp;attr=" . rawurlencode( $attr );
} ?>
<td class="attr">
<b><?php echo $attr_display; ?></b><br />
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<small>(<a href="<?php echo $add_href; ?>"
title="<?php echo $lang['add_value_tooltip']; ?>"><?php echo $lang['add_value']; ?></a>)</small>
<?php } ?>
</td>
<td class="val">
<?php
/*
* Is this attribute a jpegPhoto?
*/
if( is_jpeg_photo( $server_id, $attr ) ) {
// Don't draw the delete buttons if there is more than one jpegPhoto
// (phpLDAPadmin can't handle this case yet)
if( is_server_read_only( $server_id ) )
draw_jpeg_photos( $server_id, $dn, false );
else
draw_jpeg_photos( $server_id, $dn, true );
// proceed to the next attribute
continue;
}
/*
* Is this attribute binary?
*/
if( is_attr_binary( $server_id, $attr ) ) {
$href = "download_binary_attr.php?server_id=$server_id&amp;dn=$encoded_dn&amp;attr=$attr";
?>
<small>
<?php echo $lang['binary_value']; ?><br />
<?php if( count( $vals ) > 1 ) { for( $i=1; $i<=count($vals); $i++ ) { ?>
<a href="<?php echo $href . "&amp;value_num=$i"; ?>"><img
src="images/save.png" /> <?php echo $lang['download_value']; ?>(<?php echo $i; ?>)</a><br />
<?php } } else { ?>
<a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value']; ?></a><br />
<?php } ?>
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<a href="javascript:deleteAttribute( '<?php echo $attr; ?>' );"
style="color:red;"><img src="images/trash.png" /> <?php echo $lang['delete_attribute']; ?></a>
<?php } ?>
</small>
</td>
<?php continue;
}
/*
* Note: at this point, the attribute must be text-based (not binary or jpeg)
*/
/*
* If we are in read-only mode, simply draw the attribute values and continue.
*/
if( is_server_read_only( $server_id ) ) {
if( is_array( $vals ) ) {
foreach( $vals as $i => $val ) {
$val = utf8_decode( $val );
echo $val . "<br />";
}
} else {
echo utf8_decode( $vals ) . "<br />";
}
continue;
}
/*
* Is this a userPassword attribute?
*/
if( 0 == strcasecmp( $attr, 'userpassword' ) ) {
$user_password = $vals[0];
/* Capture the stuff in the { } to determine if this is crypt, md5, etc. */
preg_match( "/{([^}]+)}/", $user_password, $enc_type);
$enc_type = strtolower($enc_type[1]);
// Set the default hashing type if the password is blank (must be newly created)
if( $val == '' ) {
$enc_type = $servers[$server_id]['default_hash'];
} ?>
<?php /* handle crypt types */
if($enc_type == "crypt") {
preg_match( "/{[^}]+}\\$(.)\\$/", $user_password, $salt);
switch( $salt[1] ) {
case '': // CRYPT_STD_DES
$enc_type = "crypt";
break;
case '1': // CRYPT_MD5
$enc_type = "md5crypt";
break;
case '2': // CRYPT_BLOWFISH
$enc_type = "blowfish";
break;
default:
$enc_type = "crypt";
}
} ?>
<input type="hidden"
name="old_values[userpassword]"
value="<?php echo htmlspecialchars($user_password); ?>" />
<!-- Special case of enc_type to detect changes when user changes enc_type but not the password value -->
<input size="38"
type="hidden"
name="old_enc_type"
value="<?php echo ($enc_type==''?'clear':$enc_type); ?>" />
<input size="38"
type="text"
name="new_values[userpassword]"
value="<?php echo htmlspecialchars($user_password); ?>" />
<select name="enc_type">
<option>clear</option>
<option<?php echo $enc_type=='crypt'?' selected':''; ?>>crypt</option>
<option<?php echo $enc_type=='md5'?' selected':''; ?>>md5</option>
<option<?php echo $enc_type=='md5crypt'?' selected':''; ?>>md5crypt</option>
<option<?php echo $enc_type=='blowfish'?' selected':''; ?>>blowfish</option>
<option<?php echo $enc_type=='sha'?' selected':''; ?>>sha</option>
</select>
<?php continue;
}
/*
* Is this a boolean attribute?
*/
if( 0 == strcasecmp( 'boolean', $schema_attrs[ strtolower($attr) ]->getType() ) ) {
$val = $vals[0];
?>
<input type="hidden"
name="old_values[<?php echo htmlspecialchars( $attr ); ?>]"
value="<?php echo htmlspecialchars($val); ?>" />
<select name="new_values[<?php echo htmlspecialchars( $attr ); ?>]">
<option value="TRUE"<?php echo ($val=='TRUE' ? ' selected' : ''); ?>>
<?php echo $lang['true']; ?></option>
<option value="FALSE"<?php echo ($val=='FALSE' ? ' selected' : ''); ?>>
<?php echo $lang['false']; ?></option>
<option value="">(<?php echo $lang['none_remove_value']; ?>)</option>
</select>
<?php
continue;
}
/*
* End of special case attributes.
*/
/*
* This is a normal attribute, to be displayed and edited in plain text.
*/
foreach( $vals as $i => $val ) {
$val = utf8_decode( $val ); ?>
<nobr>
<!-- The old_values array will let update.php know if the entry contents changed
between the time the user loaded this page and saved their changes. -->
<input type="hidden"
name="old_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
value="<?php echo htmlspecialchars($val); ?>" />
<?php if( $attr_syntax == '1.3.6.1.4.1.1466.115.121.1.40' ) { ?>
<textarea
cols="37" rows="3"
name="new_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
><?php echo htmlspecialchars($val); ?></textarea><br />
<?php } else { ?>
<input type="text"
size="50"
name="new_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
value="<?php echo htmlspecialchars($val); ?>" /></nobr><br />
<?php } ?>
<?php } /* end foreach value */ ?>
</td>
</tr>
<?php } /* End foreach( $attrs as $attr => $vals ) */ ?>
<?php if( ! is_server_read_only( $server_id ) ) { ?>
<tr><td colspan="2"><center><input type="submit" value="<?php echo $lang['save_changes']; ?>" /></center></form></td></tr>
<?php } ?>
<?php
?>
</table>
<?php /* If this entry has a binary attribute, we need to provide a form for it to submit when deleting it. */ ?>
<script language="javascript">
//<!--
function deleteAttribute( attrName )
{
if( confirm( "<?php echo $lang['really_delete_attribute']; ?> '" + attrName + "'?" ) ) {
document.delete_attribute_form.attr.value = attrName;
document.delete_attribute_form.submit();
}
}
//-->
</script>
<!-- This form is submitted by JavaScript when the user clicks "Delete attribute" on a binary attribute -->
<form name="delete_attribute_form" action="delete_attr.php" method="post">
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="attr" value="FILLED IN BY JAVASCRIPT" />
</form>
<?php
/**
* Given an attribute $x, this returns true if it is NOT already specified
* in the current entry, returns false otherwise.
*/
function not_an_attr( $x )
{
global $attrs;
//return ! isset( $attrs[ strtolower( $x ) ] );
foreach( $attrs as $attr => $values )
if( 0 == strcasecmp( $attr, $x ) )
return false;
return true;
}
?>

View File

@@ -1,97 +0,0 @@
<?php
require 'common.php';
$container = isset( $_GET['container'] ) ? rawurldecode( $_GET['container'] ) : false;
$server_id = isset( $_GET['server_id'] ) ? $_GET['server_id'] : false;
$return_form_element = $_GET['form_element'];
include "header.php";
echo "<h3 class=\"subtitle\">Automagic Entry Chooser</h3>\n";
if( $container ) {
echo "Server: <b>" . htmlspecialchars( $servers[ $server_id ][ 'name' ] ) . "</b><br />\n";
echo "Looking in: <b>" . htmlspecialchars( $container ) . "</b><br />\n";
}
/* Has the use already begun to descend into a specific server tree? */
if( $server_id !== false && $container !== false )
{
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. ".
"Please check your configuration." );
pla_ldap_connect( $server_id ) or pla_error( "Coult not connect to LDAP server." );
$dn_list = get_container_contents( $server_id, $container );
$base_dn = $servers[ $server_id ][ 'base' ];
if( ! $base_dn )
$base_dn = try_to_get_root_dn( $server_id );
if( $container == $base_dn ) {
$parent_container = false;
$up_href = "entry_chooser.php?form_element=$return_form_element";
} else {
$parent_container = get_container( $container );
$up_href = "entry_chooser.php?form_element=$return_form_element&amp;server_id=$server_id&amp;container=" .
rawurlencode( $parent_container );
}
echo "&nbsp;<a href=\"$up_href\" style=\"text-decoration:none\">" .
"<img src=\"images/up.png\"> Back Up...</a><br />\n";
if( count( $dn_list ) == 0 )
echo "&nbsp;&nbsp;&nbsp;(no entries)<br />\n";
else
foreach( $dn_list as $dn ) {
$href = "javascript:returnDN( '$dn' )";
echo "&nbsp;&nbsp;&nbsp;<a href=\"entry_chooser.php?form_element=$return_form_element".
"&amp;server_id=$server_id&amp;container=" .
rawurlencode( $dn ) . "\"><img src=\"images/plus.png\" /></a> " .
"<a href=\"$href\">" . htmlspecialchars( $dn ) . "</a><br />\n";
}
}
/* draw the root of the selection tree (ie, list all the servers) */
else
{
foreach( $servers as $id => $server ) {
if( $server['host'] ) {
echo "<b>" . htmlspecialchars( $server['name'] ) . "</b><br />\n";
if( ! have_auth_info( $id ) )
echo "<small>&nbsp;&nbsp;&nbsp;(Not logged in)</small><br />";
else {
$dn = ( $server['base'] ? $server['base'] : try_to_get_root_dn( $id ) );
if( ! $dn ) {
echo "<small>&nbsp;&nbsp;&nbsp;(Could not determine base DN)</small><br />";
} else {
$href = "javascript:returnDN( '$dn' )";
echo "&nbsp;&nbsp;&nbsp;<a href=\"entry_chooser.php?form_element=" .
"$return_form_element&amp;server_id=$id&amp;container=" .
rawurlencode( $dn ) . "\"><img src=\"images/plus.png\" /></a> " .
"<a href=\"$href\">" . htmlspecialchars( $dn ) . "</a><br />\n";
}
}
}
}
}
// 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 . "\"]";
?>
<script language="javascript">
function returnDN( dn )
{
opener.document.<?php echo $return_form_element; ?>.value = dn;
close();
}
</script>

View File

@@ -1,71 +0,0 @@
<?php
/*
* expand.php
* This script alters the session variable 'tree', expanding it
* at the dn specified in the query string.
*
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - server_id
*
* Note: this script is equal and opposite to collapse.php
*/
require 'common.php';
// no expire header stuff
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$dn = $_GET['dn'];
$encoded_dn = rawurlencode( $dn );
$server_id = $_GET['server_id'];
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
session_start();
// dave commented this out since it was being triggered without reason in rare cases
//session_is_registered( 'tree' ) or pla_error( "Your session tree is not registered. That's weird. Should never happen".
// ". Just go back and it should be fixed automagically." );
$tree = $_SESSION['tree'];
$tree_icons = $_SESSION['tree_icons'];
pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
$contents = get_container_contents( $server_id, $dn );
//echo "<pre>";
//var_dump( $contents );
//exit;
sort( $contents );
$tree[$server_id][$dn] = $contents;
foreach( $contents as $dn )
$tree_icons[$server_id][$dn] = get_icon( $server_id, $dn );
$_SESSION['tree'] = $tree;
$_SESSION['tree_icons'] = $tree_icons;
session_write_close();
// This is for Opera. By putting "random junk" in the query string, it thinks
// that it does not have a cached version of the page, and will thus
// fetch the page rather than display the cached version
$time = gettimeofday();
$random_junk = md5( strtotime( 'now' ) . $time['usec'] );
// If cookies were disabled, build the url parameter for the session id.
// It will be append to the url to be redirect
$id_session_param="";
if(SID != ""){
$id_session_param = "&".session_name()."=".session_id();
}
header( "Location:tree.php?foo=$random_junk%23{$server_id}_{$encoded_dn}$id_session_param" );
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +0,0 @@
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="no-NO">
<head>
<title>phpLDAPadmin</title>
<link rel="stylesheet" href="style.css" />
<script src="entry_chooser.js"></script>
<script src="search_util.js"></script>
</head>

167
htdocs/add_attr.php Normal file
View File

@@ -0,0 +1,167 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr.php,v 1.18.2.7 2005/12/09 23:32:37 wurley Exp $
/**
* Adds an attribute/value pair to an object
*
* Variables that come in via common.php
* - server_id
* Variables that come in as POST vars:
* - dn
* - attr
* - val
* - binary
*
* @package phpLDAPadmin
* @todo: For boolean attributes, convert the response to TRUE/FALSE.
*/
/**
*/
require './common.php';
if( $ldapserver->isReadOnly() )
pla_error( _('You cannot perform updates while server is in read-only mode') );
if( ! $ldapserver->haveAuthInfo())
pla_error( _('Not enough information to login to server. Please check your configuration.') );
$attr = $_POST['attr'];
$val = isset( $_POST['val'] ) ? $_POST['val'] : false;;
$dn = $_POST['dn'] ;
$is_binary_val = isset( $_POST['binary'] ) ? true : false;
$encoded_dn = rawurlencode( $dn );
$encoded_attr = rawurlencode( $attr );
if( ! $is_binary_val && $val == "" ) {
pla_error( _('You left the attribute value blank. Please go back and try again.') );
}
// special case for binary attributes (like jpegPhoto and userCertificate):
// we must go read the data from the file and override $val with the binary data
// Secondly, we must check if the ";binary" option has to be appended to the name
// of the attribute.
// Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($dn,$attr,array($val))) {
$search_href = sprintf('search.php?search=true&form=advanced&server_id=%s&filter=%s=%s',$ldapserver->server_id,$attr,$badattr);
pla_error(sprintf( _('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$attr,$badattr,$dn,$search_href ) );
}
if( $is_binary_val ) {
if( 0 == $_FILES['val']['size'] )
pla_error( _('The file you chose is either empty or does not exist. Please go back and try again.') );
if( ! is_uploaded_file( $_FILES['val']['tmp_name'] ) ) {
if( isset( $_FILES['val']['error'] ) )
switch($_FILES['val']['error']) {
case 0: //no error; possible file attack!
pla_error( _('Security error: The file being uploaded may be malicious.') );
break;
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
pla_error( _('The file you uploaded is too large. Please check php.ini, upload_max_size setting') );
break;
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive specified in the html form
pla_error( _('The file you uploaded is too large. Please check php.ini, upload_max_size setting') );
break;
case 3: //uploaded file was only partially uploaded
pla_error( _('The file you selected was only partially uploaded, likley due to a network error.') );
break;
case 4: //no file was uploaded
pla_error( _('You left the attribute value blank. Please go back and try again.') );
break;
default: //a default error, just in case! :)
pla_error( _('Security error: The file being uploaded may be malicious.') );
break;
}
else
pla_error( _('Security error: The file being uploaded may be malicious.') );
}
$file = $_FILES['val']['tmp_name'];
$f = fopen( $file, 'r' );
$binary_data = fread( $f, filesize( $file ) );
fclose( $f );
$val = $binary_data;
if( is_binary_option_required( $ldapserver, $attr ) )
$attr .= ";binary";
}
/* Automagically hash new userPassword attributes according to the
chosen in config.php. */
if( 0 == strcasecmp( $attr, 'userpassword' ) ) {
if (trim($ldapserver->default_hash) != '' ) {
$enc_type = $ldapserver->default_hash;
$val = password_hash( $val, $enc_type );
}
}
elseif (strcasecmp($attr,'sambaNTPassword') == 0) {
$sambapassword = new smbHash;
$val = $sambapassword->nthash($val);
}
elseif (strcasecmp($attr,'sambaLMPassword') == 0) {
$sambapassword = new smbHash;
$val = $sambapassword->lmhash($val);
}
$new_entry = array( $attr => $val );
$result = $ldapserver->attrModify($dn,$new_entry);
if ($result)
header(sprintf('Location: template_engine.php?server_id=%s&dn=%s&modified_attrs[]=%s',
$ldapserver->server_id,$encoded_dn,$encoded_attr));
else
pla_error( _('Failed to add the attribute.'),$ldapserver->error(),$ldapserver->errno() );
/**
* Check if we need to append the ;binary option to the name
* of some binary attribute
*
* @param object $ldapserver Server Object that the attribute is in.
* @param attr $attr Attribute to test to see if it requires ;binary added to it.
* @return bool
*/
function is_binary_option_required( $ldapserver, $attr ) {
// list of the binary attributes which need the ";binary" option
$binary_attributes_with_options = array(
// Superior: Ldapv3 Syntaxes (1.3.6.1.4.1.1466.115.121.1)
'1.3.6.1.4.1.1466.115.121.1.8' => "userCertificate",
'1.3.6.1.4.1.1466.115.121.1.8' => "caCertificate",
'1.3.6.1.4.1.1466.115.121.1.10' => "crossCertificatePair",
'1.3.6.1.4.1.1466.115.121.1.9' => "certificateRevocationList",
'1.3.6.1.4.1.1466.115.121.1.9' => "authorityRevocationList",
// Superior: Netscape Ldap attributes types (2.16.840.1.113730.3.1)
'2.16.840.1.113730.3.1.40' => "userSMIMECertificate"
);
// quick check by attr name (short circuits the schema check if possible)
//foreach( $binary_attributes_with_options as $oid => $name )
//if( 0 == strcasecmp( $attr, $name ) )
//return true;
$schema_attr = $ldapserver->getSchemaAttribute($attr);
if( ! $schema_attr )
return false;
$syntax = $schema_attr->getSyntaxOID();
if( isset( $binary_attributes_with_options[ $syntax ] ) )
return true;
return false;
}
?>

197
htdocs/add_attr_form.php Normal file
View File

@@ -0,0 +1,197 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr_form.php,v 1.13.2.2 2005/12/09 14:27:32 wurley Exp $
/**
* Displays a form for adding an attribute/value to an LDAP entry.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars:
* - dn (rawurlencoded)
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if( $ldapserver->isReadOnly() )
pla_error( _('You cannot perform updates while server is in read-only mode') );
if( ! $ldapserver->haveAuthInfo())
pla_error( _('Not enough information to login to server. Please check your configuration.') );
$dn = $_GET['dn'];
$encoded_dn = rawurlencode( $dn );
$rdn = get_rdn( $dn );
$friendly_attrs = process_friendly_attr_table();
include './header.php'; ?>
<body>
<h3 class="title"><?php echo sprintf( _('Add new attribute'), htmlspecialchars( $rdn ) ); ?></b></h3>
<h3 class="subtitle"><?php echo _('Server'); ?>: <b><?php echo $ldapserver->name; ?></b> &nbsp;&nbsp;&nbsp; <?php echo _('Distinguished Name'); ?>: <b><?php echo htmlspecialchars( ( $dn ) ); ?></b></h3>
<?php $attrs = $ldapserver->getDNAttrs($dn);
$oclasses = $ldapserver->getDNAttr($dn,'objectClass');
if( ! is_array( $oclasses ) )
$oclasses = array( $oclasses );
$avail_attrs = array();
$schema_oclasses = $ldapserver->SchemaObjectClasses($dn);
foreach( $oclasses as $oclass ) {
$schema_oclass = $ldapserver->getSchemaObjectClass($oclass,$dn);
if( $schema_oclass && 0 == strcasecmp( 'objectclass', get_class( $schema_oclass ) ) )
$avail_attrs = array_merge( $schema_oclass->getMustAttrNames( $schema_oclasses ),
$schema_oclass->getMayAttrNames( $schema_oclasses ),
$avail_attrs );
}
$avail_attrs = array_unique( $avail_attrs );
$avail_attrs = array_filter( $avail_attrs, "not_an_attr" );
sort( $avail_attrs );
$avail_binary_attrs = array();
foreach( $avail_attrs as $i => $attr ) {
if ($ldapserver->isAttrBinary($attr)) {
$avail_binary_attrs[] = $attr;
unset( $avail_attrs[ $i ] );
}
}
?>
<br />
<center>
<?php echo _('Add new attribute');
if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
<br />
<br />
<form action="add_attr.php" method="post">
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo htmlspecialchars($dn); ?>" />
<select name="attr">
<?php $attr_select_html = '';
usort($avail_attrs,"sortAttrs");
foreach( $avail_attrs as $a ) {
// is there a user-friendly translation available for this attribute?
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
htmlspecialchars($a) . ")";
} else {
$attr_display = htmlspecialchars( $a );
}
echo $attr_display;
$attr_select_html .= "<option>$attr_display</option>\n";
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
} ?>
</select>
<input type="text" name="val" size="20" />
<input type="submit" name="submit" value="<?php echo _('Add'); ?>" class="update_dn" />
</form>
<?php } else { ?>
<br />
<br />
<small>(<?php echo _('no new attributes available for this entry'); ?>)</small>
<br />
<br />
<?php } ?>
<?php echo _('Add new binary attribute');
if( count( $avail_binary_attrs ) > 0 ) { ?>
<!-- Form to add a new BINARY attribute to this entry -->
<form action="add_attr.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $dn; ?>" />
<input type="hidden" name="binary" value="true" />
<br />
<select name="attr">
<?php $attr_select_html = '';
usort($avail_binary_attrs,"sortAttrs");
foreach( $avail_binary_attrs as $a ) {
// is there a user-friendly translation available for this attribute?
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
htmlspecialchars($a) . ")";
} else {
$attr_display = htmlspecialchars( $a );
}
echo $attr_display;
$attr_select_html .= "<option>$attr_display</option>\n";
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
} ?>
</select>
<input type="file" name="val" size="20" />
<input type="submit" name="submit" value="<?php echo _('Add'); ?>" class="update_dn" />
<?php if( ! ini_get( 'file_uploads' ) )
echo "<br><small><b>" . _('Your PHP configuration has disabled file uploads. Please check php.ini before proceeding.') . "</b></small><br>";
else
echo "<br><small><b>" . sprintf( _('Maximum file size: %s'), ini_get( 'upload_max_filesize' ) ) . "</b></small><br>";
?>
</form>
<?php } else { ?>
<br />
<br />
<small>(<?php echo _('no new binary attributes available for this entry'); ?>)</small>
<?php } ?>
</center>
</body>
</html>
<?php
/**
* Given an attribute $x, this returns true if it is NOT already specified
* in the current entry, returns false otherwise.
*
* @param attr $x
* @return bool
* @ignore
*/
function not_an_attr( $x ) {
global $attrs;
//return ! isset( $attrs[ strtolower( $x ) ] );
foreach( $attrs as $attr => $values )
if( 0 == strcasecmp( $attr, $x ) )
return false;
return true;
}
?>

64
htdocs/add_oclass.php Normal file
View File

@@ -0,0 +1,64 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_oclass.php,v 1.17.2.5 2005/12/09 23:32:37 wurley Exp $
/**
* Adds an objectClass to the specified dn.
*
* Note, this does not do any schema violation checking. That is
* performed in add_oclass_form.php.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - new_oclass
* - new_attrs (array, if any)
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if( $ldapserver->isReadOnly() )
pla_error( _('You cannot perform updates while server is in read-only mode') );
if( ! $ldapserver->haveAuthInfo())
pla_error( _('Not enough information to login to server. Please check your configuration.') );
$dn = rawurldecode( $_POST['dn'] );
$new_oclass = unserialize( rawurldecode( $_POST['new_oclass'] ) );
$new_attrs = $_POST['new_attrs'];
$encoded_dn = rawurlencode( $dn );
if ($ldapserver->isAttrReadOnly('objectClass'))
pla_error( "ObjectClasses are flagged as read only in the phpLDAPadmin configuration." );
$new_entry = array();
$new_entry['objectClass'] = $new_oclass;
$new_attrs_entry = array();
$new_oclass_entry = array( 'objectClass' => $new_oclass );
if( is_array( $new_attrs ) && count( $new_attrs ) > 0 )
foreach( $new_attrs as $attr => $val ) {
// Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($dn,$attr,array($val))) {
$search_href = sprintf('search.php?search=true&form=advanced&server_id=%s&filter=%s=%s',
$ldapserver->server_id,$attr,$badattr);
pla_error(sprintf( _('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$attr,$badattr,$dn,$search_href ) );
}
$new_entry[ $attr ] = $val;
}
$add_res = $ldapserver->attrModify($dn,$new_entry);
if (! $add_res)
pla_error(_('Could not perform ldap_mod_add operation.'),$ldapserver->error(),$ldapserver->errno());
else
header(sprintf('Location: template_engine.php?server_id=%s&dn=%s&modified_attrs[]=objectclass',$ldapserver->server_id,$encoded_dn));
?>

137
htdocs/add_oclass_form.php Normal file
View File

@@ -0,0 +1,137 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_oclass_form.php,v 1.23.2.6 2005/12/09 23:32:37 wurley Exp $
/**
* This page may simply add the objectClass and take you back to the edit page,
* but, in one condition it may prompt the user for input. That condition is this:
*
* If the user has requested to add an objectClass that requires a set of
* attributes with 1 or more not defined by the object. In that case, we will
* present a form for the user to add those attributes to the object.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as REQUEST vars:
* - dn (rawurlencoded)
* - new_oclass
*
* @package phpLDAPadmin
* @todo If an attribute expects a DN, show the dn browser.
*/
/**
*/
require './common.php';
if( $ldapserver->isReadOnly() )
pla_error( _('You cannot perform updates while server is in read-only mode') );
if( ! $ldapserver->haveAuthInfo())
pla_error( _('Not enough information to login to server. Please check your configuration.') );
if (! isset($_REQUEST['new_oclass']))
pla_error( _('You did not select any ObjectClasses for this object. Please go back and do so.'));
$new_oclass = $_REQUEST['new_oclass'];
$dn = rawurldecode( $_REQUEST['dn'] );
$encoded_dn = rawurlencode( $dn );
/* Ensure that the object has defined all MUST attrs for this objectClass.
* If it hasn't, present a form to have the user enter values for all the
* newly required attrs. */
$entry = $ldapserver->getDNAttrs($dn,true);
$current_attrs = array();
foreach( $entry as $attr => $junk )
$current_attrs[] = strtolower($attr);
// grab the required attributes for the new objectClass
$schema_oclasses = $ldapserver->SchemaObjectClasses();
$must_attrs = array();
foreach( $new_oclass as $oclass_name ) {
$oclass = $ldapserver->getSchemaObjectClass($oclass_name);
if( $oclass )
$must_attrs = array_merge( $must_attrs, $oclass->getMustAttrNames( $schema_oclasses ) );
}
$must_attrs = array_unique( $must_attrs );
// We don't want any of the attr meta-data, just the string
//foreach( $must_attrs as $i => $attr )
//$must_attrs[$i] = $attr->getName();
// build a list of the attributes that this new objectClass requires,
// but that the object does not currently contain
$needed_attrs = array();
foreach( $must_attrs as $attr ) {
$attr = $ldapserver->getSchemaAttribute($attr);
//echo "<pre>"; var_dump( $attr ); echo "</pre>";
// First, check if one of this attr's aliases is already an attribute of this entry
foreach( $attr->getAliases() as $alias_attr_name )
if( in_array( strtolower( $alias_attr_name ), $current_attrs ) )
// Skip this attribute since it's already in the entry
continue;
if( in_array( strtolower($attr->getName()), $current_attrs ) )
continue;
// We made it this far, so the attribute needs to be added to this entry in order
// to add this objectClass
$needed_attrs[] = $attr;
}
if( count( $needed_attrs ) > 0 ) {
include './header.php'; ?>
<body>
<h3 class="title"><?php echo _('New Required Attributes'); ?></h3>
<h3 class="subtitle"><?php echo _('This action requires you to add') . ' ' . count($needed_attrs) .
' ' . _('new attributes'); ?></h3>
<small>
<?php echo _('Instructions: In order to add these objectClass(es) to this entry, you must specify');
echo ' ' . count( $needed_attrs ) . ' ' . _('new attributes') . ' ';
echo _('that this objectClass requires. You can do so in this form.'); ?>
</small>
<br />
<br />
<form action="add_oclass.php" method="post">
<input type="hidden" name="new_oclass" value="<?php echo rawurlencode( serialize( $new_oclass ) ); ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
<table class="edit_dn" cellspacing="0">
<tr><th colspan="2"><?php echo _('New Required Attributes'); ?></th></tr>
<?php foreach( $needed_attrs as $count => $attr ) { ?>
<tr><td class="attr"><b><?php echo htmlspecialchars($attr->getName()); ?></b></td></tr>
<tr><td class="val"><input type="text" name="new_attrs[<?php echo htmlspecialchars($attr->getName()); ?>]" value="" size="40" /></tr>
<?php } ?>
</table>
<br />
<br />
<center><input type="submit" value="<?php echo _('Add ObjectClass and Attributes'); ?>" /></center>
</form>
</body>
</html>
<?php } else {
$add_res = $ldapserver->attrModify($dn,array('objectClass'=>$new_oclass));
if (! $add_res)
pla_error("Could not perform ldap_mod_add operation.",
$ldapserver->error(),$ldapserver->errno());
else
header(sprintf('Location: template_engine.php?server_id=%s&dn=%s&modified_attrs[]=objectClass',
$ldapserver->server_id,$encoded_dn));
}
?>

74
htdocs/add_value.php Normal file
View File

@@ -0,0 +1,74 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_value.php,v 1.19.2.5 2005/12/09 23:32:37 wurley Exp $
/**
* Adds a value to an attribute for a given dn.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
* - new_value (form element)
* - binary
*
* On success, redirect to the edit_dn page. On failure, echo an error.
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if( $ldapserver->isReadOnly() )
pla_error( _('You cannot perform updates while server is in read-only mode') );
if( ! $ldapserver->haveAuthInfo())
pla_error( _('Not enough information to login to server. Please check your configuration.') );
$attr = $_POST['attr'];
$new_value = $_POST['new_value'];
$dn = rawurldecode( $_POST['dn'] );
$is_binary_val = isset( $_POST['binary'] ) ? true : false;
$encoded_dn = rawurlencode( $dn );
$encoded_attr = rawurlencode( $attr );
if ($ldapserver->isAttrReadOnly($attr))
pla_error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),htmlspecialchars( $attr )));
// special case for binary attributes:
// we must go read the data from the file.
if( $is_binary_val ) {
$file = $_FILES['new_value']['tmp_name'];
$f = fopen( $file, 'r' );
$binary_value = fread( $f, filesize( $file ) );
fclose( $f );
$new_value = $binary_value;
}
$new_entry = array( $attr => $new_value );
// Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($dn,$attr,$new_entry)) {
$search_href = sprintf('search.php?search=true&form=advanced&server_id=%s&filter=%s=%s',$ldapserver->server_id,$attr,$badattr);
pla_error(sprintf( _('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$attr,$badattr,$dn,$search_href ) );
}
// Call the custom callback for each attribute modification
// and verify that it should be modified.
if( run_hook ( 'pre_attr_add', array ( 'server_id' => $ldapserver->server_id, 'dn' => $dn, 'attr_name' => $attr,
'new_value' => $new_entry ) ) ) {
$add_result = $ldapserver->attrModify($dn,$new_entry);
if (! $add_result)
pla_error(_('Could not perform ldap_mod_add operation.'),
$ldapserver->error(),$ldapserver->errno());
}
header(sprintf('Location: template_engine.php?server_id=%s&dn=%s&modified_attrs[]=%s',
$ldapserver->server_id,$encoded_dn,$encoded_attr));
?>

205
htdocs/add_value_form.php Normal file
View File

@@ -0,0 +1,205 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_value_form.php,v 1.34.2.5 2007/01/27 12:51:47 wurley Exp $
/**
* Displays a form to allow the user to enter a new value to add
* to the existing list of values for a multi-valued attribute.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$attr = $_GET['attr'];
$dn = isset($_GET['dn']) ? $_GET['dn'] : null;
$encoded_dn = rawurlencode($dn);
$encoded_attr = rawurlencode($attr);
if (! is_null($dn))
$rdn = get_rdn($dn);
else
$rdn = null;
$current_values = $ldapserver->getDNAttr($dn,$attr);
if ($current_values) {
if (! is_array($current_values))
$current_values = array($current_values);
$num_current_values = count($current_values);
} else {
$current_values = array();
$num_current_values = 0;
}
$is_object_class = (strcasecmp($attr, 'objectClass') == 0) ? true : false;
if ($is_object_class) {
# fetch all available objectClasses and remove those from the list that are already defined in the entry
$schema_oclasses = $ldapserver->SchemaObjectClasses();
foreach($current_values as $oclass)
unset($schema_oclasses[strtolower($oclass)]);
} else {
$schema_attr = $ldapserver->getSchemaAttribute($attr);
}
include './header.php';
echo '<body>';
printf('<h3 class="title">%s <b>%s</b> %s <b>%s</b></h3>',
_('Add new'),htmlspecialchars($attr),_('value to'),htmlspecialchars($rdn));
printf('<h3 class="subtitle">%s <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn));
printf('%s <b>%s</b> %s <b>%s</b>:',
_('Current list of'),$num_current_values,_('values for attribute'),htmlspecialchars($attr));
if ($num_current_values) {
if ($ldapserver->isJpegPhoto($attr)) {
echo '<table><tr><td>';
draw_jpeg_photos($ldapserver, $dn, $attr, false);
echo '</td></tr></table>';
# <!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
printf('<p><small>%s</small></p>',
_('Note: You will get an "inappropriate matching" error if you have not setup an EQUALITY rule on your LDAP server for this attribute.'));
# <!-- End of temporary warning -->
} elseif ($ldapserver->isAttrBinary($attr)) {
echo '<ul>';
if (is_array($vals)) {
for ($i=1; $i<=count($vals); $i++) {
$href = sprintf('download_binary_attr.php?server_id=%s&amp;dn=%s&amp;attr=%s&amp;value_num=%s',
$ldapserver->server_id,$encoded_dn,$attr,$i-1);
printf('<li><a href="%s"><img src="images/save.png" />%s (%s)</a></li>',
$href,_('download value'),$i);
}
} else {
$href = sprintf('download_binary_attr.php?server_id=%s&amp;dn=%s&amp;attr=%s',
$ldapserver->server_id,$encoded_dn,$attr);
printf('<li><a href="%s"><img src="images/save.png" />%s</a></li>',
$href,_('download value'));
}
echo '</ul>';
# <!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
printf('<p><small>%s</small></p>',
_('Note: You will get an "inappropriate matching" error if you have not setup an EQUALITY rule on your LDAP server for this attribute.'));
# <!-- End of temporary warning -->
} else {
echo '<ul class="current_values">';
if (is_array($current_values)) {
if (strcasecmp($attr,'userPassword') == 0) {
foreach ($current_values as $key => $value) {
if (obfuscate_password_display(get_enc_type($value)))
echo '<li><span style="white-space: nowrap;">'.preg_replace('/./','*',$value).'<br /></li>';
else
echo '<li><span style="white-space: nowrap;">'.htmlspecialchars($value).'<br /></li>';
}
} else {
foreach ($current_values as $val)
printf('<li><span style="white-space: nowrap;">%s</span></li>',htmlspecialchars($val));
}
} else {
printf('<li><span style="white-space: nowrap;">%s</span></li>',htmlspecialchars($current_values));
}
echo '</ul>';
}
} else {
echo '<br /><br />';
}
echo _('Enter the value you would like to add:');
echo '<br /><br />';
if ($is_object_class) {
echo '<form action="add_oclass_form.php" method="post" class="new_value">';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="hidden" name="dn" value="%s" />',$encoded_dn);
echo '<select name="new_oclass[]" multiple="true" size="15">';
foreach ($schema_oclasses as $name => $oclass) {
# exclude any structural ones, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION
if ($oclass->getType() == 'structural')
continue;
printf('<option value="%s">%s</option>',$oclass->getName(),$oclass->getName());
}
echo '</select>';
echo '<br />';
printf('<input type="submit" value="%s" />',_('Add new ObjectClass'));
echo '<br />';
if ($config->GetValue('appearance','show_hints'))
printf('<small><br /><img src="images/light.png" /><span class="hint">%s</span></small>',
_('Note: You may be required to enter new attributes that these objectClass(es) require'));
} else {
echo '<form action="add_value.php" method="post" class="new_value" name="new_value_form">';
if ($ldapserver->isAttrBinary($attr))
echo 'enctype="multipart/form-data"';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="hidden" name="dn" value="%s" />',$encoded_dn);
printf('<input type="hidden" name="attr" value="%s" />',$encoded_attr);
if ($ldapserver->isAttrBinary($attr)) {
echo '<input type="file" name="new_value" />';
echo '<input type="hidden" name="binary" value="true" />';
} else {
if ($ldapserver->isMultiLineAttr($attr)) {
echo '<textarea name="new_value" rows="3" cols="30"></textarea>';
} else {
printf('<input type="text"%s name="new_value" size="40" value="" />',
($schema_attr->getMaxLength() ? sprintf(' maxlength="%s"',$schema_attr->getMaxLength()) : ''));
# draw the "browse" button next to this input box if this attr houses DNs:
if ($ldapserver->isDNAttr($attr))
draw_chooser_link("new_value_form.new_value", false);
}
}
printf('<input type="submit" name="submit" value="%s" />',_('Add New Value'));
echo '<br />';
if ($schema_attr->getDescription())
printf('<small><b>%s:</b> %s</small><br />',_('Description'),$schema_attr->getDescription());
if ($schema_attr->getType())
printf('<small><b>%s:</b> %s</small><br />',_('Syntax'),$schema_attr->getType());
if ($schema_attr->getMaxLength())
printf('<small><b>%s:</b> %s %s</small><br />',
_('Maximum Length'),number_format($schema_attr->getMaxLength()),_('characters'));
echo '</form>';
}
echo '</body></html>';
?>

33
htdocs/collapse.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/collapse.php,v 1.13.4.2 2007/03/18 03:16:05 wurley Exp $
/**
* This script alters the session variable 'tree', collapsing it
* at the dn specified in the query string.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars:
* - dn (rawurlencoded)
*
* Note: this script is equal and opposite to expand.php
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
$dn = $_GET['dn'];
$tree = get_cached_item($ldapserver->server_id,'tree');
$tree['browser'][$dn]['open'] = false;
set_cached_item($ldapserver->server_id,'tree','null',$tree);
/* If cookies were disabled, build the url parameter for the session id.
It will be append to the url to be redirect */
$id_session_param = '';
if (SID != '')
$id_session_param = sprintf('&%s=%s',session_name(),session_id());
header(sprintf('Location:tree.php?foo=%s#%s_%s%s',random_junk(),$ldapserver->server_id,rawurlencode($dn),$id_session_param));
?>

5
htdocs/common.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
# This is a temporary file
@define('LIBDIR',sprintf('%s/',realpath('../lib/')));
require LIBDIR.'common.php';
?>

588
htdocs/compare.php Normal file
View File

@@ -0,0 +1,588 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/compare.php,v 1.12.2.6 2007/01/27 12:38:59 wurley Exp $
/**
* Compare two DNs - the destination DN is editable.
* @package phpLDAPadmin
*/
/**
* @todo: Must fix dc/domainComponent evaluation.
*/
require './common.php';
$dn_src = isset($_POST['dn_src']) ? $_POST['dn_src'] : null;
$dn_dst = isset($_POST['dn_dst']) ? $_POST['dn_dst'] : null;
$encoded_dn_src = rawurlencode($dn_src);
$encoded_dn_dst = rawurlencode($dn_dst);
$server_id_src = (isset($_POST['server_id_src']) ? $_POST['server_id_src'] : '');
$server_id_dst = (isset($_POST['server_id_dst']) ? $_POST['server_id_dst'] : '');
$ldapserver_src = $ldapservers->Instance($server_id_src);
if (! $ldapserver_src->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$ldapserver_dst = $ldapservers->Instance($server_id_dst);
if (! $ldapserver_src->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
if (! $ldapserver_src->dnExists($dn_src))
pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn_src)));
if (! $ldapserver_dst->dnExists($dn_dst))
pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn_dst)));
$friendly_attrs = process_friendly_attr_table();
$attrs_src = $ldapserver_src->getDNAttrs($dn_src,false,$config->GetValue('deref','view'));
$attrs_dst = $ldapserver_dst->getDNAttrs($dn_dst,false,$config->GetValue('deref','view'));
# Get a list of all attributes.
$attrs_all = array_keys($attrs_src);
foreach ($attrs_dst as $key => $val)
if (! in_array($key,$attrs_all))
$attrs_all[] = $key;
include './header.php';
?>
<body>
<table class="comp_dn" border=0>
<tr><td colspan=6>
<h3 class="title"><?php echo _('Comparing the following DNs'); ?></h3>
</td></tr>
<tr>
<td colspan=2 width=20%>
<h3 class="subtitle"><?php echo _('Attribute'); ?><br />&nbsp;</h3>
</td>
<td colspan=2 width=40%>
<h3 class="subtitle"><?php echo _('Server'); ?>: <b><?php echo $ldapserver_src->name; ?></b><br /><?php echo _('Distinguished Name');?>: <b><?php echo htmlspecialchars(($dn_src)); ?></b></h3>
</td>
<td colspan=2 width=40%>
<h3 class="subtitle"><?php echo _('Server'); ?>: <b><?php echo $ldapserver_dst->name; ?></b><br /><?php echo _('Distinguished Name');?>: <b><?php echo htmlspecialchars(($dn_dst)); ?></b></h3>
</td>
</tr>
<tr>
<td colspan=6 align=right>
<form action="compare.php" method="post" name="compare_form">
<input type="hidden" name="server_id_src" value="<?php echo $ldapserver_dst->server_id; ?>" />
<input type="hidden" name="server_id_dst" value="<?php echo $ldapserver_src->server_id; ?>" />
<input type="hidden" name="dn_src" value="<?php echo htmlspecialchars($dn_dst); ?>" />
<input type="hidden" name="dn_dst" value="<?php echo htmlspecialchars($dn_src); ?>" />
<input type="submit" value="<?php echo _('Switch Entry'); ?>" />
</form>
</td>
</tr>
<?php
if (! $attrs_all || ! is_array($attrs_all)) {
printf('<tr><td colspan="2">(%s)</td></tr>',_('This entry has no attributes'));
print '</table>';
print '</html>';
die();
}
sort($attrs_all);
# Work through each of the attributes.
foreach ($attrs_all as $attr) {
flush();
# If this is the DN, get the next attribute.
if (! strcasecmp($attr,'dn'))
continue;
# Has the config.php specified that this attribute is to be hidden or shown?
if ($ldapserver_src->isAttrHidden($attr) || $ldapserver_dst->isAttrHidden($attr))
continue;
?>
<!-- Begin Attribute -->
<tr>
<?php foreach (array('src','dst') as $side) { ?>
<?php
if ($side == 'dst' && ! $ldapserver_dst->isReadOnly()) { ?>
<form action="update_confirm.php" method="post" name="edit_form">
<input type="hidden" name="server_id" value="<?php echo $ldapserver_dst->server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $dn_dst; ?>" />
<?php }
$schema_attr_src = $ldapserver_src->getSchemaAttribute($attr,$dn_src);
$schema_attr_dst = $ldapserver_dst->getSchemaAttribute($attr,$dn_dst);
# Setup the $attr_note, which will be displayed to the right of the attr name (if any)
$attr_note = '';
$required_note = '';
# is there a user-friendly translation available for this attribute?
if (isset($friendly_attrs[strtolower($attr)])) {
$attr_display = $friendly_attrs[strtolower($attr)];
$attr_note = sprintf('<acronym title="%s">alias</acronym>',sprintf(_('Note: \'%s\' is an alias for \'%s\''),$attr_display,$attr));
} else {
$attr_note = '';
$attr_display = $attr;
}
# is this attribute required by an objectClass?
$required_by = '';
switch ($side) {
case 'src':
$ldapserver = $ldapserver_src;
if ($schema_attr_src)
foreach ($schema_attr_src->getRequiredByObjectClasses() as $required)
if (isset($attrs_src['objectClass']) && in_array(strtolower($required),arrayLower($attrs_src['objectClass'])))
$required_by .= $required . ' ';
# It seems that some LDAP servers (Domino) returns attributes in lower case?
elseif (isset($attrs_src['objectclass']) && in_array(strtolower($required),arrayLower($attrs_src['objectclass'])))
$required_by .= $required . ' ';
break;
case 'dst':
$ldapserver = $ldapserver_dst;
if ($schema_attr_dst)
foreach ($schema_attr_dst->getRequiredByObjectClasses() as $required)
if (isset($attrs_dst['objectClass']) && in_array(strtolower($required),arrayLower($attrs_dst['objectClass'])))
$required_by .= $required . ' ';
# It seems that some LDAP servers (Domino) returns attributes in lower case?
elseif (isset($attrs_dst['objectclass']) && in_array(strtolower($required),arrayLower($attrs_dst['objectclass'])))
$required_by .= $required . ' ';
break;
}
if ($side == 'src') { ?>
<td class="attr">
<?php $schema_href="schema.php?server_id=$server_id_src&amp;view=attributes&amp;viewvalue=".real_attr_name($attr); ?>
<b><a title="<?php echo sprintf(_('Click to view the schema definition for attribute type \'%s\''),$attr) ?>" href="<?php echo $schema_href; ?>"><?php echo $attr_display; ?></a></b>
</td>
<td class="attr_note">
<sup><small><?php echo $attr_note; ?></small></sup>
</td>
<?php }
if ($required_by) {
$required_note .= sprintf('<acronym title="%s">%s</acronym>',sprintf(_('Required attribute for objectClass(es) %s'),$required_by),_('required'));
?>
<td colspan=2 class="attr_note">
<sup><small><?php echo $required_note; ?></small></sup>
</td>
<?php } else { ?>
<td colspan=2 class="attr_note">&nbsp;</td>
<?php } ?>
<?php if ($ldapserver->isAttrReadOnly($attr)) { ?>
<small>(<acronym title="<?php echo _('This attribute has been flagged as read only by the phpLDAPadmin administrator'); ?>"><?php echo _('read only'); ?></acronym>)</small>
<?php } ?>
</td>
<?php } ?>
</tr>
<!-- End of Attribute -->
<!-- Begin Values -->
<tr>
<?php
foreach (array('src','dst') as $side) {
$vals = null; ?>
<?php
# If this attribute isnt set, then show a blank.
$toJump = 0;
switch ($side) {
case 'src':
print '<td colspan=2>&nbsp</td><td class="attr">';
if (! isset($attrs_src[$attr])) {
echo "<small>&lt;". _('No Value')."&gt;</small></td>";
$toJump = 1;
continue;
} else
$vals = $attrs_src[$attr];
$ldapserver = $ldapserver_src;
break;
case 'dst':
print '<td colspan=2>&nbsp</td><td class="val">';
if (! isset($attrs_dst[$attr])) {
echo "<small>&lt;". _('No Value')."&gt;</small></td>";
$toJump = 1;
continue;
} else
$vals = $attrs_dst[$attr];
$ldapserver = $ldapserver_dst;
break;
}
if ($toJump) continue;
if (! is_array($vals))
$vals = array($vals);
/*
* Is this attribute a jpegPhoto?
*/
if ($ldapserver->isJpegPhoto($attr)) {
switch ($side) {
case 'src':
// Don't draw the delete buttons if there is more than one jpegPhoto
// (phpLDAPadmin can't handle this case yet)
draw_jpeg_photos($ldapserver,$dn_src,$attr,false);
break;
case 'dst':
if ($ldapserver_dst->isReadOnly() || $ldapserver_dst->isAttrReadOnly($attr))
draw_jpeg_photos($ldapserver,$dn_dst,$attr,false);
else
draw_jpeg_photos($ldapserver,$dn_dst,$attr,true);
break;
}
// proceed to the next attribute
echo "</td>\n";
continue;
}
/*
* Is this attribute binary?
*/
if ($ldapserver->isAttrBinary($attr)) {
switch ($side) {
case 'src':
$href = sprintf("download_binary_attr.php?server_id=%s&dn=%s&attr=%s",$ldapserver->server_id,$encoded_dn_src,$attr);
break;
case 'dst':
$href = sprintf("download_binary_attr.php?server_id=%s&dn=%s&attr=%s",$ldapserver->server_id,$encoded_dn_dst,$attr);
break;
}
?>
<small>
<?php echo _('Binary value'); ?><br />
<?php if (count($vals) > 1) { for($i=1; $i<=count($vals); $i++) { ?>
<a href="<?php echo $href . "&amp;value_num=$i"; ?>"><img
src="images/save.png" /> <?php echo _('download value'); ?>(<?php echo $i; ?>)</a><br />
<?php } } else { ?>
<a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo _('download value'); ?></a><br />
<?php }
if ($side == 'dst' && ! $ldapserver_dst->isReadOnly() && ! $ldapserver->isAttrReadOnly($attr)) { ?>
<a href="javascript:deleteAttribute('<?php echo $attr; ?>');" style="color:red;"><img src="images/trash.png" /> <?php echo _('delete attribute'); ?></a>
<?php } ?>
</small>
</td>
<?php continue;
}
/*
* Note: at this point, the attribute must be text-based (not binary or jpeg)
*/
/*
* If this server is in read-only mode or this attribute is configured as read_only,
* simply draw the attribute values and continue.
*/
if ($side == 'dst' && ($ldapserver->isReadOnly() || $ldapserver->isAttrReadOnly($attr))) {
if (is_array($vals)) {
foreach ($vals as $i => $val) {
if (trim($val) == "")
echo "<span style=\"color:red\">[" . _('empty') . "]</span><br />\n";
elseif (0 == strcasecmp($attr,'userPassword') && $config->GetValue('appearance','obfuscate_password_display'))
echo preg_replace('/./','*',$val) . "<br />";
else
echo htmlspecialchars($val) . "<br />";
}
// @todo: redundant - $vals is always an array.
} else {
if (0 == strcasecmp($attr,'userPassword') && $config->GetValue('appearance','obfuscate_password_display'))
echo preg_replace('/./','*',$vals) . "<br />";
else
echo $vals . "<br />";
}
echo "</td>";
continue;
}
/*
* Is this a userPassword attribute?
*/
if (! strcasecmp($attr,'userpassword')) {
$user_password = $vals[0];
$enc_type = get_enc_type($user_password);
// Set the default hashing type if the password is blank (must be newly created)
if ($user_password == '') {
$enc_type = get_default_hash($server_id);
}
if ($side == 'dst') { ?>
<input type="hidden" name="old_values[userpassword]" value="<?php echo htmlspecialchars($user_password); ?>" />
<!-- Special case of enc_type to detect changes when user changes enc_type but not the password value -->
<input size="38" type="hidden" name="old_enc_type" value="<?php echo ($enc_type==''?'clear':$enc_type); ?>" />
<?php }
if (obfuscate_password_display($enc_type)) {
echo htmlspecialchars(preg_replace('/./','*',$user_password));
} else {
echo htmlspecialchars($user_password);
} ?>
<br />
<?php if ($side == 'dst') { ?>
<input style="width: 260px" type="password" name="new_values[userpassword]" value="<?php echo htmlspecialchars($user_password); ?>" />
<?php echo enc_type_select_list($enc_type);
} ?>
<br />
<script language="javascript">
<!--
function passwordComparePopup()
{
mywindow = open('password_checker.php','myname','resizable=no,width=450,height=200,scrollbars=1');
mywindow.location.href = 'password_checker.php?hash=<?php echo base64_encode($user_password); ?>&base64=true';
if (mywindow.opener == null)
mywindow.opener = self;
}
-->
</script>
<small><a href="javascript:passwordComparePopup()"><?php echo _('Check password'); ?></a></small>
</td>
<?php continue;
}
/*
* Is this a boolean attribute?
*/
if ($ldapserver->isAttrBoolean($attr)) {
$val = $vals[0];
if ($side = 'dst') {?>
<input type="hidden" name="old_values[<?php echo htmlspecialchars($attr); ?>]" value="<?php echo htmlspecialchars($val); ?>" />
<select name="new_values[<?php echo htmlspecialchars($attr); ?>]">
<option value="TRUE"<?php echo ($val=='TRUE' ? ' selected' : ''); ?>><?php echo _('true'); ?></option>
<option value="FALSE"<?php echo ($val=='FALSE' ? ' selected' : ''); ?>><?php echo _('false'); ?></option>
<option value="">(<?php echo _('none, remove value'); ?>)</option>
</select>
<?php } ?>
</td>
<?php continue;
}
/*
* End of special case attributes (non plain text).
*/
foreach ($vals as $i => $val) {
if ($side == 'dst') {
$input_name = "new_values[" . htmlspecialchars($attr) . "][$i]";
// We smack an id="..." tag in here that doesn't have [][] in it to allow the
// draw_chooser_link() to identify it after the user clicks.
$input_id = "new_values_" . htmlspecialchars($attr) . "_" . $i; ?>
<!-- The old_values array will let update.php know if the entry contents changed
between the time the user loaded this page and saved their changes. -->
<input type="hidden" name="old_values[<?php echo htmlspecialchars($attr); ?>][<?php echo $i; ?>]" value="<?php echo htmlspecialchars($val); ?>" />
<?php }
// Is this value is a structural objectClass, make it read-only
if (0 == strcasecmp($attr,'objectClass')) { ?>
<a title="<?php echo _('View the schema description for this objectClass'); ?>" href="schema.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;view=objectClasses&amp;viewvalue=<?php echo htmlspecialchars($val); ?>"><img src="images/info.png" /></a>
<?php $schema_object = $ldapserver->getSchemaObjectClass($val);
if ($schema_object->getType() == 'structural') {
echo "$val <small>(<acronym title=\"" . sprintf(_('This is a structural ObjectClass and cannot be removed.')) . "\">" . _('structural') . "</acronym>)</small><br />";
if ($side == 'dst') {?>
<input type="hidden" name="<?php echo $input_name; ?>" id="<?php echo $input_id; ?>" value="<?php echo htmlspecialchars($val); ?>" />
<?php }
continue;
}
}
if (is_dn_string($val) || $ldapserver->isDNAttr($attr)) { ?>
<a title="<?php echo sprintf(_('Go to %s'),htmlspecialchars($val)); ?>" href="template_engine.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;dn=<?php echo rawurlencode($val); ?>"><img style="vertical-align: top" src="images/go.png" /></a>
<?php } elseif (is_mail_string($val)) { ?>
<a href="mailto:<?php echo htmlspecialchars($val); ?>"><img style="vertical-align: center" src="images/mail.png" /></a>
<?php } elseif (is_url_string($val)) { ?>
<a href="<?php echo htmlspecialchars($val); ?>" target="new"><img style="vertical-align: center" src="images/dc.png" /></a>
<?php }
if ($ldapserver->isMultiLineAttr($attr,$val)) {
if ($side == 'dst') {?>
<textarea class="val" rows="3" cols="30" name="<?php echo $input_name; ?>" id="<?php echo $input_id; ?>"><?php echo htmlspecialchars($val); ?></textarea>
<?php } else {
echo htmlspecialchars($val);
}
} else {
if ($side == 'dst') {?>
<input type="text" class="val" name="<?php echo $input_name; ?>" id="<?php echo $input_id; ?>" value="<?php echo htmlspecialchars($val); ?>" />
<?php } else {
echo htmlspecialchars($val);
}
}
// draw a link for popping up the entry browser if this is the type of attribute
// that houses DNs.
if ($ldapserver->isDNAttr($attr))
draw_chooser_link("edit_form.$input_id",false); ?>
<br />
<?php } ?>
</td>
<?php } /* end foreach value */ ?>
</tr>
<?php
/* Draw the "add value" link under the list of values for this attributes */
if (! $ldapserver_dst->isReadOnly()) {
// First check if the required objectClass is in this DN
$isOK = 0;
$src_oclass = array();
$attr_object = $ldapserver_dst->getSchemaAttribute($attr,$dn_dst);
foreach ($attr_object->used_in_object_classes as $oclass) {
if (in_array(strtolower($oclass),arrayLower($attrs_dst['objectClass']))) {
$isOK = 1;
break;
} else {
// Find oclass that the source has that provides this attribute.
if (in_array($oclass,$attrs_src['objectClass']))
$src_oclass[] = $oclass;
}
}
print "<tr><td colspan=2></td><td colspan=2>&nbsp</td><td>&nbsp;</td><td>";
if (! $isOK) {
if (count($src_oclass) == 1) {
$add_href = sprintf('add_oclass_form.php?server_id=%s&dn=%s&new_oclass=%s',
$ldapserver_dst->server_id,$encoded_dn_dst,$src_oclass[0]);
} else {
$add_href = sprintf('add_value_form.php?server_id=%s&dn=%s&attr=objectClass',
$ldapserver_dst->server_id,$encoded_dn_dst);
}
if ($attr == 'objectClass')
printf('<div class="add_oclass">(<a href="%s" title="%s">%s</a>)</div>',$add_href,_('Add ObjectClass and Attributes'),_('add value'));
else
printf('<div class="add_oclass">(<a href="%s" title="%s">%s</a>)</div>',$add_href,sprintf(_('You need one of the following ObjectClass(es) to add this attribute %s.'),implode(" ",$src_oclass)),_('Add new ObjectClass'));
} else {
if (! $schema_attr_dst->getIsSingleValue() || (! isset($vals))) {
$add_href = sprintf('add_value_form.php?server_id=%s&dn=%s&attr=%s',
$ldapserver_dst->server_id,$encoded_dn_dst,rawurlencode($attr));
printf('<div class="add_value">(<a href="%s" title="%s">%s</a>)</div>',
$add_href,sprintf(_('Add an additional value to attribute \'%s\''),$attr),_('add value'));
}
}
}
print "</td></tr>"; ?>
</td>
<?php flush(); ?>
</tr>
<?php } /* End foreach ($attrs as $attr => $vals) */
if (! $ldapserver_dst->isReadOnly()) { ?>
<td colspan="2">&nbsp</td><td colspan=2><center><input type="submit" value="<?php echo _('Save Changes'); ?>" /></center></td></tr></form>
<?php } ?>
</table>
<?php /* If this entry has a binary attribute,we need to provide a form for it to submit when deleting it. */ ?>
<script language="javascript">
//<!--
function deleteAttribute(attrName)
{
if (confirm("<?php echo _('Really delete attribute'); ?> '" + attrName + "'?")) {
document.delete_attribute_form.attr.value = attrName;
document.delete_attribute_form.submit();
}
}
//-->
</script>
<!-- This form is submitted by JavaScript when the user clicks "Delete attribute" on a binary attribute -->
<form name="delete_attribute_form" action="delete_attr.php" method="post">
<input type="hidden" name="server_id" value="<?php echo $ldapserver_dst->server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $dn_dst; ?>" />
<input type="hidden" name="attr" value="FILLED IN BY JAVASCRIPT" />
</form>
</body>
</html>

78
htdocs/compare_form.php Normal file
View File

@@ -0,0 +1,78 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/compare_form.php,v 1.2.4.3 2006/04/29 03:15:34 wurley Exp $
/**
* Compares to DN entries side by side.
*
* - dn (rawurlencoded)
* - server_id
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = (isset($_GET['dn']) ? $_GET['dn'] : '');
$rdn = get_rdn($dn);
$select_server_html = server_select_list($ldapserver->server_id,true,'server_id_dst');
include './header.php';
echo '<body>';
printf('<h3 class="title">%s %s</h3>',_('Compare another DN with'),htmlspecialchars($rdn));
printf('<h3 class="subtitle">%s: <b>%s</b>',_('Server'),$ldapserver->name);
if ($dn)
printf('&nbsp;&nbsp;&nbsp;%s: <b>%s</b>',_('Distinguished Name'),htmlspecialchars($dn));
echo '</h3>';
echo "\n";
echo '<center>';
printf('%s <b>%s</b> %s<br />',_('Compare'),htmlspecialchars($rdn),_('with '));
echo '<form action="compare.php" method="post" name="compare_form">';
printf('<input type="hidden" name="server_id_src" value="%s" />',$ldapserver->server_id);
echo "\n";
echo '<table style="border-spacing: 10px">';
echo "\n";
echo '<tr><td>';
if (! $dn) {
printf('<acronym title="%s">%s</acronym>:',_('Compare this DN with another'),_('Source DN'));
echo '</td><td>';
printf('<input type="text" name="dn_src" size="45" value="%s" />',htmlspecialchars($dn));
draw_chooser_link('compare_form.dn_src','true',$rdn);
} else
printf('<input type="hidden" name="dn_src" value="%s" />',htmlspecialchars($dn));
echo '</td></tr>';
echo "\n";
echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',_('Compare this DN with another'),_('Destination DN'));
echo '<td>';
echo '<input type="text" name="dn_dst" size="45" value="" />';
draw_chooser_link('compare_form.dn_dst','true','');
echo '</td>';
echo '</tr>';
echo "\n";
printf('<tr><td>%s:</td><td>%s</td></tr>',_('Destination Server'),$select_server_html);
echo "\n";
printf('<tr><td colspan="2" align="right"><input type="submit" value="%s" /></td></tr>',_('Compare'));
echo "\n";
echo '</table>';
echo '</form>';
echo '</center>';
echo '</body>';
echo '</html>';
?>

189
htdocs/copy.php Normal file
View File

@@ -0,0 +1,189 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/copy.php,v 1.36.2.12 2007/03/18 01:31:19 wurley Exp $
/**
* Copies a given object to create a new one.
*
* Vars that come in as POST vars
* - source_dn (rawurlencoded)
* - new_dn (form element)
* - server_id
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
$server_id_src = (isset($_POST['server_id']) ? $_POST['server_id'] : '');
$server_id_dst = (isset($_POST['dest_server_id']) ? $_POST['dest_server_id'] : '');
$ldapserver_src = $ldapservers->Instance($server_id_src);
$ldapserver_dst = $ldapservers->Instance($server_id_dst);
if ($ldapserver_dst->isReadOnly())
pla_error(_('Destination server is currently READ-ONLY.'));
if (! $ldapserver_src->haveAuthInfo() || ! $ldapserver_dst->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$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;
include './header.php';
# Error checking
if (0 == strlen(trim($dn_dst)))
pla_error(_('You left the destination DN blank.'));
if (pla_compare_dns($dn_src,$dn_dst) == 0 && $server_id_src == $server_id_dst)
pla_error(_('The source and destination DN are the same.'));
if ($ldapserver_dst->dnExists($dn_dst))
pla_error(sprintf(_('The destination entry (%s) already exists.'),pretty_print_dn($dn_dst)));
if (! $ldapserver_dst->dnExists(get_container($dn_dst)))
pla_error(sprintf(_('The destination container (%s) 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 '<body>';
printf('<h3 class="title">%s%s</h3>',_('Copying '),htmlspecialchars($dn_src));
printf('<h3 class="subtitle">%s</h3>',_('Recursive copy progress'));
print '<br /><br />';
print '<small>';
print _('Building snapshot of tree to copy... ');
flush();
$snapshot_tree = build_tree($ldapserver_src,$dn_src,array(),$filter);
printf('<span style="color:green">%s</span><br />',_('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 '</small>';
} else {
$copy_result = copy_dn($ldapserver_src,$ldapserver_dst,$dn_src,$dn_dst);
}
if ($copy_result) {
$edit_url = sprintf('template_engine.php?server_id=%s&amp;dn=%s',$server_id_dst,rawurlencode($dn_dst));
$new_rdn = get_rdn($dn_dst);
$container = get_container($dn_dst);
printf('<center>%s<a href="%s">%s</a></center>',_('Copy successful! Would you like to '),$edit_url,_('view the new entry'));
echo '<!-- refresh the tree view (with the new DN renamed) and redirect to the edit_dn page -->';
echo '<script type="text/javascript" language="javascript">parent.left_frame.location.reload();</script>';
echo '</body></html>';
if ($do_remove) {
sleep(2);
$delete_url = sprintf('delete_form.php?server_id=%s&dn=%s',$server_id_src,rawurlencode($dn_src));
echo '<!-- redirect to the delete form -->';
printf('<script type="text/javascript" language="javascript">parent.right_frame.location="%s" </script>',$delete_url);
}
}
function r_copy_dn($ldapserver_src,$ldapserver_dst,$snapshottree,$root_dn,$dn_dst) {
if (DEBUG_ENABLED)
debug_log('r_copy_dn: Entered with (%s,%s,%s,%s,%s)',1,
$ldapserver_src->server_id,$ldapserver_dst->server_id,$snapshottree,$root_dn,$dn_dst);
printf('<span style="white-space: nowrap;">%s %s...',_('Copying'),htmlspecialchars($root_dn));
flush();
$copy_result = copy_dn($ldapserver_src,$ldapserver_dst,$root_dn,$dn_dst);
if (! $copy_result)
return false;
printf('<span style="color:green">%s</span><br />',_('Success'));
flush();
$children = isset($snapshottree[$root_dn]) ? $snapshottree[$root_dn] : null;
if (is_array($children) && count($children) > 0) {
foreach($children as $child_dn) {
$child_rdn = get_rdn($child_dn);
$new_dest_dn = sprintf('%s,%s',$child_rdn,$dn_dst);
r_copy_dn($ldapserver_src,$ldapserver_dst,$snapshottree,$child_dn,$new_dest_dn);
}
} else {
return true;
}
return true;
}
function copy_dn($ldapserver_src,$ldapserver_dst,$dn_src,$dn_dst) {
if (DEBUG_ENABLED)
debug_log('copy_dn: Entered with (%s,%s,%s,%s)',17,
$ldapserver_src->server_id,$ldapserver_dst->server_id,$dn_src,$dn_dst);
$new_entry = $ldapserver_src->getDNAttrs($dn_src);
# modify the prefix-value (ie "bob" in cn=bob) to match the destination DN's value.
$rdn_attr = substr($dn_dst,0,strpos($dn_dst,'='));
$rdn_value = get_rdn($dn_dst);
$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 (run_hook('pre_entry_create',
array ('server_id'=>$ldapserver_dst->server_id,'dn'=>$dn_dst,'attrs'=>$new_entry))) {
$add_result = $ldapserver_dst->add($dn_dst,$new_entry);
if (! $add_result) {
run_hook('post_entry_create',
array('server_id'=>$ldapserver_dst->server_id,'dn'=>$dn_dst,'attrs'=>$new_entry));
echo '</small><br /><br />';
pla_error(_('Failed to copy DN: ').$dn_dst,$ldapserver_dst->error(),$ldapserver_dst->errno());
}
return $add_result;
} else {
return false;
}
}
/**
* @param object $ldapserver
* @param dn $dn
* @param array $tree
* @param string $filter
*/
function build_tree($ldapserver,$dn,$buildtree) {
if (DEBUG_ENABLED)
debug_log('build_tree: Entered with (%s,%s,%s)',1,
$ldapserver->server_id,$dn,$buildtree);
# we search all children, not only the visible children in the tree
$children = $ldapserver->getContainerContents($dn,0);
if (is_array($children) && count($children) > 0) {
$buildtree[$dn] = $children;
foreach ($children as $child_dn)
$buildtree = build_tree($ldapserver,$child_dn,$buildtree);
}
if (DEBUG_ENABLED)
debug_log('build_tree: Returning (%s)',1,$buildtree);
return $buildtree;
}
?>

122
htdocs/copy_form.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/copy_form.php,v 1.24.4.5 2006/04/29 03:27:41 wurley Exp $
/**
* Copies a given object to create a new one.
*
* Variables that come in via common.php
* - server_id
* Variables that come in via GET variables
* - dn (rawurlencoded)
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = $_GET['dn'] ;
$rdn = get_rdn($dn);
$attrs = $ldapserver->getDNAttrs($dn);
$select_server_html = server_select_list($ldapserver->server_id,true,'dest_server_id');
$children = $ldapserver->getContainerContents($dn);
include './header.php';
# Draw some javaScrpt to enable/disable the filter field if this may be a recursive copy
if (is_array($children) && count($children) > 0) { ?>
<script type="text/javascript" language="javascript">
//<!--
function toggle_disable_filter_field(recursive_checkbox)
{
if (recursive_checkbox.checked) {
recursive_checkbox.form.remove.disabled = false;
recursive_checkbox.form.filter.disabled = false;
} else {
recursive_checkbox.form.remove.disabled = true;
recursive_checkbox.form.remove.checked = false;
recursive_checkbox.form.filter.disabled = true;
}
}
//-->
</script>
<?php
}
echo '<body>';
printf('<h3 class="title">%s %s</h3>',_('Copy'),htmlspecialchars($rdn));
printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',_('Server'),$ldapserver->name,
_('Distinguished Name'),htmlspecialchars($dn));
echo "\n";
echo '<center>';
printf('%s <b>%s</b> %s:<br /><br />',_('Copy'),htmlspecialchars($rdn),_('to a new object'));
echo '<form action="copy.php" method="post" name="copy_form">';
printf('<input type="hidden" name="old_dn" value="%s" />',htmlspecialchars($dn));
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
echo "\n";
echo '<table style="border-spacing: 10px">';
echo "\n";
echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',
_('The full DN of the new entry to be created when copying the source entry'),_('Destination DN'));
printf('<td><input type="text" name="new_dn" size="45" value="%s" />',htmlspecialchars($dn));
draw_chooser_link('copy_form.new_dn','true',htmlspecialchars($rdn));
echo '</td></tr>';
echo "\n";
printf('<tr><td>%s</td><td>%s</td></tr>',_('Destination Server'),$select_server_html);
echo "\n";
if (is_array($children) && count($children) > 0) {
echo '<tr>';
printf('<td><label for="recursive">%s</label>:</td>',_('Recursive copy'));
echo '<td><input type="checkbox" id="recursive" name="recursive" onClick="toggle_disable_filter_field(this)" />';
printf('<small>(%s)</small></td>',_('Recursively copy all children of this object as well.'));
echo '</tr>'."\n";
echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',_('When performing a recursive copy, only copy those entries which match this filter'),_('Filter'));
echo '<td><input type="text" name="filter" value="(objectClass=*)" size="45" disabled />';
echo '</tr>'."\n";
echo '<tr>';
printf('<td>%s</td>',_('Delete after copy (move):'));
echo '<td><input type="checkbox" name="remove" value="yes"/ disabled>';
printf('<small>(%s)</small)</td>',_('Make sure your filter (above) will select all child records.'));
echo '</tr>';
} else {
printf('<tr><td>%s</td><td><input type="checkbox" name="remove" value="yes"/></td></tr>',_('Delete after copy (move):'));
}
echo "\n";
printf('<tr><td colspan="2" align="right"><input type="submit" value="%s" /></td></tr>',_('Copy '));
echo "\n";
echo '</table></form>';
echo "\n";
echo '<script type="text/javascript" language="javascript">';
echo '<!--';
echo '/* If the user uses the back button, this way we draw the filter field properly. */';
echo 'toggle_disable_filter_field(document.copy_form.recursive);';
echo '//-->';
echo '</script>';
if ($config->GetValue('appearance','show_hints'))
printf('<small><img src="images/light.png" alt="Light" /><span class="hint">%s</span></small>',_('Hint: Copying between different servers only works if there are no schema violations'));
echo '</center></body></html>';
?>

160
htdocs/create.php Normal file
View File

@@ -0,0 +1,160 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/create.php,v 1.44.2.6 2006/02/19 02:57:01 wurley Exp $
/**
* Creates a new object.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as POST vars:
* - new_dn
* - attrs (an array of attributes)
* - vals (an array of values for the above attrs)
* - required_attrs (an array with indices being the attributes,
* and the values being their respective values)
* - object_classes (rawurlencoded, and serialized array of objectClasses)
*
* @package phpLDAPadmin
*/
/**
* @todo: posixgroup with empty memberlist generates an error.
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$new_dn = isset($_POST['new_dn']) ? $_POST['new_dn'] : null;
$required_attrs = isset($_POST['required_attrs']) ? $_POST['required_attrs'] : false;
$object_classes = unserialize(rawurldecode($_POST['object_classes']));
$redirect = isset($_POST['redirect']) ? $_POST['redirect'] : false;
# See if there are any presubmit values to work out.
if (isset($_POST['presubmit']) && count($_POST['presubmit']) && isset($_POST['template'])) {
$templates = new Templates($ldapserver->server_id);
$template = $templates->GetTemplate($_POST['template']);
foreach ($_POST['presubmit'] as $attr) {
$_POST['attrs'][] = $attr;
$_POST['form'][$attr] = $templates->EvaluateDefault($ldapserver,$template['attribute'][$attr]['presubmit'],$_POST['container']);
$_POST['vals'][] = $_POST['form'][$attr];
}
# @todo: This section needs to be cleaned up, and will be when the old templates are removed. In the mean time...
# Rebuild the $_POST['attrs'] & $_POST['vals'], as they can be inconsistent.
unset($_POST['attrs']);
unset($_POST['vals']);
foreach ($_POST['form'] as $attr => $val) {
$_POST['attrs'][] = $attr;
$_POST['vals'][] = $val;
}
}
$vals = isset($_POST['vals']) ? $_POST['vals'] : array();
$attrs = isset($_POST['attrs']) ? $_POST['attrs'] : array();
# build the new entry
$new_entry = array();
if (isset($required_attrs) && is_array($required_attrs)) {
foreach ($required_attrs as $attr => $val) {
if ($val == '')
pla_error(sprintf(_('You left the value blank for required attribute (%s).'),htmlspecialchars($attr)));
$new_entry[$attr][] = $val;
}
}
if (isset($attrs) && is_array($attrs)) {
foreach ($attrs as $i => $attr) {
if ($ldapserver->isAttrBinary($attr)) {
if (isset($_FILES['vals']['name'][$i]) && $_FILES['vals']['name'][$i] != '' ) {
# read in the data from the file
$file = $_FILES['vals']['tmp_name'][$i];
$f = fopen($file,'r');
$binary_data = fread($f,filesize($file));
fclose($f);
$val = $binary_data;
$new_entry[$attr][] = $val;
} elseif (isset($_SESSION['submitform'][$attr])) {
$new_entry[$attr][] = $_SESSION['submitform'][$attr];
unset($_SESSION['submitform'][$attr]);
}
} else {
if (is_array($vals[$i])) {
# If the array has blank entries, then ignore them.
foreach ($vals[$i] as $value) {
if (trim($value))
$new_entry[$attr][] = $value;
}
} else {
$val = isset($vals[$i]) ? $vals[$i] : '';
if ('' !== trim($val))
$new_entry[$attr][] = $val;
}
}
}
}
$new_entry['objectClass'] = $object_classes;
if (! in_array('top',$new_entry['objectClass']))
$new_entry['objectClass'][] = 'top';
foreach ($new_entry as $attr => $vals) {
# Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($new_dn,$attr,$vals)) {
$search_href = sprintf('search.php?search=true&amp;form=advanced&amp;server_id=%s&amp;filter=%s=%s',
$ldapserver->server_id,$attr,$badattr);
pla_error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$attr,$badattr,$new_dn,$search_href));
}
if (! $ldapserver->isAttrBinary($attr))
if (is_array($vals))
foreach ($vals as $i => $v)
$new_entry[$attr][$i] = $v;
else
$new_entry[$attr] = $vals;
}
# Check the user-defined custom call back first
if (run_hook('pre_entry_create',array('server_id'=>$ldapserver->server_id,'dn'=>$new_dn,'attrs'=>$new_entry)))
$add_result = $ldapserver->add($new_dn,$new_entry);
if ($add_result) {
run_hook('post_entry_create',array('server_id'=>$ldapserver->server_id,'dn'=>$new_dn,'attrs'=>$new_entry));
if ($redirect)
$redirect_url = $redirect;
else
$redirect_url = sprintf('template_engine.php?server_id=%s&dn=%s',$ldapserver->server_id,rawurlencode($new_dn));
echo '<html><head>';
$tree = get_cached_item($ldapserver->server_id,'tree');
$container = get_container($new_dn);
if ((isset($tree['browser'][$container]['open']) && $tree['browser'][$container]['open']) ||
in_array($new_dn,$ldapserver->getBaseDN())) {
echo '<!-- refresh the tree view (with the new DN renamed) and redirect to the edit_dn page -->';
printf('<script language="javascript">parent.left_frame.location.reload();location.href="%s"</script>',$redirect_url);
}
printf('<meta http-equiv="refresh" content="0; url=%s" />',$redirect_url);
echo '</head><body>';
printf('%s <a href="%s">%s</a>.',_('Redirecting...'),$redirect_url,_('here'));
echo '</body></html>';
} else {
pla_error(_('Could not add the object to the LDAP server.'),$ldapserver->error(),$ldapserver->errno());
}
?>

134
htdocs/create_form.php Normal file
View File

@@ -0,0 +1,134 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/Attic/create_form.php,v 1.31.2.5 2005/12/31 04:21:37 wurley Exp $
/**
* The menu where the user chooses an RDN, Container, and Template for creating a new entry.
* After submitting this form, the user is taken to their chosen Template handler.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars
* - container (rawurlencoded) (optional)
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$container = $_REQUEST['container'];
$server_menu_html = server_select_list($ldapserver->server_id,true);
include './header.php';
echo '<body>';
printf('<h3 class="title">%s</h3>',_('Create Object'));
printf('<h3 class="subtitle">%s</h3>',_('Choose a template'));
printf('<center><h3>%s</h3></center>',_('Select a template for the creation process'));
echo '<form action="template_engine.php" method="post">';
printf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($container));
echo '<table class="create">';
printf('<tr><td class="heading">%s:</td><td>%s</td></tr>',_('Server'),$server_menu_html);
echo '<tr>';
printf('<td class="heading">%s:</td>',_('Template'));
echo '<td>';
echo '<table class="template_display">';
echo '<tr><td>';
echo '<table class="templates">';
$i = -1;
$template_xml = new Templates($ldapserver->server_id);
$templates = $template_xml->_template;
# Remove non-visable templates.
foreach ($templates as $index => $template)
if (isset($template['visible']) && (! $template['visible']))
unset ($templates[$index]);
$templates['custom']['title'] = 'Custom';
$templates['custom']['icon'] = 'images/object.png';
$count = count($templates);
foreach ($templates as $name => $template) {
$i++;
# If the template doesnt have a title, we'll use the desc field.
$template['desc'] = isset($template['title']) ? $template['title'] : $template['desc'];
# Balance the columns properly
if ((count($templates) % 2 == 0 && $i == intval($count / 2)) ||
(count($templates) % 2 == 1 && $i == intval($count / 2) + 1))
echo '</table></td><td><table class="templates">';
# Check and see if this template should be shown in the list
$isValid = false;
if (isset($template['regexp'])) {
if (@preg_match('/'.$template['regexp'].'/i',$container))
$isValid = true;
} else
$isValid = true;
if (isset($template['invalid']) && $template['invalid'])
$isValid = false;
echo '<tr>';
if (! $isValid || (isset($template['handler']) && ! file_exists(TMPLDIR.'creation/'.$template['handler'])))
echo '<td class="icon"><img src="images/error.png" /></td>';
else
printf('<td><input type="radio" name="template" value="%s" id="%s" %s /></td>',
htmlspecialchars($name),htmlspecialchars($name),
! $isValid ? 'disabled' : (strcasecmp('Custom',$name) ? '' : 'checked'));
printf('<td class="icon"><label for="%s"><img src="%s" /></label></td>',
htmlspecialchars($name),$template['icon']);
printf('<td class="name"><label for="%s">',
htmlspecialchars($name));
if (strcasecmp('Custom', $template['desc']) == 0)
echo '<b>';
if (! $isValid)
if (isset($template['invalid']) && $template['invalid'])
printf('<span style="color: gray"><acronym title="%s">',
isset($template['invalid_reason']) ? $template['invalid_reason'] :
_('This template has been disabled in the XML file.'));
else
printf('<span style="color: gray"><acronym title="%s">',
_('This template is not allowed in this container.'));
echo htmlspecialchars($template['desc']);
if (! $isValid) echo '</acronym></span>';
if (strcasecmp('Custom', $template['desc']) == 0)
echo '</b>';
echo '</label></td></tr>';
}
echo '</table>';
echo '</td></tr></table>';
echo '</td></tr>';
printf('<tr><td colspan="2"><center><input type="submit" name="submit" value="%s" /></center></td></tr>',
htmlspecialchars(_('Proceed >>')));
echo '</table>';
echo '</form></body></html>';
?>

View File

@@ -1,3 +1,20 @@
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/css/style.css,v 1.44.4.3 2008/11/28 14:21:37 wurley Exp $ */
span.hint {
font-size: small;
font-weight: normal;
color: #888;
}
span.warning {
font-size: small;
font-weight: normal;
color: #f00;
}
span.x-small {
font-size: x-small;
}
table.schema_oclasses {
border-left: 1px solid black;
border-right: 1px solid black;
@@ -18,7 +35,7 @@ table.schema_attr th {
padding: 5px;
color: white;
font-weight: bold;
font-size: 125%;
font-size: 100%;
}
table.schema_attr td {
@@ -39,11 +56,24 @@ table.schema_attr tr.highlight{
font-weight: Bold;
}
table.notice tr td {
font-size: 9pt;
padding: 2px;
margin: 0px;
background-color: #eee;
}
table.error {
width: 500px;
border: 2px solid black;
}
table.error tr td table.bug tr td{
padding: 6px;
margin: 0px;
background-color: #eee;
}
table.error tr td {
vertical-align: top;
text-align: left;
@@ -57,7 +87,7 @@ table.error tr td h2 {
}
table.error tr td.img {
vertical-align: center;
vertical-align: middle;
text-align: center;
width: 20px;
}
@@ -69,6 +99,10 @@ table.confirm th {
font-weight: normal;
}
table.confirm tr td {
padding: 4px;
}
table.confirm tr.spacer {
background-color: #ddd;
}
@@ -77,28 +111,50 @@ table.confirm tr.even {
background-color: #ccc;
}
table.confirm tr.odd{
table.confirm tr.odd {
background-color: #eee;
}
table.confirm tr td {
padding: 4px;
vertical-align: top;
table.confirm tr td.heading {
text-align: right;
font-size: 75%;
}
table.confirm tr td.heading {
font-size: 75%;
table.confirm td.icon {
text-align: center;
}
table.browse tr td {
border: 0;
margin: 0;
padding: 0;
}
table.template_display tr td {
vertical-align: top;
}
table.templates tr td {
text-align: left;
vertical-align: center;
vertical-align: middle;
}
table.templates tr {
height: 25px;
}
table.templates td.icon {
text-align: center;
}
table.exporters tr td {
text-align: left;
vertical-align: middle;
}
table.exporters tr {
height: 25px;
}
a img {
border: 0px;
@@ -107,7 +163,7 @@ a img {
body {
font-family: arial, helvetica, sans-serif;
background-color: white;
font-size: 12pt;
font-size: 10pt;
}
table.tree tr.login td {
@@ -148,7 +204,7 @@ table.tree tr.server td {
padding-top: 15px;
padding-bottom: 0px;
vertical-align: top;
font-size: 20px;
font-size: 12px;
text-align: left;
}
@@ -156,7 +212,7 @@ table.tree td.icon {
text-align: center;
padding: 0px;
width: 14px;
font-size: 1px;
font-size: 10px;
}
table.tree td.rdn {
@@ -211,7 +267,7 @@ h3.title {
background-color: #018;
border: 1px solid black;
font-weight: normal;
font-size: 150%;
font-size: 140%;
}
h3.subtitle {
@@ -228,27 +284,59 @@ h3.subtitle {
font-weight: normal;
}
table.edit_dn tr.spacer td {
height: 10px;
table.comp_dn {
border-collapse: collapse;
border-spacing: 0px;
empty-cells: show;
font-size: 80%;
}
table.comp_dn tr {
width: 200px;
}
table.comp_dn tr td.attr {
background-color: #eee;
vertical-align: top;
}
table.comp_dn tr td.attr_note {
text-align: right;
background-color: #eee;
padding-right: 50px;
}
table.edit_dn {
width: 100%;
border-collapse: collapse;
border-spacing: 0px;
empty-cells: show;
width: 600px;
}
table.edit_dn th {
background: #777;
color: white;
font-weight: normal;
font-size: 125%;
padding: 5px;
table.edit_dn input {
margin: 1px;
}
table.edit_dn input.val {
font-size: 12px;
width: 350px;
font-family: arial, helvetica, sans-serif;
background-color: white;
}
table.edit_dn textarea.val {
font-size: 12px;
width: 350px;
font-family: arial, helvetica, sans-serif;
background-color: white;
}
table.edit_dn tr td {
padding: 4px;
padding-right: 0px;
}
table.edit_dn tr td.attr {
background-color: #eee;
vertical-align: top;
}
@@ -257,20 +345,51 @@ table.edit_dn tr td.heading {
font-weight: bold;
}
table.edit_dn tr td.attr_note {
text-align: right;
background-color: #eee;
}
table.edit_dn tr td.attr a {
text-decoration: none;
color: black;
}
table.edit_dn tr td.attr a:hover {
text-decoration: underline;
color: #016;
}
table.edit_dn tr td.val {
text-align: right;
vertical-align: center;
text-align: left;
vertical-align: middle;
padding-bottom: 10px;
padding-left: 50px;
}
/* When an attr is updated, it is displayed in light blue to indicate such */
table.edit_dn tr.updated_attr {
background: #def;
/** When an attr is updated, it is highlighted to indicate such */
table.edit_dn tr.updated_attr td.attr {
border-top: 1px dashed green;
border-left: 1px dashed green;
background-color: #ded;
}
table.edit_dn tr.updated_attr td {
border-top: 1px solid black;
border-bottom: 1px solid black;
color: #005;
table.edit_dn tr.updated_attr td.attr_note {
border-top: 1px dashed green;
border-right: 1px dashed green;
background-color: #ded;
}
/** An extra row that sits at the bottom of recently modified attrs to encase them in dashes */
table.edit_dn tr.updated_attr td.bottom {
border-top: 1px dashed green;
}
/** Formatting for the value cell when it is the attribute that has been recently modified */
table.edit_dn tr.updated_attr td.val {
border-left: 1px dashed green;
border-right: 1px dashed green;
}
/* Neede to prevent sub-tables (like the one in which jpegPhotos are displayed)
@@ -299,7 +418,7 @@ input.update_dn {
}
small {
font-size: 10pt;
font-size: 8pt;
}
form.edit_dn {
@@ -314,7 +433,7 @@ h4.oclass {
margin-top: 8px;
font-weight: normal;
border: 1px solid black;
font-size: 140%;
font-size: 120%;
color: white;
}
@@ -331,10 +450,22 @@ h4.oclass_sub {
ul.schema {
margin: 5px;
margin-left: 0px;
padding-left: 20px;
}
ul.schema li {
margin-left: 10px;
margin-left: 0px;
padding-left: 0px;
}
ul.schema li small {
font-size: 75%;
color: #777;
}
ul.schema li small a {
color: #77c;
}
ul.current_values {
@@ -348,15 +479,44 @@ form.new_value {
margin-left: 70px;
}
table.search_result_table {
border-spacing: 0;
border-collapse: collapse;
empty-cells: show;
}
table.search_result_table td {
vertical-align: top;
border: 1px solid gray;
padding: 4px;
}
table.search_result_table th {
border: 1px solid gray;
padding: 10px;
padding-left: 20px;
padding-right: 20px;
}
table.search_result_table tr.highlight {
background-color: #eee;
}
ul.search {
font-weight: bold;
}
table.search_header {
background-color: #ddf;
width: 100%;
vertical-align: top;
}
div.search_result {
list-style-type: none;
background: #ffb;
padding: 6px;
padding-left: 10px;
padding-left: 20px;
margin-right: 40px;
}
@@ -364,6 +524,7 @@ table.attrs {
font-weight: normal;
font-size: 75%;
margin: 0px;
margin-left: 35px;
}
table.attrs td {
@@ -385,6 +546,11 @@ table.edit_dn_menu {
font-size: 75%;
}
table.edit_dn_menu td.icon {
width: 16px;
text-align: center;
}
input.scary {
background: red;
font-weight: bold;
@@ -427,3 +593,72 @@ table.create td.heading {
vertical-align: top;
padding: 10px;
}
table.create td.name {
font-size: 11px;
width: 350px;
}
div.add_value {
font-size: 10pt;
margin: 0px;
padding: 0px;
}
a.logged_in_dn {
text-decoration: none;
color: black;
}
a.logged_in_dn:hover {
text-decoration: underline;
color: blue;
}
a:hover {
color: red;
}
/* Styles for formatting the documentation page */
h3.doc {
margin-left: 60px;
}
h2.doc {
margin-left: 20px;
}
p.doc {
margin-left: 100px;
}
table.export_form {
font-size: 75%;
width: 400px;
border-spacing: 10px;
border-collapse: separate;
}
table.export_form tr td {
font-size: 11px;
text-align: left;
vertical-align: top;
padding: 4px;
}
table.form tr td {
vertical-align: top;
padding: 4px;
}
.attribute_failed {
color: red;
}
img.chooser {
/* This makes the chooser image line up properly when placed next to a form element in a table cell*/
vertical-align: bottom;
}

55
htdocs/delete.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete.php,v 1.24.2.3 2005/12/11 08:21:03 wurley Exp $
/**
* Deletes a DN and presents a "job's done" message.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as POST vars:
* - dn (rawurlencoded)
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = $_POST['dn'];
if (is_null($dn))
pla_error(_('You must specify a DN'));
if (! $ldapserver->dnExists($dn))
pla_error(sprintf(_('No such entry: %s'),'<b>'.pretty_print_dn($dn).'</b>'));
# Check the user-defined custom callback first.
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn)))
$del_result = $ldapserver->delete($dn);
else
pla_error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($dn).'</b>'));
if ($del_result) {
# Custom callback
run_hook('post_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn));
include './header.php';
echo '<body>';
echo '<script type="text/javascript" language="javascript">parent.left_frame.location.reload();</script>';
echo '<br /><br />';
printf('<center>'._('Entry %s deleted successfully.').'</center>','<b>'.pretty_print_dn($dn).'</b>');
echo '</body>';
} else {
pla_error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($dn).'</b>'),
$ldapserver->error(),$ldapserver->errno());
}
echo '</html>';
?>

54
htdocs/delete_attr.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete_attr.php,v 1.14.2.5 2005/12/09 14:29:37 wurley Exp $
/**
* Deletes an attribute from an entry with NO confirmation.
*
* Variables that come in via common.php
* - server_id
*
* On success, redirect to template_engine.php
* On failure, echo an error.
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = isset($_POST['dn']) ? $_POST['dn'] : null;
$attr = isset($_POST['attr']) ? $_POST['attr'] : null;
if (! $dn)
pla_error(_('No DN specified'));
if (! $attr)
pla_error(_('No attribute name specified.'));
$encoded_dn = rawurlencode($dn);
if ($ldapserver->isAttrReadOnly($attr))
pla_error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),htmlspecialchars($attr)));
$update_array = array();
$update_array[$attr] = array();
$res = $ldapserver->modify($dn,$update_array);
if ($res) {
$redirect_url = sprintf('template_engine.php?server_id=%s&dn=%s',$ldapserver->server_id,$encoded_dn);
foreach($update_array as $attr => $junk)
$redirect_url .= "&modified_attrs[]=$attr";
header("Location: $redirect_url");
} else {
pla_error(_('Could not perform ldap_modify operation.'),$ldapserver->error(),$ldapserver->errno());
}
?>

153
htdocs/delete_form.php Normal file
View File

@@ -0,0 +1,153 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete_form.php,v 1.20.4.6 2006/04/29 04:05:14 wurley Exp $
/**
* delete_form.php
* Displays a last chance confirmation form to delete a dn.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars:
* - dn (rawurlencoded)
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = $_GET['dn'];
$children = $ldapserver->getContainerContents($dn,0,'(objectClass=*)',LDAP_DEREF_NEVER);
$has_children = count($children) > 0 ? true : false;
include './header.php';
echo '<body>';
printf('<h3 class="title">'._('Delete %s').'</h3>',htmlspecialchars(get_rdn($dn)));
printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn));
echo "\n";
echo '<center>';
if ($has_children) {
printf('<b>%s</b><br /><br />',_('Permanently delete all children also?'));
flush();
# get the total number of child objects (whole sub-tree)
$s = $ldapserver->search(null,dn_escape($dn),'objectClass=*',array('dn'));
$sub_tree_count = count($s);
echo '<table class="delete_confirm">';
echo '<tr>';
echo '<td><p>';
printf(_('This entry is the root of a sub-tree containing %s entries.'),$sub_tree_count);
printf('<small>(<a href="search.php?search=true&amp;server_id=%s&amp;filter=%s&amp;base_dn=%s&amp;form=advanced&amp;scope=sub">%s</a>)</small>',
$ldapserver->server_id,rawurlencode('objectClass=*'),rawurlencode($dn),_('view entries'));
echo '<br /><br />';
printf(_('phpLDAPadmin can recursively delete this entry and all %s of its children. See below for a list of all the entries that this action will delete. Do you want to do this?'),($sub_tree_count-1));
echo '<br /><br />';
printf('<small>%s</small>',
_('Note: this is potentially very dangerous and you do this at your own risk. This operation cannot be undone. Take into consideration aliases, referrals, and other things that may cause problems.'));
echo '<br /><br />';
echo "\n";
echo '<table width="100%">';
echo '<tr>';
echo '<td><center>';
echo '<form action="rdelete.php" method="post">';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($dn));
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="submit" class="scary" value="%s" />',sprintf(_('Delete all %s objects'),$sub_tree_count));
echo '</form>';
echo '</center></td>';
echo '<td><center>';
echo '<form action="template_engine.php" method="get">';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($dn));
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="submit" name="submit" value="%s" class="cancel" />',_('Cancel'));
echo '</form>';
echo '</center></td>';
echo '</tr>';
echo '</table>';
echo "\n";
echo '</td>';
echo '</tr>';
echo '</table>';
echo "\n";
flush();
echo '<br /><br />';
echo _('List of entries to be deleted:');
echo '<br />';
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,$sub_tree_count));
$i=0;
foreach ($s as $dn => $junk) {
$i++;
printf('<option>%s. %s</option>',$i,htmlspecialchars(dn_unescape($dn)));
}
echo '</select>';
echo "\n";
} else {
echo '<table class="delete_confirm">';
echo '<tr>';
echo '<td nowrap>';
echo _('Are you sure you want to permanently delete this object?');
echo '<br /><br />';
printf('<acronym title="%s">%s</acronym>: <b>%s</b>',_('Distinguished Name'),_('DN'),pretty_print_dn($dn));
echo '<br />';
printf('%s: <b>%s</b>',_('Server'),htmlspecialchars($ldapserver->name));
echo '<br /><br />';
echo "\n";
echo '<table width="100%">';
echo '<tr>';
echo '<td><center>';
echo '<form action="delete.php" method="post">';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($dn));
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="submit" name="submit" value="%s" class="scary" />',_('Delete'));
echo '</form>';
echo '</center></td>';
echo '<td><center>';
echo '<form action="template_engine.php" method="get">';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($dn));
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="submit" name="submit" value="%s" class="cancel" />',_('Cancel'));
echo '</form>';
echo '</center></td>';
echo '</tr>';
echo '</table>';
echo "\n";
echo '</td>';
echo '</tr>';
echo '</table>';
echo "\n";
}
echo '</center>';
echo '<br />';
echo '</body>';
echo '</html>';
?>

View File

@@ -0,0 +1,39 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/download_binary_attr.php,v 1.13.2.3 2005/12/08 11:49:28 wurley Exp $
/**
* @package phpLDAPadmin
* Variables that come in via common.php
* - server_id
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = rawurldecode($_GET['dn']);
$attr = $_GET['attr'];
# if there are multiple values in this attribute, which one do you want to see?
$value_num = isset($_GET['value_num']) ? $_GET['value_num'] : null;
if (! $ldapserver->dnExists($dn))
pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn)));
$search = $ldapserver->search(null,$dn,'(objectClass=*)',array($attr),'base',false,$config->GetValue('deref','view'));
# Dump the binary data to the browser
header('Content-type: octet-stream');
header("Content-disposition: attachment; filename=$attr");
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
if ($value_num && is_array($search[$attr][$dn]))
echo $search[$dn][$attr][$value_num];
else
echo $search[$dn][$attr];
?>

117
htdocs/entry_chooser.php Normal file
View File

@@ -0,0 +1,117 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/entry_chooser.php,v 1.27.2.5 2008/11/28 14:21:37 wurley Exp $
/**
* Display a selection (popup window) to pick a DN.
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
$container = isset($_GET['container']) ? rawurldecode($_GET['container']) : false;
$return_form_element = isset($_GET['form_element']) ? htmlspecialchars($_GET['form_element']) : null;
$rdn = isset($_GET['rdn']) ? htmlspecialchars($_GET['rdn']) : null;
include "./header.php";
printf('<h3 class="subtitle">%s</h3>',_('Entry Chooser'));
flush();
?>
<script type="text/javascript" language="javascript">
function returnDN(dn) {
opener.document.<?php echo $return_form_element; ?>.value = dn;
close();
}
</script>
<?php
if ($container) {
printf('%s<b>%s</b>',_('Server: '),htmlspecialchars($ldapserver->name));
echo '<br />';
printf('%s<b>%s</b>',_('Looking in: '),htmlspecialchars($container));
echo '<br />';
}
/* Has the use already begun to descend into a specific server tree? */
if (isset($ldapserver) && $container !== false) {
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn_list = $ldapserver->getContainerContents($container,0,'(objectClass=*)',$config->GetValue('deref','tree'));
sort($dn_list);
foreach ($ldapserver->getBaseDN() as $base_dn) {
if (DEBUG_ENABLED)
debug_log('entry_chooser.php: Comparing BaseDN [%s] with container [%s]',64,$base_dn,$container);
if (! pla_compare_dns($container,$base_dn)) {
$parent_container = false;
$up_href = sprintf('entry_chooser.php?form_element=%s&amp;rdn=%s',$return_form_element,$rdn);
break;
} else {
$parent_container = get_container($container);
$up_href = sprintf('entry_chooser.php?form_element=%s&amp;rdn=%s&amp;server_id=%s&amp;container=%s',
$return_form_element,$rdn,$ldapserver->server_id,rawurlencode($parent_container));
}
}
echo '&nbsp;';
printf('<a href="%s" style="text-decoration:none"><img src="images/up.png" /> %s</a>',$up_href,_('Back Up...'));
echo '<br />';
if (! count($dn_list))
printf('&nbsp;&nbsp;&nbsp;(%s)<br />',_('no entries'));
else
foreach ($dn_list as $dn) {
$href = sprintf("javascript:returnDN('%s%s')",
($rdn ? '"'.htmlspecialchars(dn_js_escape($rdn)).',"' : ''),
htmlspecialchars(dn_js_escape($dn)));
echo '&nbsp;&nbsp;&nbsp;';
printf('<a href="entry_chooser.php?server_id=%s&amp;form_element=%s&amp;rdn=%s&amp;container=%s"><img src="images/plus.png" /></a>',
$ldapserver->server_id,$return_form_element,$rdn,rawurlencode($dn));
printf('<a href="%s">%s</a>',$href,htmlspecialchars($dn));
echo '<br />';
}
/* draw the root of the selection tree (ie, list all the servers) */
} else {
foreach ($ldapservers->GetServerList() as $id) {
$ldapserver = $ldapservers->Instance($id);
if ($ldapserver->isVisible()) {
if (! $ldapserver->haveAuthInfo())
continue;
else {
printf('<b>%s</b>',htmlspecialchars($ldapserver->name));
echo '<br />';
foreach ($ldapserver->getBaseDN() as $dn) {
if (! $dn) {
printf('<small>&nbsp;&nbsp;&nbsp;(%s)</small><br />',_('Could not determine base DN'));
} else {
$href = sprintf("javascript:returnDN('%s%s')",($rdn ? "$rdn," : ''),$dn);
echo '&nbsp;&nbsp;&nbsp;';
printf('<a href="entry_chooser.php?server_id=%s&amp;form_element=%s&amp;rdn=%s&amp;container=%s"><img src="images/plus.png" /></a> ',
$ldapserver->server_id,$return_form_element,$rdn,rawurlencode($dn));
printf('<a href="%s">%s</a>',$href,htmlspecialchars($dn));
echo '<br />';
}
}
}
}
}
}
?>

45
htdocs/expand.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/expand.php,v 1.22.4.3 2007/03/18 03:16:05 wurley Exp $
/**
* This script alters the session variable 'tree', expanding it
* at the dn specified in the query string.
*
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars:
* - dn (rawurlencoded)
*
* Note: this script is equal and opposite to collapse.php
* @package phpLDAPadmin
* @see collapse.php
*/
/**
*/
require './common.php';
no_expire_header();
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
# This allows us to display large sub-trees without running out of time.
@set_time_limit(0);
$dn = $_GET['dn'];
# We dont need this result, as we'll use the SESSION value when we call tree.php
$ldapserver->getContainerContents($dn,0,'(objectClass=*)',$config->GetValue('deref','tree'));
$tree = get_cached_item($ldapserver->server_id,'tree');
$tree['browser'][$dn]['open'] = true;
set_cached_item($ldapserver->server_id,'tree','null',$tree);
/* If cookies were disabled, build the url parameter for the session id.
It will be append to the url to be redirect */
$id_session_param = '';
if (SID != '')
$id_session_param = sprintf('&%s=%s',session_name(),session_id());
header(sprintf('Location:tree.php?foo=%s#%s_%s%s',random_junk(),$ldapserver->server_id,rawurlencode($dn),$id_session_param));
?>

111
htdocs/export.php Executable file
View File

@@ -0,0 +1,111 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/export.php,v 1.15.4.6 2005/12/10 12:03:44 wurley Exp $
/**
* @package phpLDAPadmin
*/
/**
*/
# Fix a bug with IE:
ini_set('session.cache_limiter','');
require './common.php';
require LIBDIR.'export_functions.php';
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$base_dn = isset($_POST['dn']) ? $_POST['dn']:NULL;
$format = isset($_POST['format']) ? $_POST['format'] : 'unix';
$scope = isset($_POST['scope']) ? $_POST['scope'] : 'base';
$filter = isset($_POST['filter']) ? $_POST['filter'] : 'objectclass=*';
$target = isset($_POST['target']) ? $_POST['target'] : 'display';
$save_as_file = isset($_POST['save_as_file']) && $_POST['save_as_file'] == 'on';
if (isset($_POST['filter'])) {
preg_replace('/\s+/','',$_POST['filter']);
$attributes = split(',',preg_replace('/\s+/','',$_POST['attributes']));
} else {
$attributes = array();
}
# add system attributes if needed
if (isset($_POST['sys_attr'])) {
array_push($attributes,'*');
array_push($attributes,'+');
}
isset($_POST['exporter_id']) or pla_error(_('You must choose an export format.'));
$exporter_id = $_POST['exporter_id'];
isset($exporters[$exporter_id]) or pla_error(_('Invalid export format'));
# Initialisation of other variables
$friendly_rdn = get_rdn($base_dn,1);
$extension = $exporters[$exporter_id]['extension'];
# default case not really needed
switch ($format) {
case 'win':
$br = "\r\n";
break;
case 'mac':
$br = "\r";
break;
case 'unix':
default:
$br = "\n";
}
# get the decoree,ie the source
$plaLdapExporter = new PlaLdapExporter($ldapserver->server_id,$filter,$base_dn,$scope,$attributes);
# the decorator do it that way for the moment
$exporter = null;
switch ($exporter_id) {
case 0:
$exporter = new PlaLdifExporter($plaLdapExporter);
break;
case 1:
$exporter = new PlaDsmlExporter($plaLdapExporter);
break;
case 2:
$exporter = new PlaVcardExporter($plaLdapExporter);
break;
case 3:
$exporter = new PlaCSVExporter($plaLdapExporter);
break;
default:
# truly speaking,this default case will never be reached. See check at the bottom.
pla_error(_('No available exporter found.'));
}
# set the CLRN
$exporter->setOutputFormat($br);
if (isset($_REQUEST['compress']) && $_REQUEST['compress'] = 'on')
$exporter->compress(true);
# prevent script from bailing early for long search
@set_time_limit(0);
# send the header
if ($save_as_file)
header('Content-type: application/download');
else
header('Content-type: text/plain');
header(sprintf('Content-Disposition: filename="%s.%s"',$friendly_rdn,$exporters[$exporter_id]['extension'].($exporter->isCompressed()?'.gz':'')));
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: post-check=0, pre-check=0', false);
# and export
$exporter->export();
?>

165
htdocs/export_form.php Executable file
View File

@@ -0,0 +1,165 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/export_form.php,v 1.22.4.7 2007/03/18 03:16:05 wurley Exp $
/**
* export_form.php
* Html form to choose an export format(ldif,...)
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
require LIBDIR.'export_functions.php';
$format = isset($_GET['format']) ? $_GET['format'] : get_line_end_format();
$scope = isset($_GET['scope']) ? $_GET['scope'] : 'base' ;
$exporter_id = isset($_GET['exporter_id']) ? $_GET['exporter_id'] : 0 ;
$dn = isset($_GET['dn']) ? $_GET['dn'] : null;
$filter = isset($_GET['filter']) ? $_GET['filter'] : '(objectClass=*)';
$attributes = isset($_GET['attributes']) ? $_GET['attributes'] : '*';
$sys_attr = isset($_GET['sys_attr']) && $_GET['sys_attr'] == 'true' ? true : false;
$available_formats = array (
'unix' => 'UNIX (Linux, BSD)',
'mac' => 'Macintosh',
'win' => 'Windows'
);
$available_scopes = array (
'base' => _('Base (base dn only)'),
'one' => _('One (one level beneath base)'),
'sub' => _('Sub (entire subtree)')
);
include './header.php';
echo '<body>';
printf('<h3 class="title">%s</h3>',_('Export'));
echo '<br />';
echo '<center>';
echo '<form name="export_form" action="export.php" method="post">';
echo '<table class="export_form">';
echo '<tr>';
echo '<td>';
echo '<fieldset>';
printf('<legend>%s</legend>',_('Export'));
echo '<table>';
printf('<tr><td>%s</td><td>%s</td></tr>',_('Server'),server_select_list());
echo '<tr>';
printf('<td style="white-space:nowrap">%s</td>',_('Base DN'));
printf('<td><span style="white-space: nowrap;"><input type="text" name="dn" id="dn" style="width:230px" value="%s" />&nbsp;',htmlspecialchars($dn));
draw_chooser_link('export_form.dn');
echo '</span></td>';
echo '</tr>';
echo '<tr>';
printf('<td><span style="white-space: nowrap">%s</span></td>',_('Search Scope'));
echo '<td>';
foreach ($available_scopes as $id => $desc)
printf('<input type="radio" name="scope" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
htmlspecialchars($id),htmlspecialchars($id),($id == $scope) ? 'checked="true"' : '',
htmlspecialchars($id),htmlspecialchars($desc));
echo '</td>';
echo '</tr>';
printf('<tr><td>%s</td><td><input type="text" name="filter" style="width:300px" value="%s" /></td></tr>',
_('Search Filter'),htmlspecialchars($filter));
printf('<tr><td>%s</td><td><input type="text" name="attributes" style="width:300px" value="%s" /></td></tr>',
_('Show Attributtes'),htmlspecialchars($attributes));
printf('<tr><td>&nbsp;</td><td><input type="checkbox" name="sys_attr" id="sys_attr" %s/> <label for="sys_attr">%s</label></td></tr>',
$sys_attr ? 'checked="true" ' : '',_('Include system attributes'));
printf('<tr><td>&nbsp;</td><td><input type="checkbox" id="save_as_file" name="save_as_file" onclick="toggle_disable_field_saveas(this)" /> <label for="save_as_file">%s</label></td></tr>',
_('Save as file'));
printf('<tr><td>&nbsp;</td><td><input type="checkbox" id="compress" name="compress" disabled /> <label for="compress">%s</label></td></tr>',
_('Compress'));
echo '</table>';
echo '</fieldset>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '<table style="width: 100%">';
echo '<tr><td style="width: 50%">';
echo '<fieldset style="height: 100px">';
printf('<legend>%s</legend>',_('Export format'));
foreach ($exporters as $index => $exporter) {
printf('<input type="radio" name="exporter_id" id="exporter_id_%s" value="%s"%s />',
htmlspecialchars($index),htmlspecialchars($index),($index==$exporter_id) ? ' checked="true"' : '');
printf('<label for="%s">%s</label><br />',
htmlspecialchars($index),htmlspecialchars($exporter['desc']));
}
echo '</fieldset>';
echo '</td>';
echo '<td style="width: 50%">';
echo '<fieldset style="height: 100px">';
printf('<legend>%s</legend>',_('Line ends'));
foreach ($available_formats as $id => $desc)
printf('<input type="radio" name="format" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
htmlspecialchars($id),htmlspecialchars($id),($format==$id) ? ' checked="true"' : '',
htmlspecialchars($id),htmlspecialchars($desc));
echo '</fieldset>';
echo '</td></tr>';
echo '</table>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan="2">';
printf('<center><input type="submit" name="target" value="%s" /></center>',
htmlspecialchars(_('Proceed >>')));
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</form>';
echo '</center>';
/**
* Helper functoin for fetching the line end format.
* @return String 'win', 'unix', or 'mac' based on the user's browser..
*/
function get_line_end_format() {
if (is_browser_os_windows())
return 'win';
elseif (is_browser_os_unix())
return 'unix';
elseif (is_browser_os_mac())
return 'mac';
else
return 'unix';
}
?>
<script type="text/javascript" language="javascript">
<!--
function toggle_disable_field_saveas(id) {
if (id.checked) {
id.form.compress.disabled = false;
} else {
id.form.compress.disabled = true;
id.form.compress.checked = false;
}
}
-->
</script>
</body>
</html>

58
htdocs/header.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/header.php,v 1.21.2.4 2006/04/29 03:14:45 wurley Exp $
/**
* @package phpLDAPadmin
*/
/* We want to get $language into scope in case we were included
from within a function */
$language = isset($config) ? $language = $config->GetValue('appearance','language') : 'auto';
# text/xml won't work with MSIE, but is very useful for debugging xhtml code.
# header('Content-type: text/xml; charset="UTF-8"');
@header('Content-type: text/html; charset="UTF-8"');
# XML version and encoding for well-behaved browsers
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'."\n";
echo '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="%s" lang="%s" dir="ltr">',$language,$language);
echo "\n\n";
echo '<head>';
if (isset($config) && $pagetitle = $config->GetValue('appearance','page_title'))
printf('<title>phpLDAPadmin - %s</title>',$pagetitle);
else
echo '<title>phpLDAPadmin</title>';
printf('<link type="text/css" rel="stylesheet" href="%sstyle.css" media="screen" />',CSSDIR);
if (isset($server_id)) {
$custom_file = get_custom_file($server_id,'style.css',CSSDIR);
if (strcmp($custom_file,'style.css') != 0)
printf('<link type="text/css" rel="stylesheet" href="%s" media="screen" />',$custom_file);
}
printf('<script type="text/javascript" src="%sentry_chooser.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sie_png_work_around.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%ssearch_util.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sgeneric_utils.js"></script>',JSDIR);
printf('<link type="text/css" rel="stylesheet" media="all" href="%s/jscalendar/calendar-blue.css" title="blue" />',JSDIR);
printf('<script type="text/javascript" src="%sjscalendar/calendar.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sjscalendar/lang/calendar-en.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sjscalendar/calendar-setup.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sdate_selector.js"></script>',JSDIR);
printf('<link type="text/css" rel="stylesheet" href="%s/phplayersmenu/layerstreemenu.css"></link>',JSDIR);
if (isset($meta_refresh_variable))
printf('<meta http-equiv="refresh" content="%s" />',$meta_refresh_variable);
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
echo '</head>';
echo "\n\n";
?>

28
htdocs/help.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/Attic/help.php,v 1.5 2005/02/26 12:35:05 wurley Exp $
/**
* @package phpLDAPadmin
*/
/**
*/
include './common.php';
include './header.php';
$forum_href = get_href( 'forum' );
?>
<body>
<h3 class="title">Help</h3>
<br />
<center>
<p>Do you have a problem or question?</p>
<p>Perhaps you are new to LDAP and need a little guidance?</p>
<p>Help is only one click away. Visit the online <a href="<?php echo $forum_href; ?>">phpLDAPadmin support forum</a>.</p>
<br />
</center>
</body>
</html>

BIN
htdocs/images/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

View File

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 278 B

BIN
htdocs/images/calendar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

BIN
htdocs/images/catalog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
htdocs/images/children.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

BIN
htdocs/images/compare.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Some files were not shown because too many files have changed in this diff Show More