RELEASE 0.9.1
This commit is contained in:
parent
763843c16a
commit
ed7caca53b
63
INSTALL
63
INSTALL
@ -1,40 +1,49 @@
|
||||
These instructions assume that you have a working install of:
|
||||
a. A web server (Apache, IIS, etc).
|
||||
b. PHP (with LDAP support)
|
||||
a. A web server (Apache, IIS, etc).
|
||||
b. PHP (with LDAP support)
|
||||
|
||||
Installing phpLDAPAdmin in 4 easy steps:
|
||||
* Installing phpLDAPadmin in 4 easy steps:
|
||||
|
||||
1. Untar the archive (if you're reading this, you've already done that).
|
||||
2. Put the resulting phpldapadmin directory somewhere in your webroot.
|
||||
3. Copy 'config.php.example' to 'config.php' and edit to taste.
|
||||
4. Then, point your browser to the phpldapadmin directory.
|
||||
1. Untar 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.
|
||||
4. Then, point your browser to the phpldapadmin directory.
|
||||
|
||||
Browsers
|
||||
* Browser Notes
|
||||
|
||||
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.
|
||||
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!)
|
||||
* Contributors (thank you!)
|
||||
|
||||
Project Developers:
|
||||
|
||||
- David Smith Maintainer
|
||||
- Xavier Renard LDIF master
|
||||
- Nate Rotschafer Release manager
|
||||
|
||||
Patch writers:
|
||||
|
||||
- Mario Valdez jpegPhoto support, localization (not yet in 0.8.x), html fixes
|
||||
- Bayu Irawan userPassword encryption support, html fixes, ldap_modify fixes
|
||||
- Uwe Ebel short_open_tags fix-it script
|
||||
- Philippe Broussard form auth_type bug report
|
||||
- Andrew Tipton SUP support in schema-fetching
|
||||
- Eigil Bjørgum UTF-8 support
|
||||
- Brandon Lederer DNS entry template
|
||||
- Bayu Irawan userPassword hash, html fixes, ldap_modify fixes
|
||||
- Uwe Ebel short_open_tags fix
|
||||
- Andrew Tipton SUP support in schema parser
|
||||
- Eigil Bjørgum UTF-8 support
|
||||
- Brandon Lederer DNS entry template
|
||||
Nathan Rotschafer
|
||||
- Steve Rigler Password hash patch
|
||||
- Chric Jackson Blowfish and md5crypt passwords
|
||||
- Steve Rigler Password hash patch
|
||||
- Chric Jackson Blowfish and md5crypt passwords
|
||||
- Marius Rieder Enhanced schema parser
|
||||
- Nick Burch Many realpath() fixes
|
||||
|
||||
Bug reporters:
|
||||
Translators:
|
||||
|
||||
- Colin Tinker (short_open_tags bug report)
|
||||
- Greg Felix (multi-value update bug report)
|
||||
- Moritz Mertinkat (creation bug report)
|
||||
- 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
|
||||
|
||||
|
@ -14,17 +14,19 @@
|
||||
* - new_attrs (array, if any)
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$dn = rawurldecode( $_POST['dn'] );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$new_oclass = stripslashes( $_POST['new_oclass'] );
|
||||
$new_oclass = $_POST['new_oclass'];
|
||||
$server_id = $_POST['server_id'];
|
||||
$new_attrs = $_POST['new_attrs'];
|
||||
|
||||
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( 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;
|
||||
@ -40,12 +42,12 @@ if( is_array( $new_attrs ) && count( $new_attrs ) > 0 )
|
||||
//print_r( $new_entry );
|
||||
//exit;
|
||||
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server." );
|
||||
$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( "Could not perform ldap_mod_add operation", ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
pla_error( $lang['could_not_perform_ldap_mod_add'], ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -15,16 +15,18 @@
|
||||
* - new_oclass
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$dn = rawurldecode( $_POST['dn'] );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$new_oclass = stripslashes( $_POST['new_oclass'] );
|
||||
$new_oclass = $_POST['new_oclass'];
|
||||
$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." );
|
||||
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
|
||||
@ -47,19 +49,19 @@ foreach( $must_attrs as $attr )
|
||||
|
||||
if( count( $needed_attrs ) > 0 )
|
||||
{
|
||||
?>
|
||||
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
include 'header.php'; ?>
|
||||
<body>
|
||||
|
||||
<h3 class="title">New Required Attributes</h3>
|
||||
<h3 class="subtitle">This action requires you to add <?php echo count($needed_attrs); ?> new attribute<?php echo (count($needed_attrs)>1?'s':''); ?></h3>
|
||||
<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>
|
||||
Instrucitons: In order to add the objectClass <b><?php echo $new_oclass; ?></b> to the object <b><?php echo htmlspecialchars($dn); ?></b>,
|
||||
you must specify <?php echo count( $needed_attrs ); ?> new attribute<?php echo (count($needed_atts)>1?'s':''); ?> that this
|
||||
objectClass requires. You can do so in this form.</small>
|
||||
<?php
|
||||
echo $lang['new_required_attrs_instructions'];
|
||||
echo ' ' . count( $needed_attrs ) . ' ' . $lang['new_attributes'] . ' ';
|
||||
echo $lang['that_this_oclass_requires']; ?>
|
||||
</small>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
@ -70,7 +72,7 @@ if( count( $needed_attrs ) > 0 )
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
|
||||
<table class="edit_dn" cellspacing="0">
|
||||
<tr><th colspan="2">New Required Attributes</th></tr>
|
||||
<tr><th colspan="2"><?php echo $lang['new_required_attrs']; ?></th></tr>
|
||||
|
||||
<?php foreach( $needed_attrs as $count => $attr ) { ?>
|
||||
<?php if( $count % 2 == 0 ) { ?>
|
||||
@ -86,7 +88,7 @@ if( count( $needed_attrs ) > 0 )
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
<center><input type="submit" value="Add ObjectClass and Attributes" /></center>
|
||||
<center><input type="submit" value="<?php echo $lang['add_oclass_and_attrs']; ?>" /></center>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
@ -8,36 +8,40 @@
|
||||
* - 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 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$dn = rawurldecode( $_POST['dn'] );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$attr = stripslashes( $_POST['attr'] );
|
||||
$attr = $_POST['attr'];
|
||||
$encoded_attr = rawurlencode( $attr );
|
||||
$server_id = $_POST['server_id'];
|
||||
$new_value = stripslashes( $_POST['new_value'] );
|
||||
$new_value = $_POST['new_value'];
|
||||
$new_value = utf8_encode($new_value);
|
||||
$is_binary_val = isset( $_POST['binary'] ) ? true : 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." );
|
||||
if( is_server_read_only( $server_id ) )
|
||||
pla_error( $lang['no_updates_in_read_only_mode'] );
|
||||
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
|
||||
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'] );
|
||||
|
||||
// special case for jpegPhoto attributes:
|
||||
$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( 0 == strcasecmp( $attr, 'jpegPhoto' ) )
|
||||
if( $is_binary_val )
|
||||
{
|
||||
$file = $_FILES['jpeg_photo_file']['tmp_name'];
|
||||
$file = $_FILES['new_value']['tmp_name'];
|
||||
$f = fopen( $file, 'r' );
|
||||
$jpeg_data = fread( $f, filesize( $file ) );
|
||||
$binary_value = fread( $f, filesize( $file ) );
|
||||
fclose( $f );
|
||||
$new_value = $jpeg_data;
|
||||
$new_value = $binary_value;
|
||||
}
|
||||
|
||||
$new_entry = array( $attr => $new_value );
|
||||
@ -45,7 +49,7 @@ $new_entry = array( $attr => $new_value );
|
||||
$add_result = @ldap_mod_add( $ds, $dn, $new_entry );
|
||||
|
||||
if( ! $add_result )
|
||||
pla_error( "Could not perform ldap_mod_add operation.", ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
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" );
|
||||
|
||||
|
@ -11,34 +11,36 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require 'common.php';
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$dn = stripslashes( $_GET['dn'] );
|
||||
$dn = $_GET['dn'];
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = pla_explode_dn( $dn );
|
||||
$rdn = $rdn[0];
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
$attr = stripslashes( $_GET['attr'] );
|
||||
$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;
|
||||
|
||||
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( 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 );
|
||||
if( ! is_array( $current_values ) )
|
||||
$current_values = array( $current_values );
|
||||
foreach( $current_values as $oclass )
|
||||
unset( $schema_oclasses[ strtolower( $oclass ) ] );
|
||||
} else {
|
||||
$schema_attrs = get_schema_attributes( $server_id );
|
||||
$schema_attr = get_schema_attribute( $server_id, $attr );
|
||||
}
|
||||
|
||||
?>
|
||||
@ -47,11 +49,18 @@ if( $is_object_class ) {
|
||||
|
||||
<body>
|
||||
|
||||
<h3 class="title">New <b><?php echo htmlspecialchars($attr); ?></b> value for <b><?php echo htmlentities($rdn); ?></b></h3>
|
||||
<h3 class="subtitle">Server: <b><?php echo $server_name; ?></b> Distinguished Name: <b><?php echo $dn; ?></b></h3>
|
||||
<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>
|
||||
<?php echo $lang['distinguished_name']; ?>: <b><?php echo htmlspecialchars( $dn ); ?></b></h3>
|
||||
|
||||
Current list of <b><?php echo $num_current_values; ?></b> value<?php echo $num_current_values>1?'s':''; ?>
|
||||
for attribute <b><?php echo htmlspecialchars($attr); ?></b>:
|
||||
<?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 ) { ?>
|
||||
|
||||
@ -61,8 +70,23 @@ Current list of <b><?php echo $num_current_values; ?></b> value<?php echo $num_c
|
||||
|
||||
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
||||
<p><small>
|
||||
Note: You will get an "inappropriate matching" error if you have not<br />
|
||||
setup an <tt>EQUALITY</tt> rule on your LDAP server for <tt>jpegPhoto</tt> attributes.
|
||||
<?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&dn=$encoded_dn&attr=$attr&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&dn=$encoded_dn&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 -->
|
||||
|
||||
@ -84,7 +108,8 @@ Current list of <b><?php echo $num_current_values; ?></b> value<?php echo $num_c
|
||||
|
||||
<?php } ?>
|
||||
|
||||
Enter the value you would like to add:<br />
|
||||
<?php echo $lang['enter_value_to_add']; ?>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<?php if( $is_object_class ) { ?>
|
||||
@ -102,29 +127,31 @@ Enter the value you would like to add:<br />
|
||||
|
||||
</select> <input type="submit" value="Add new objectClass" />
|
||||
|
||||
<br /><small>Note: you may be required to enter new attributes<br />
|
||||
that this objectClass requires (MUST attrs)</small>
|
||||
|
||||
<?php } elseif( $is_jpeg_photo ) { ?>
|
||||
|
||||
<form action="add_value.php" method="post" class="new_value" 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; ?>" />
|
||||
<input type="file" name="jpeg_photo_file" value="" /><br />
|
||||
<br />
|
||||
<input type="submit" name="submit" value="Add new jpeg >>" />
|
||||
<br /><small><?php echo $lang['new_required_attrs_note']; ?></small>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<form action="add_value.php" method="post" class="new_value">
|
||||
<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; ?>" />
|
||||
<input type="text" name="new_value" size="40" value="" />
|
||||
|
||||
<?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>Syntax: <?php echo $schema_attrs[ strtolower($attr) ]['type']; ?></small>
|
||||
<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 } ?>
|
||||
|
22
collapse.php
22
collapse.php
@ -12,18 +12,20 @@
|
||||
* Note: this script is equal and opposite to expand.php
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( $_GET['dn'] );
|
||||
$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();
|
||||
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." );
|
||||
|
||||
// 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
|
||||
@ -38,6 +40,12 @@ session_write_close();
|
||||
$time = gettimeofday();
|
||||
$random_junk = md5( strtotime( 'now' ) . $time['usec'] );
|
||||
|
||||
header( "Location: tree.php?foo=$random_junk#{$server_id}_{$encoded_dn}" );
|
||||
// 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" );
|
||||
?>
|
||||
|
53
common.php
Normal file
53
common.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
?>
|
@ -1,22 +1,24 @@
|
||||
<?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.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// Required Configuration
|
||||
|
||||
// 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
|
||||
$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
|
||||
@ -26,8 +28,17 @@ $servers[$i]['login_dn'] = 'cn=Manager,dc=example,dc=com'; /* For anonymous bind
|
||||
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 an additional LDAP server, do so below. */
|
||||
|
||||
/* If you want to configure additional LDAP servers, do so below. */
|
||||
$i++;
|
||||
$servers[$i]['name'] = 'Another server';
|
||||
$servers[$i]['host'] = '';
|
||||
@ -37,68 +48,56 @@ $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;
|
||||
|
||||
$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;
|
||||
|
||||
/* If you want to configure more LDAP servers, copy and paste the sections above (including the "$i++;") */
|
||||
|
||||
// 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"; // for Unix systems
|
||||
//$jpeg_temp_dir = "c:\\temp"; // for Windows systems
|
||||
|
||||
|
||||
// Optional Configuration Below
|
||||
// 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;
|
||||
$cookie_time = 0; // seconds
|
||||
|
||||
// How many pixels wide do you want your left frame view (for the tree browser)
|
||||
$tree_width = 300;
|
||||
$tree_width = 300; // pixels
|
||||
|
||||
// Do you want phpLDAPAdmin to check the schema of the server when you edit a DN and draw
|
||||
// specialized for elements based on that schema (ie, for booleans, draw a true/false
|
||||
// drop-down instead of a text box). This may cause a performance slow-down.
|
||||
// Note:
|
||||
// This will have problems with non-LDAP compliant servers that do not properly represent
|
||||
// their schema.
|
||||
$edit_dn_schema_lookup = true;
|
||||
|
||||
// How long to keep jpegPhoto temporary files around (in seconds)
|
||||
$jpeg_tmp_keep_time = 120;
|
||||
// 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)
|
||||
$search_attributes = "uid, cn, gidNumber";
|
||||
// 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, Full Name, Group ID";
|
||||
$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";
|
||||
|
||||
// Search methods in the drop down box for the simple search form
|
||||
// (if you change this, you will also have to edit search.php to properly handle the new option)
|
||||
$search_criteria_options = "equals, starts with, contains, ends with, sounds like";
|
||||
|
||||
/** **/
|
||||
/** Templates for entry creation **/
|
||||
/** **/
|
||||
@ -106,17 +105,17 @@ $search_criteria_options = "equals, starts with, contains, ends with, sounds lik
|
||||
$templates = array();
|
||||
|
||||
// Fill in this array with templates that you can create to suit your needs.
|
||||
// Each entry defines a description (for display in the template list) and
|
||||
// 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 an example of how to make your own template.
|
||||
// See the templates provided here for examples of how to make your own template.
|
||||
|
||||
$templates[] =
|
||||
array( 'desc' => 'User',
|
||||
array( 'desc' => 'User Account',
|
||||
'icon' => 'images/user.png',
|
||||
'handler' => 'new_user_template.php' );
|
||||
|
||||
$templates[] =
|
||||
array( 'desc' => 'inetOrgPerson',
|
||||
array( 'desc' => 'Address Book Entry (inetOrgPerson)',
|
||||
'icon' => 'images/user.png',
|
||||
'handler' => 'new_address_template.php' );
|
||||
|
||||
@ -125,16 +124,32 @@ $templates[] =
|
||||
'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/terminal.png',
|
||||
'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 **/
|
||||
/** **/
|
||||
@ -147,17 +162,15 @@ $friendly_attrs = array();
|
||||
$friendly_attrs[ 'facsimileTelephoneNumber' ] = 'Fax';
|
||||
$friendly_attrs[ 'telephoneNumber' ] = 'Phone';
|
||||
|
||||
/** **/
|
||||
/** Some phpLDAPAdmin code to be executed. No touchy. **/
|
||||
/** **/
|
||||
/** **/
|
||||
/** Hidden attributes **/
|
||||
/** **/
|
||||
|
||||
// Turn off notices about referencing arrays and such, but leave everything else on.
|
||||
error_reporting( E_ALL ^ E_NOTICE );
|
||||
// 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:
|
||||
|
||||
// Always including the 'custom' template (the most generic and flexible)
|
||||
$templates['custom'] =
|
||||
array( 'desc' => 'Custom',
|
||||
'icon' => 'images/object.png',
|
||||
'handler' => 'custom.php' );
|
||||
//$hidden_attrs = array( 'jpegPhoto', 'objectClass' );
|
||||
|
||||
?>
|
||||
|
15
copy.php
15
copy.php
@ -10,17 +10,19 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
session_start();
|
||||
|
||||
$source_dn = stripslashes( rawurldecode( $_POST['old_dn'] ) );
|
||||
$dest_dn = stripslashes( $_POST['new_dn'] );
|
||||
$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 = $_POST['recursive'] == 'on' ? true : false;
|
||||
$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." );
|
||||
@ -72,6 +74,7 @@ if( $copy_result )
|
||||
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;
|
||||
@ -102,7 +105,7 @@ else
|
||||
|
||||
function r_copy_dn( $source_server_id, $dest_server_id, &$tree, $root_dn, $dest_dn )
|
||||
{
|
||||
echo "<nobr>Copying " . htmlspecialchars( utf8_decode( $root_dn ) ) . "...";
|
||||
echo "<nobr>Copying " . htmlspecialchars( $root_dn ) . "...";
|
||||
flush();
|
||||
$copy_result = copy_dn( $source_server_id, $root_dn, $dest_server_id, $dest_dn );
|
||||
|
||||
|
@ -8,13 +8,12 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_GET['dn'] ) );
|
||||
$dn = rawurldecode( $_GET['dn'] );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = pla_explode_dn( $dn );
|
||||
$container = $rdn[ 1 ];
|
||||
for( $i=2; $i<count($rdn)-1; $i++ )
|
||||
$container .= ',' . $rdn[$i];
|
||||
@ -42,11 +41,11 @@ $children = get_container_contents( $server_id, $dn );
|
||||
<?php include 'header.php'; ?>
|
||||
<body>
|
||||
|
||||
<h3 class="title">Copy <?php echo $rdn; ?></h3>
|
||||
<h3 class="title">Copy <?php echo utf8_decode( $rdn ); ?></h3>
|
||||
<h3 class="subtitle">Server: <b><?php echo $server_name; ?></b> Distinguished Name: <b><?php echo $dn; ?></b></h3>
|
||||
|
||||
<center>
|
||||
Copy <b><?php echo htmlspecialchars($rdn); ?></b> to a new object:<br />
|
||||
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; ?>" />
|
||||
@ -56,7 +55,7 @@ Copy <b><?php echo htmlspecialchars($rdn); ?></b> to a new object:<br />
|
||||
<tr>
|
||||
<td>Destination DN:</td>
|
||||
<td>
|
||||
<input type="text" name="new_dn" size="45" value="<?php echo htmlspecialchars($dn); ?>" />
|
||||
<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>
|
||||
|
44
create.php
44
create.php
@ -14,19 +14,21 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$new_dn = stripslashes( $_POST['new_dn'] );
|
||||
$new_dn = utf8_encode( $new_dn );
|
||||
$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 = $_POST['required_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." );
|
||||
|
||||
@ -40,8 +42,6 @@ if( isset( $required_attrs ) && is_array( $required_attrs ) )
|
||||
pla_error( "Error, you left the value for required attribute <b>" .
|
||||
htmlspecialchars( $attr ) . "</b> blank." );
|
||||
|
||||
$attr = stripslashes( $attr );
|
||||
$val = stripslashes( $val );
|
||||
$new_entry[ $attr ][] = utf8_encode( $val );
|
||||
}
|
||||
}
|
||||
@ -50,11 +50,22 @@ if( isset( $vals ) && is_array( $vals ) )
|
||||
{
|
||||
foreach( $vals as $i => $val )
|
||||
{
|
||||
$val = stripslashes( $val );
|
||||
$attr = $attrs[$i];
|
||||
$attr = stripslashes( $attr );
|
||||
if( trim($val) )
|
||||
$new_entry[ $attr ][] = utf8_encode( $val );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +73,16 @@ $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 )
|
||||
@ -77,6 +98,7 @@ if( $add_result )
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,14 @@
|
||||
* - container (rawurlencoded) (optional)
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_REQUEST['server_id'];
|
||||
$step = $_REQUEST['step'] ? $_REQUEST['step'] : 1; // defaults to 1
|
||||
$container = stripslashes( $_REQUEST['container'] );
|
||||
$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." );
|
||||
|
@ -10,17 +10,18 @@
|
||||
* template
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
|
||||
$template = stripslashes( $_POST['template'] );
|
||||
$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';
|
||||
|
||||
?>
|
||||
@ -36,6 +37,7 @@ 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
|
||||
|
@ -9,16 +9,18 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$encoded_dn = $_POST['dn'];
|
||||
$dn = stripslashes( rawurldecode( $encoded_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." );
|
||||
|
||||
|
42
delete_attr.php
Normal file
42
delete_attr.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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 ) );
|
||||
}
|
||||
|
||||
?>
|
@ -9,16 +9,18 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( $_GET['dn'] );
|
||||
$dn = $_GET['dn'];
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$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." );
|
||||
|
||||
@ -61,7 +63,7 @@ if( $has_children ) {
|
||||
|
||||
<p>This object is the root of a sub-tree containing <a href="search.php?search=true&server_id=<?php echo $server_id; ?>&filter=<?php echo rawurlencode('objectClass=*'); ?>&base_dn=<?php echo $encoded_dn; ?>&form=advanced&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
|
||||
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.
|
||||
|
28
download_binary_attr.php
Normal file
28
download_binary_attr.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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];
|
||||
|
||||
?>
|
577
edit.php
577
edit.php
@ -7,20 +7,22 @@
|
||||
* 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 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_GET['dn'] ) );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$updated_attr = stripslashes( $_GET['updated_attr'] );
|
||||
$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 = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = pla_explode_dn( $dn );
|
||||
$rdn = $rdn[0];
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
@ -42,19 +44,24 @@ if( ! is_array( $oclasses ) )
|
||||
$oclasses = array( $oclasses );
|
||||
$avail_attrs = array();
|
||||
$schema_oclasses = get_schema_objectclasses( $server_id, true );
|
||||
foreach( $oclasses as $oclass )
|
||||
$avail_attrs = array_merge( $schema_oclasses[ strtolower( $oclass ) ]['must_attrs'],
|
||||
$schema_oclasses[ strtolower( $oclass ) ]['may_attrs'],
|
||||
$avail_attrs );
|
||||
|
||||
$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 );
|
||||
|
||||
/* A boolean flag to indicate whether this entry has a jpegPhoto associated with it.
|
||||
* TODO If it does, the jpegPhotos will be drawn at the bottom of the form */
|
||||
$has_jpeg_photo = false;
|
||||
$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 ] );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -71,36 +78,42 @@ $has_jpeg_photo = false;
|
||||
<td><img src="images/refresh.png" /></td>
|
||||
<td><a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>&random=<?php
|
||||
echo $random_junk; ?>"
|
||||
title="Refresh this entry">Refresh</a></td>
|
||||
title="<?php echo $lang['refresh_this_entry']; ?>"><?php echo $lang['refresh']; ?></a></td>
|
||||
</tr>
|
||||
|
||||
<?php if( 0 != strcasecmp( $dn, $servers[$server_id]['base'] ) ) { ?>
|
||||
<?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; ?>&dn=<?php echo $encoded_dn; ?>"
|
||||
title="You will be prompted to confirm this decision">Delete this entry</a></td>
|
||||
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; ?>&dn=<?php echo $encoded_dn?>"
|
||||
title="Copy this object to another location, a new DN, or another server">Copy this entry</a></td>
|
||||
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&dn=$encoded_dn&scope=base"; ?>
|
||||
<td><a href="<?php echo $ldif_url; ?>" title="Save an LDIF dump of this object">Export to LDIF</a>
|
||||
(<a href="<?php echo $ldif_url; ?>&format=mac" title="Macintosh style carriage returns">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win" title="Windows style carriage returns">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=unix" title="Unix style carriage returns">unix</a>)
|
||||
<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; ?>&format=mac"
|
||||
title="<?php echo $lang['export_to_ldif_mac']; ?>">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win"
|
||||
title="<?php echo $lang['export_to_ldif_win']; ?>">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&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&container=$encoded_dn"; ?>">Create a child entry</a></td>
|
||||
<td><a href="<?php echo "create_form.php?server_id=$server_id&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 );
|
||||
@ -113,68 +126,74 @@ if( ($children_count = count( $children ) ) > 0 ) {
|
||||
|
||||
<tr>
|
||||
<td><img src="images/children.png" /></td>
|
||||
<td><a href="search.php?search=true&server_id=<?php echo $server_id; ?>&filter=<?php echo rawurlencode('objectClass=*'); ?>&base_dn=<?php echo $encoded_dn; ?>&form=advanced&scope=one">View <?php echo $children_count; ?> <?php echo ($children_count==1?'child':'children');?></a></td>
|
||||
<td><a href="search.php?search=true&server_id=<?php echo $server_id; ?>&filter=<?php echo rawurlencode('objectClass=*'); ?>&base_dn=<?php echo $encoded_dn; ?>&form=advanced&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&dn=$encoded_dn&scope=sub"; ?>
|
||||
<td><a href="<?php echo $ldif_url; ?>" title="Save an LDIF dump of this object and all of its children">Export subtree to LDIF</a>
|
||||
(<a href="<?php echo $ldif_url; ?>&format=mac" title="Macintosh style carriage returns">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win" title="Windows style carriage returns">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=unix" title="Unix style carriage returns">unix</a>)
|
||||
<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; ?>&format=mac" title="<?php echo $lang['export_to_ldif_mac'];?>">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win" title="<?php echo $lang['export_to_ldif_win'];?>">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=unix" title="<?php echo $lang['export_to_ldif_unix'];?>">unix</a>)
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php if( in_array( 'jpegPhoto', $avail_attrs ) ) { ?>
|
||||
|
||||
<?php $new_jpeg_href = "new_jpeg_photo_form.php?server_id=$server_id&dn=$encoded_dn&attr=jpegPhoto"; ?>
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<tr>
|
||||
<td><img src="images/photo.png" /></td>
|
||||
<td><a href="<?php echo $new_jpeg_href; ?>">Add a jpegPhoto</a></td>
|
||||
<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">
|
||||
|
||||
|
||||
<!-- Form to rename this entry -->
|
||||
<tr class="row1">
|
||||
<td class="heading"><acronym title="Change this entry's RDN">Rename Entry</acronym></td>
|
||||
<td class="heading" align="right">
|
||||
<?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="40" value="<?php echo htmlspecialchars( utf8_decode( $rdn ) ); ?>" />
|
||||
<input class="update_dn" type="submit" value="Rename" />
|
||||
<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>
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
<tr class="spacer"><td colspan="2"></td></tr>
|
||||
<?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>
|
||||
|
||||
<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; ?>" />
|
||||
|
||||
<!-- Form to add a new attribute to this entry -->
|
||||
<tr class="row1">
|
||||
<td class="heading">
|
||||
<nobr>
|
||||
<acronym title="Add a new attribute/value to this entry">Add New Attribute</acronym>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="heading" align="right"><nobr>
|
||||
<?php if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
|
||||
<?php if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
|
||||
|
||||
<select name="attr">
|
||||
<?php foreach( $avail_attrs as $a ) {
|
||||
@ -192,35 +211,75 @@ if( ($children_count = count( $children ) ) > 0 ) {
|
||||
} ?>
|
||||
</select>
|
||||
<input type="text" name="val" size="20" />
|
||||
<input type="submit" name="submit" value="Add" class="update_dn" />
|
||||
<input type="submit" name="submit" value="<?php echo $lang['add']; ?>" class="update_dn" />
|
||||
|
||||
<?php } else { ?>
|
||||
<?php } else { ?>
|
||||
|
||||
<small>(no new attributes available for this entry)</small>
|
||||
<small>(<?php echo $lang['no_new_attrs_available']; ?>)</small>
|
||||
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</nobr></td>
|
||||
</form>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php flush(); ?>
|
||||
<tr class="spacer"><td colspan="2"></td></tr>
|
||||
|
||||
<?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; ?>&dn=<?php echo $encoded_dn; ?>"
|
||||
><img src="images/minus.png" title="Hide internal attributes" /></a>
|
||||
<acronym title="Attributes set automatically by the system">Internal Attriubtes</acronym>
|
||||
><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; ?>&dn=<?php echo $encoded_dn; ?>&show_internal_attrs=true">
|
||||
<img src="images/plus.png" title="Show internal attributes" /></a>
|
||||
<acronym title="Attributes set automatically by the system (click + to display)">Internal Attriubtes</acronym>
|
||||
<small>(hidden)</small>
|
||||
<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 } ?>
|
||||
|
||||
@ -230,16 +289,20 @@ if( ($children_count = count( $children ) ) > 0 ) {
|
||||
<?php
|
||||
if( $show_internal_attrs ) {
|
||||
$counter = 0;
|
||||
foreach( get_entry_system_attrs( $server_id, $dn ) as $attr => $val ) {
|
||||
$counter++
|
||||
?>
|
||||
<tr class="<?php echo ($counter%2==0?'row1':'row2');?>">
|
||||
<td class="attr"><b><?php echo htmlspecialchars( $attr ); ?></b></td>
|
||||
<td class="val"><?php echo htmlspecialchars( $val ); ?></td>
|
||||
</tr>
|
||||
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>(none)</center></td></tr>\n";
|
||||
echo "<tr class=\"row2\"><td colspan=\"2\"><center>(" . $lang['none'] . ")</center></td></tr>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
@ -250,35 +313,49 @@ if( $show_internal_attrs ) {
|
||||
<!-- Table of attributes/values to edit -->
|
||||
<tr class="row1">
|
||||
<td class="heading" colspan="2">
|
||||
<nobr>
|
||||
<acronym title="Edit the contents of the form below and click Save.">Modify Attributes</acronym>
|
||||
</nobr>
|
||||
<nobr><?php echo $lang['entry_attributes']; ?></nobr>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<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 rawurlencode($dn); ?>" />
|
||||
|
||||
<?php if( $edit_dn_schema_lookup ) $schema_attrs = get_schema_attributes( $server_id ); ?>
|
||||
<?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 foreach( $attrs as $attr => $vals ) {
|
||||
flush();
|
||||
if( $attr == 'dn' )
|
||||
continue;
|
||||
|
||||
// is there a user-friendly translation available for this attribute?
|
||||
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) {
|
||||
$attr_display = "<acronym title=\"Alias for $attr\">" .
|
||||
$friendly_attrs[ strtolower( $attr ) ] . "</acronym>";
|
||||
} else {
|
||||
$attr_display = $attr;
|
||||
}
|
||||
<?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( $attr == $updated_attr ) { ?>
|
||||
<?php if( is_array( $modified_attrs ) && in_array( $attr, $modified_attrs ) ) { ?>
|
||||
<tr class="updated_attr">
|
||||
<?php } else { ?>
|
||||
<?php if( $counter++ % 2 == 0 ) { ?>
|
||||
@ -288,152 +365,208 @@ if( $show_internal_attrs ) {
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php $add_href = "add_value_form.php?server_id=$server_id&dn=$encoded_dn&attr=" . rawurlencode( $attr ); ?>
|
||||
<?php
|
||||
if( ! is_server_read_only( $server_id ) ) {
|
||||
$add_href = "add_value_form.php?server_id=$server_id&dn=$encoded_dn&attr=" . rawurlencode( $attr );
|
||||
} ?>
|
||||
|
||||
<td class="attr">
|
||||
<b><?php echo $attr_display; ?></b><br />
|
||||
<small>(<a href="<?php echo $add_href; ?>"
|
||||
title="Add an additional value to this attribute">add value</a>)</small>
|
||||
|
||||
<?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 if( 0==strcasecmp( $attr, 'jpegPhoto' ) ) {
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Is this attribute a jpegPhoto?
|
||||
*/
|
||||
if( is_jpeg_photo( $server_id, $attr ) ) {
|
||||
|
||||
$has_jpeg_photo = true;
|
||||
|
||||
// Don't draw the delete buttons if there is more than one jpegPhoto
|
||||
// (phpLDAPAdmin can't handle this case yet)
|
||||
if( is_array( $vals ) )
|
||||
// (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;
|
||||
}
|
||||
|
||||
} ?>
|
||||
|
||||
<?php /*
|
||||
* This is next IF statement is a KLUGE!! If anyone knows a better way to check for
|
||||
* binary data that works with UTF-8 encoded strings, please help
|
||||
*/
|
||||
?>
|
||||
/*
|
||||
* Is this attribute binary?
|
||||
*/
|
||||
if( is_attr_binary( $server_id, $attr ) ) {
|
||||
$href = "download_binary_attr.php?server_id=$server_id&dn=$encoded_dn&attr=$attr";
|
||||
?>
|
||||
|
||||
<?php if( 0==strcasecmp( $attr, 'networkAddress' ) ) { ?>
|
||||
<small>
|
||||
<?php echo $lang['binary_value']; ?><br />
|
||||
<?php if( count( $vals ) > 1 ) { for( $i=1; $i<=count($vals); $i++ ) { ?>
|
||||
<a href="<?php echo $href . "&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 } ?>
|
||||
|
||||
<small>This attribute contains binary data,<br />
|
||||
which cannot be safely displayed<br />
|
||||
or edited in a web-browser.</small>
|
||||
<?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; ?>
|
||||
<?php continue;
|
||||
}
|
||||
|
||||
<?php } ?>
|
||||
/*
|
||||
* Note: at this point, the attribute must be text-based (not binary or jpeg)
|
||||
*/
|
||||
|
||||
<?php /* is this a multi-valued attribute? */ ?>
|
||||
<?php if( is_array( $vals ) ) { ?>
|
||||
<?php foreach( $vals as $i => $val ) { ?>
|
||||
/*
|
||||
* 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]);
|
||||
|
||||
<?php $val = utf8_decode( $val ); ?>
|
||||
// Set the default hashing type if the password is blank (must be newly created)
|
||||
if( $val == '' ) {
|
||||
$enc_type = $servers[$server_id]['default_hash'];
|
||||
} ?>
|
||||
|
||||
<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); ?>" />
|
||||
|
||||
<input type="text"
|
||||
size="60"
|
||||
name="new_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" /></nobr><br />
|
||||
<?php } ?>
|
||||
<?php /* this a single-valued attribute */ ?>
|
||||
<?php } else { ?>
|
||||
<?php $val = $vals; ?>
|
||||
<?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";
|
||||
}
|
||||
} ?>
|
||||
|
||||
<?php $val = utf8_decode( $val ); ?>
|
||||
<input type="hidden"
|
||||
name="old_values[userpassword]"
|
||||
value="<?php echo htmlspecialchars($user_password); ?>" />
|
||||
|
||||
<nobr>
|
||||
<?php /* This series of if/elseif/else is for special cases of attributes (userPassword, boolean, etc) */ ?>
|
||||
<?php if( 0 == strcasecmp( $attr, 'userpassword' ) ) { ?>
|
||||
<!-- 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 /* Capture the stuff in the { } if any */
|
||||
preg_match( "/{([^}]+)}/", $val, $enc_type); $enc_type = strtolower($enc_type[1]); ?>
|
||||
<input size="38"
|
||||
type="text"
|
||||
name="new_values[userpassword]"
|
||||
value="<?php echo htmlspecialchars($user_password); ?>" />
|
||||
|
||||
<?php /* handle crypt types */
|
||||
if($enc_type == "crypt") {
|
||||
preg_match( '/{[^}]+}\$(.)\$/', $val, $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($val); ?>" />
|
||||
|
||||
<input size="48"
|
||||
type="text"
|
||||
name="new_values[userpassword]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
|
||||
<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 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 } elseif( $edit_dn_schema_lookup &&
|
||||
'Boolean' == $schema_attrs[ strtolower($attr) ]['type'] ) { ?>
|
||||
<?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); ?>" />
|
||||
<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' : ''); ?>>TRUE</option>
|
||||
<option value="FALSE"<?php echo ($val=='FALSE' ? ' selected' : ''); ?>>FALSE</option>
|
||||
<option value="">(none -- remove value)</option>
|
||||
</select>
|
||||
<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 } else { ?>
|
||||
<?php
|
||||
continue;
|
||||
}
|
||||
|
||||
<input type="hidden"
|
||||
name="old_values[<?php echo htmlspecialchars( $attr ); ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
/*
|
||||
* End of special case attributes.
|
||||
*/
|
||||
|
||||
<input size="60"
|
||||
type="text"
|
||||
name="new_values[<?php echo htmlspecialchars( $attr ); ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
/*
|
||||
* This is a normal attribute, to be displayed and edited in plain text.
|
||||
*/
|
||||
foreach( $vals as $i => $val ) {
|
||||
$val = utf8_decode( $val ); ?>
|
||||
|
||||
<?php } ?>
|
||||
</nobr>
|
||||
|
||||
<?php } ?>
|
||||
<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 } ?>
|
||||
<?php } /* End foreach( $attrs as $attr => $vals ) */ ?>
|
||||
|
||||
<tr><td colspan="2"><center><input type="submit" value="Save Changes" /></center></form></td></tr>
|
||||
<?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
|
||||
?>
|
||||
@ -441,32 +574,40 @@ if( $show_internal_attrs ) {
|
||||
|
||||
</table>
|
||||
|
||||
<?php /* If this entry has a jpegPhoto, we need to provide a form for it to submit when deleting it. */ ?>
|
||||
<?php if( $has_jpeg_photo ) { ?>
|
||||
<script language="javascript">
|
||||
<!--
|
||||
function deleteJpegPhoto()
|
||||
{
|
||||
if( confirm( "Really delete jpegPhoto?" ) )
|
||||
document.delete_jpeg_photo_form.submit();
|
||||
<?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>
|
||||
<!-- TODO: Go to update_confirm.php instead of directly to update.php -->
|
||||
<form name="delete_jpeg_photo_form" action="update.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="update_array[jpegPhoto]" value="" />
|
||||
</form>
|
||||
<?php } ?>
|
||||
}
|
||||
//-->
|
||||
</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 ) ] );
|
||||
//return ! isset( $attrs[ strtolower( $x ) ] );
|
||||
foreach( $attrs as $attr => $values )
|
||||
if( 0 == strcasecmp( $attr, $x ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.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'];
|
||||
@ -15,6 +15,7 @@ if( $container ) {
|
||||
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 ) );
|
||||
@ -43,25 +44,48 @@ if( $server_id !== false && $container !== false )
|
||||
else
|
||||
foreach( $dn_list as $dn ) {
|
||||
$href = "javascript:returnDN( '$dn' )";
|
||||
echo " <a href=\"entry_chooser.php?form_element=$return_form_element&server_id=$server_id&container=" .
|
||||
echo " <a href=\"entry_chooser.php?form_element=$return_form_element".
|
||||
"&server_id=$server_id&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 htmlspecialchars( $server['name'] ) . "<br />\n";
|
||||
$dn = ( $server['base'] ? $server['base'] : try_to_get_root_dn( $id ) );
|
||||
$href = "javascript:returnDN( '$dn' )";
|
||||
echo " <a href=\"entry_chooser.php?form_element=$return_form_element&server_id=$id&container=" .
|
||||
rawurlencode( $dn ) . "\"><img src=\"images/plus.png\" /></a> " .
|
||||
"<a href=\"$href\">" . htmlspecialchars( $dn ) . "</a><br />\n";
|
||||
echo "<b>" . htmlspecialchars( $server['name'] ) . "</b><br />\n";
|
||||
if( ! have_auth_info( $id ) )
|
||||
echo "<small> (Not logged in)</small><br />";
|
||||
else {
|
||||
$dn = ( $server['base'] ? $server['base'] : try_to_get_root_dn( $id ) );
|
||||
if( ! $dn ) {
|
||||
echo "<small> (Could not determine base DN)</small><br />";
|
||||
} else {
|
||||
$href = "javascript:returnDN( '$dn' )";
|
||||
echo " <a href=\"entry_chooser.php?form_element=" .
|
||||
"$return_form_element&server_id=$id&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">
|
||||
|
23
expand.php
23
expand.php
@ -12,8 +12,7 @@
|
||||
* Note: this script is equal and opposite to collapse.php
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
// no expire header stuff
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
@ -22,7 +21,7 @@ header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
$dn = stripslashes( $_GET['dn'] );
|
||||
$dn = $_GET['dn'];
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
|
||||
@ -31,14 +30,20 @@ have_auth_info( $server_id ) or pla_error( "Not enough information to login to s
|
||||
|
||||
session_start();
|
||||
|
||||
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." );
|
||||
// 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;
|
||||
|
||||
@ -55,6 +60,12 @@ session_write_close();
|
||||
$time = gettimeofday();
|
||||
$random_junk = md5( strtotime( 'now' ) . $time['usec'] );
|
||||
|
||||
header( "Location: tree.php?foo=$random_junk#{$server_id}_{$encoded_dn}" );
|
||||
// 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" );
|
||||
?>
|
||||
|
732
functions.php
732
functions.php
@ -1,39 +1,120 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* functions.php
|
||||
* A collection of functions used throughout phpLDAPAdmin.
|
||||
* A collection of functions used throughout phpLDAPadmin.
|
||||
*/
|
||||
|
||||
@include 'config.php';
|
||||
|
||||
/*
|
||||
* Used to determine if the specified attribute is indeed a jpegPhoto
|
||||
*/
|
||||
function is_jpeg_photo( $server_id, $attr_name )
|
||||
{
|
||||
// easy quick check
|
||||
if( 0 == strcasecmp( $attr_name, 'jpegPhoto' ) ||
|
||||
0 == strcasecmp( $attr_name, 'photo' ) )
|
||||
return true;
|
||||
|
||||
// go to the schema and get the Syntax OID
|
||||
require_once realpath( 'schema_functions.php' );
|
||||
$schema_attr = get_schema_attribute( $server_id, $attr_name );
|
||||
if( ! $schema_attr )
|
||||
return false;
|
||||
|
||||
$oid = $schema_attr->getSyntaxOID();
|
||||
$type = $schema_attr->getType();
|
||||
|
||||
if( 0 == strcasecmp( $type, 'JPEG' ) )
|
||||
return true;
|
||||
if( $oid == '1.3.6.1.4.1.1466.115.121.1.28' )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given an attribute name and server id number, this function returns
|
||||
* whether the attrbiute may contain binary data.
|
||||
*/
|
||||
function is_attr_binary( $server_id, $attr_name )
|
||||
{
|
||||
require_once realpath( 'schema_functions.php' );
|
||||
$schema_attrs = get_schema_attributes( $server_id );
|
||||
|
||||
if( 0 == strcasecmp( substr( $attr_name, strlen( $attr_name ) - 7 ), ";binary" ) )
|
||||
return true;
|
||||
if( isset( $schema_attrs[ strtolower( $attr_name ) ] ) ) {
|
||||
$type = $schema_attrs[ strtolower( $attr_name ) ]->getType();
|
||||
$syntax = $schema_attrs[ strtolower( $attr_name ) ]->getSyntaxOID();
|
||||
if( 0 == strcasecmp( substr( $attr_name, strlen( $attr_name ) - 7 ), ";binary" ) ||
|
||||
0 == strcasecmp( $type, 'Certificate' ) ||
|
||||
0 == strcasecmp( $type, 'Binary' ) ||
|
||||
0 == strcasecmp( $attr_name, 'networkAddress' ) ||
|
||||
0 == strcasecmp( $attr_name, 'userCertificate' ) ||
|
||||
0 == strcasecmp( $attr_name, 'userSMIMECertificate' ) ||
|
||||
$syntax == '1.3.6.1.4.1.1466.115.121.1.10' ||
|
||||
$syntax == '1.3.6.1.4.1.1466.115.121.1.28' ||
|
||||
$syntax == '1.3.6.1.4.1.1466.115.121.1.5' ||
|
||||
$syntax == '1.3.6.1.4.1.1466.115.121.1.8' ||
|
||||
$syntax == '1.3.6.1.4.1.1466.115.121.1.9' )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the specified server is configured to be displayed
|
||||
* in read only mode. If a user has logged in via anonymous bind, and
|
||||
* config.php specifies anonymous_bind_implies_read_only as true, then
|
||||
* this also returns true.
|
||||
*/
|
||||
function is_server_read_only( $server_id )
|
||||
{
|
||||
global $servers;
|
||||
if( isset( $servers[$server_id]['read_only'] ) &&
|
||||
$servers[$server_id]['read_only'] == true )
|
||||
return true;
|
||||
|
||||
global $anonymous_bind_implies_read_only;
|
||||
if( 0 == strcasecmp( "anonymous", get_logged_in_dn( $server_id ) ) &&
|
||||
isset( $anonymous_bind_implies_read_only ) &&
|
||||
$anonymous_bind_implies_read_only == true )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a DN and server ID, this function reads the DN's objectClasses and
|
||||
* determines which icon best represents the entry.
|
||||
* determines which icon best represents the entry. The results of this query
|
||||
* are cached in a session variable so it is not run *every* time the tree
|
||||
* browser changes, just when exposing new DNs that were not displayed
|
||||
* previously. That means we can afford a little bit of inefficiency here
|
||||
* in favor of coolness. :)
|
||||
*/
|
||||
function get_icon( $server_id, $dn )
|
||||
{
|
||||
// fetch and lowercase all the objectClasses in an array
|
||||
$object_classes = get_object_attr( $server_id, $dn, 'objectClass' );
|
||||
$object_classes = get_object_attr( $server_id, $dn, 'objectClass', true );
|
||||
|
||||
if( $object_classes === null )
|
||||
if( $object_classes === null || $object_classes === false)
|
||||
return 'object.png';
|
||||
|
||||
// If there is only one objectClass, make it an array with one element instead
|
||||
if( ! is_array( $object_classes ) )
|
||||
$object_classes = array( $object_classes );
|
||||
|
||||
foreach( $object_classes as $i => $class )
|
||||
$object_classes[$i] = strtolower( $class );
|
||||
|
||||
// get the prefix (ie: dc, ou, cn, uid)
|
||||
$exploded_dn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = $dn[0];
|
||||
$prefix = explode( '=', $rdn );
|
||||
$prefix = $prefix[0];
|
||||
$rdn = get_rdn( $dn );
|
||||
|
||||
// Is it a samba NT machine (is sambaAccount and ends with '$')
|
||||
if( in_array( 'sambaaccount', $object_classes ) &&
|
||||
'$' == $rdn{ strlen($rdn) - 1 } )
|
||||
return 'nt.png';
|
||||
// Is it a person or some type of account/user?
|
||||
if( in_array( 'person', $object_classes ) ||
|
||||
elseif( in_array( 'person', $object_classes ) ||
|
||||
in_array( 'organizationalperson', $object_classes ) ||
|
||||
in_array( 'inetorgperson', $object_classes ) ||
|
||||
in_array( 'account', $object_classes ) ||
|
||||
@ -55,6 +136,8 @@ function get_icon( $server_id, $dn )
|
||||
return 'mail.png';
|
||||
elseif( in_array( 'locality', $object_classes ) )
|
||||
return 'locality.png';
|
||||
elseif( in_array( 'posixgroup', $object_classes ) )
|
||||
return 'ou.png';
|
||||
// Oh well, I don't know what it is. Use a generic icon.
|
||||
else
|
||||
return 'object.png';
|
||||
@ -112,7 +195,11 @@ function get_logged_in_pass( $server_id )
|
||||
function get_logged_in_dn( $server_id )
|
||||
{
|
||||
global $_COOKIE;
|
||||
$dn = $_COOKIE[ 'pla_login_dn_' . $server_id ];
|
||||
$cookie_name = 'pla_login_dn_' . $server_id;
|
||||
if( isset( $_COOKIE[ $cookie_name ] ) )
|
||||
$dn = $_COOKIE[ $cookie_name ];
|
||||
else
|
||||
return false;
|
||||
|
||||
if( $dn == '0' )
|
||||
return 'Anonymous';
|
||||
@ -139,7 +226,7 @@ function pla_ldap_connect( $server_id )
|
||||
// times, we don't have to reauthenticate with the LDAP server
|
||||
|
||||
static $conns;
|
||||
if( $conns[$server_id] )
|
||||
if( isset( $conns[$server_id] ) && $conns[$server_id] )
|
||||
return $conns[$server_id];
|
||||
|
||||
$host = $servers[$server_id]['host'];
|
||||
@ -204,9 +291,7 @@ function get_container_contents( $server_id, $dn, $size_limit=0 )
|
||||
$search = ldap_get_entries( $con, $search );
|
||||
|
||||
$return = array();
|
||||
|
||||
for( $i=0; $i<$search['count']; $i++ )
|
||||
{
|
||||
for( $i=0; $i<$search['count']; $i++ ) {
|
||||
$entry = $search[$i];
|
||||
$dn = $entry['dn'];
|
||||
$return[] = $dn;
|
||||
@ -273,12 +358,15 @@ function get_entry_system_attrs( $server_id, $dn )
|
||||
|
||||
$entry = ldap_first_entry( $conn, $search );
|
||||
$attrs = ldap_get_attributes( $conn, $entry );
|
||||
foreach( $attrs as $name => $vals )
|
||||
if( is_numeric( $name ) || $name == 'count' )
|
||||
unset( $attrs[$name] );
|
||||
else
|
||||
$attrs[$name] = $vals[0];
|
||||
return $attrs;
|
||||
$count = $attrs['count'];
|
||||
unset( $attrs['count'] );
|
||||
//echo "<pre>"; print_r( $attrs );
|
||||
for( $i=0; $i<$count; $i++ ) {
|
||||
$attr_name = $attrs[$i];
|
||||
unset( $attrs[$attr_name]['count'] );
|
||||
$return_attrs[$attr_name] = $attrs[$attr_name];
|
||||
}
|
||||
return $return_attrs;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -305,22 +393,22 @@ function get_object_attrs( $server_id, $dn, $lower_case_attr_names = false )
|
||||
$conn = pla_ldap_connect( $server_id );
|
||||
if( ! $conn ) return false;
|
||||
|
||||
$search = @ldap_read( $conn, $dn, '(objectClass=*)' );
|
||||
|
||||
$search = @ldap_read( $conn, $dn, '(objectClass=*)', array( ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( ! $search )
|
||||
return false;
|
||||
|
||||
$entry = ldap_first_entry( $conn, $search );
|
||||
$attrs = ldap_get_attributes( $conn, $entry );
|
||||
//$attrs = ldap_get_entries( $conn, $search );
|
||||
|
||||
if( ! $attrs || $attrs['count'] == 0 )
|
||||
if( ! $attrs || $attrs['count'] == 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//$attrs = $attrs[0];
|
||||
$num_attrs = $attrs['count'];
|
||||
unset( $attrs['count'] );
|
||||
|
||||
// strip numerical inices
|
||||
for( $i=0; $i<$num_attrs; $i++ )
|
||||
unset( $attrs[$i] );
|
||||
|
||||
@ -330,10 +418,7 @@ function get_object_attrs( $server_id, $dn, $lower_case_attr_names = false )
|
||||
$attr = strtolower( $attr );
|
||||
$count = $vals['count'];
|
||||
unset( $vals['count'] );
|
||||
if( $count == 1 )
|
||||
$return_array[ $attr ] = $vals[0];
|
||||
else
|
||||
$return_array[ $attr ] = $vals;
|
||||
$return_array[ $attr ] = $vals;
|
||||
}
|
||||
|
||||
ksort( $return_array );
|
||||
@ -374,353 +459,7 @@ function get_object_attr( $server_id, $dn, $attr )
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if $var is not white space only, and false otherwise.
|
||||
*/
|
||||
function not_white( $var )
|
||||
{
|
||||
return trim($var) != "" ? true : false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associative array of objectClasses for the specified
|
||||
* $server_id. Each array entry's key is the name of the objectClass
|
||||
* in lower-case.
|
||||
* The sub-entries consist of sub-arrays called 'must_attrs' and
|
||||
* 'may_attrs', and sub-entries called 'oid', 'name' and 'description'.
|
||||
*
|
||||
* The bulk of this function came from the good code in the
|
||||
* GPL'ed LDAP Explorer project. Thank you.
|
||||
*/
|
||||
function get_schema_objectclasses( $server_id )
|
||||
{
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// get all the objectClasses
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'objectclasses' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'objectclasses' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( ! $result ) return false;
|
||||
if( $result ) $raw_oclasses = ldap_get_entries($ds,$result );
|
||||
|
||||
// build the array of objectClasses
|
||||
$oclasses = array();
|
||||
for( $att=0; $att < count( $raw_oclasses[0]["objectclasses"] ); $att++ )
|
||||
{
|
||||
$class = $raw_oclasses[0]["objectclasses"][$att];
|
||||
|
||||
preg_match( "/[\s]+NAME[\s'\(]+([a-zA-Z0-9\-_]+)[\s'\)]/" , $class, $name);
|
||||
preg_match( "/[\s]+([\d\.]+)[\s]+NAME/", $class, $oid );
|
||||
preg_match( "/[\s]+DESC[\s]+'([a-zA-Z0-9\-_ ]+)'/", $class, $description );
|
||||
preg_match( "/[\s]+SUP[\s]+([a-zA-Z0-9\-_]+)[\s]/", $class, $sup );
|
||||
|
||||
$key = strtolower( trim( $name[1] ) );
|
||||
$oclass_name = trim( $name[1] );
|
||||
if( ! $key ) continue;
|
||||
|
||||
$oclasses[$key] = array();
|
||||
$oclasses[$key]['oid'] = trim( $oid[1] );
|
||||
$oclasses[$key]['description'] = trim( $description[1] );
|
||||
$oclasses[$key]['sup'] = trim( $sup[1] );
|
||||
|
||||
unset( $name );
|
||||
unset( $syntax );
|
||||
unset( $desription );
|
||||
|
||||
// get all the required attributes
|
||||
preg_match( "/MUST[\s\(]+([a-zA-Z0-9\s$]+)(MAY|\))/" , $class, $must_attrs );
|
||||
$must_attrs = str_replace( ' ', '', $must_attrs[1] );
|
||||
$oclasses[$key]['must_attrs'] = array_filter( explode( '$', $must_attrs ), "not_white" );
|
||||
|
||||
// get all the optional attributes
|
||||
preg_match( "/MAY[\s\(]+([a-zA-Z0-9\s$]+)(MUST|\))/" , $class, $may_attrs );
|
||||
$may_attrs = str_replace( ' ', '', $may_attrs[1] );
|
||||
$oclasses[$key]['may_attrs'] = array_filter( array_merge( $oclasses[$key]['must_attrs'], explode( '$', $may_attrs) ), "not_white" );
|
||||
unset( $must_attrs );
|
||||
unset( $may_attrs );
|
||||
|
||||
$oclasses[$key]['name'] = $oclass_name;
|
||||
}
|
||||
|
||||
// go back and add any inherited MUST/MAY attrs to each objectClass
|
||||
foreach( $oclasses as $oclass => $attrs )
|
||||
{
|
||||
$new_must = $attrs['must_attrs'];
|
||||
$new_may = $attrs['may_attrs'];
|
||||
$sup_attr = $attrs['sup'];
|
||||
|
||||
while( $sup_attr && $sup_attr != "top" ) {
|
||||
$new_must = array_merge( $new_must, $oclasses[strtolower($sup_attr)]['must_attrs'] );
|
||||
$new_may = array_merge( $new_may, $oclasses[strtolower($sup_attr)]['may_attrs'] );
|
||||
$sup_attr = $oclasses[strtolower($sup_attr)]['sup'];
|
||||
}
|
||||
|
||||
$oclasses[$oclass]['must_attrs'] = array_unique( $new_must );
|
||||
$oclasses[$oclass]['may_attrs'] = array_unique( $new_may );
|
||||
}
|
||||
|
||||
ksort( $oclasses );
|
||||
|
||||
return $oclasses;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associate array of the server's schema matching rules
|
||||
*/
|
||||
function get_schema_matching_rules( $server_id )
|
||||
{
|
||||
static $cache;
|
||||
|
||||
if( isset( $cache[$server_id] ) )
|
||||
return $cache[$server_id];
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// get all the attributeTypes
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'matchingRules', 'matchingRuleUse' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'matchingRules', 'matchingRuleUse' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( $result )
|
||||
$raw = ldap_get_entries( $ds, $result );
|
||||
else
|
||||
return( array() );
|
||||
|
||||
// build the array of attributes
|
||||
$rules = array();
|
||||
for( $i=0; $i < $raw[0]['matchingrules']['count']; $i++ )
|
||||
{
|
||||
$rule = $raw[0]['matchingrules'][$i];
|
||||
preg_match( "/[\s]+([\d\.]+)[\s]+/", $rule, $oid);
|
||||
preg_match( "/[\s]+NAME[\s]+'([\)\(:?\.a-zA-Z0-9\-_ ]+)'/", $rule, $name );
|
||||
|
||||
$key = strtolower( trim( $oid[1] ) );
|
||||
if( ! $key ) continue;
|
||||
|
||||
$rules[$key] = $name[1];
|
||||
//$rules[$key]['name'] = $name[1];
|
||||
}
|
||||
|
||||
ksort( $rules );
|
||||
$cache[$server_id] = $rules;
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns an associate array of the syntax OIDs that this LDAP server uses mapped to
|
||||
* their descriptions.
|
||||
*/
|
||||
function get_schema_syntaxes( $server_id )
|
||||
{
|
||||
static $cache;
|
||||
|
||||
if( isset( $cache[$server_id] ) )
|
||||
return $cache[$server_id];
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// get all the attributeTypes
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'ldapSyntaxes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'ldapSyntaxes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( $result )
|
||||
$raw = ldap_get_entries( $ds, $result );
|
||||
else
|
||||
return( array() );
|
||||
|
||||
// build the array of attributes
|
||||
$syntaxes = array();
|
||||
for( $i=0; $i < $raw[0]['ldapsyntaxes']['count']; $i++ )
|
||||
{
|
||||
$syntax = $raw[0]['ldapsyntaxes'][$i];
|
||||
preg_match( "/[\s]+([\d\.]+)[\s]+/", $syntax, $oid);
|
||||
preg_match( "/[\s]+DESC[\s]+'([\)\(:?\.a-zA-Z0-9\-_ ]+)'/", $syntax, $description );
|
||||
|
||||
$key = strtolower( trim( $oid[1] ) );
|
||||
if( ! $key ) continue;
|
||||
|
||||
$syntaxes[$key] = array();
|
||||
$syntaxes[$key]['description'] = $description[1];
|
||||
}
|
||||
|
||||
ksort( $syntaxes );
|
||||
|
||||
$cache[$server_id] = $syntaxes;
|
||||
|
||||
return $syntaxes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associative array of attributes for the specified
|
||||
* $server_id. Each array entry's key is the name of the attribute,
|
||||
* in lower-case.
|
||||
* The sub-entries are 'oid', 'syntax', 'equality', 'substr', 'name',
|
||||
* and 'single_value'.
|
||||
*
|
||||
* The bulk of this function came from the good code in the
|
||||
* GPL'ed LDAP Explorer project. Thank you. It was extended
|
||||
* considerably for application here.
|
||||
*/
|
||||
function get_schema_attributes( $server_id )
|
||||
{
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// get all the attributeTypes
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'attributeTypes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'attributeTypes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( $result )
|
||||
$raw_attrs = ldap_get_entries( $ds, $result );
|
||||
else
|
||||
$raw_attrs = array();
|
||||
$syntaxes = get_schema_syntaxes( $server_id );
|
||||
|
||||
// build the array of attributes
|
||||
$attrs = array();
|
||||
for( $i=0; $i < $raw_attrs[0]['attributetypes']['count']; $i++ )
|
||||
{
|
||||
$attr = $raw_attrs[0]['attributetypes'][$i];
|
||||
|
||||
preg_match( "/[\s]+NAME[\s'\(]+([a-zA-Z0-9\-_]+)[\s'\)]/" , $attr, $name);
|
||||
preg_match( "/\s+NAME\s+'([a-zA-Z0-9\-_]+)'\s/" , $attr, $name);
|
||||
preg_match( "/[\s]+([\d\.]+)[\s]+NAME/", $attr, $oid );
|
||||
preg_match( "/[\s]+DESC[\s]+'([\)\(:?\.a-zA-Z0-9\-_ ]+)'/", $attr, $description );
|
||||
preg_match( "/[\s]+SYNTAX[\s]+([\d\.]+)/", $attr, $syntax);
|
||||
preg_match( "/[\s]+EQUALITY[\s]+([a-zA-Z]+)/", $attr, $equality);
|
||||
preg_match( "/[\s]+SUBSTR[\s]+([a-zA-Z]+)/", $attr, $substr);
|
||||
preg_match( "/[\s]+SUP[\s]+([a-zA-Z0-9\-_]+)/", $attr, $sup );
|
||||
|
||||
if( preg_match( "/[\s]+SINGLE-VALUE[\s]+/", $attr, $single_value ) )
|
||||
$single_value = 'Yes';
|
||||
else
|
||||
$single_value = 'No';
|
||||
|
||||
// If this schema attribute has multiple names (like: "NAME ( 'uid' 'userid' )"), then we need
|
||||
// to create a matching attribute entry for each name it bares.
|
||||
if( preg_match( "/\s+NAME\s+\(\s*['\sa-zA-Z0-9\-_]+\s*\)/", $attr, $multi_name ) ) {
|
||||
$multi_name = $multi_name[0];
|
||||
preg_match_all( "/'([a-zA-Z0-9\-_]+)'/", $multi_name, $multiple_names );
|
||||
$multiple_names = $multiple_names[1];
|
||||
//print_r( $multiple_names );
|
||||
|
||||
foreach( $multiple_names as $name ) {
|
||||
$key = strtolower( trim( $name ) );
|
||||
$attr_name = trim( $name );
|
||||
if( ! $key ) continue;
|
||||
|
||||
$attrs[$key] = array();
|
||||
$attrs[$key]['oid'] = trim( $oid[1] );
|
||||
$attrs[$key]['description'] = trim( $description[1] );
|
||||
$attrs[$key]['syntax'] = trim( $syntax[1] );
|
||||
$attrs[$key]['type'] = $syntaxes[ trim($syntax[1]) ]['description'];
|
||||
$attrs[$key]['equality'] = trim( $equality[1] );
|
||||
$attrs[$key]['substr'] = trim( $substr[1] );
|
||||
$attrs[$key]['single_value'] = $single_value;
|
||||
$attrs[$key]['sup'] = trim( $sup[1] );
|
||||
$attrs[$key]['name'] = $attr_name;
|
||||
|
||||
$count = 1;
|
||||
for( $j=0; $j<count($multiple_names); $j++ ) {
|
||||
$alias_name = $multiple_names[$j];
|
||||
if( $alias_name != $name ) {
|
||||
$attrs[$key]['alias' . $count] = $alias_name;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
// this attribute bares only a single name.
|
||||
$key = strtolower( trim( $name[1] ) );
|
||||
$attr_name = trim( $name[1] );
|
||||
if( ! $key ) continue;
|
||||
|
||||
$attrs[$key] = array();
|
||||
$attrs[$key]['oid'] = trim( $oid[1] );
|
||||
$attrs[$key]['description'] = trim( $description[1] );
|
||||
$attrs[$key]['syntax'] = trim( $syntax[1] );
|
||||
$attrs[$key]['type'] = $syntaxes[ trim($syntax[1]) ]['description'];
|
||||
$attrs[$key]['equality'] = trim( $equality[1] );
|
||||
$attrs[$key]['substr'] = trim( $substr[1] );
|
||||
$attrs[$key]['single_value'] = $single_value;
|
||||
$attrs[$key]['sup'] = trim( $sup[1] );
|
||||
$attrs[$key]['name'] = $attr_name;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// go back and add any inherited descriptions from parent attributes (ie, cn inherits name)
|
||||
foreach( $attrs as $attr => $desc )
|
||||
{
|
||||
$sup_attr = $desc['sup'];
|
||||
while( $sup_attr ) {
|
||||
if( ! $attrs[ $sup_attr ]['sup'] ) {
|
||||
$attrs[ $attr ][ 'syntax' ] = $attrs[ $sup_attr ]['syntax'];
|
||||
$attrs[ $attr ][ 'equality' ] = $attrs[ $sup_attr ]['equality'];
|
||||
$attrs[ $attr ][ 'substr' ] = $attrs[ $sup_attr ]['substr'];
|
||||
$attrs[ $attr ][ 'single_value' ] = $attrs[ $sup_attr ]['single_value'];
|
||||
break;
|
||||
} else {
|
||||
$sup_attr = $attrs[ $sup_attr ]['sup'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $attrs );
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
/*
|
||||
* A wrapper function to save you from having to call get_schema_objectclasses()
|
||||
* and get_schema_attributes(). Returns an array with two indexes: 'oclasses'
|
||||
* and 'attributes', as defined by their respective functions above.
|
||||
*/
|
||||
function get_schema( $server_id )
|
||||
{
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
$attrs = get_schema_attributes($server_id, $lower_case_all );
|
||||
$oclasses = get_schema_objectclasses($server_id, $lower_case_all );
|
||||
|
||||
if( ! $oclasses )
|
||||
return false;
|
||||
|
||||
$schema = array( 'attrs' => $attrs,
|
||||
'oclasses' => $oclasses );
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* A do-it-all ldap_search function. You can even specify the search scope. Other than
|
||||
* that, it's pretty much the same as the PHP ldap_search() call, except it returns
|
||||
* an array of results, rather than an LDAP result resource.
|
||||
@ -729,54 +468,74 @@ function pla_ldap_search( $server_id, $filter, $base_dn=null, $attrs=array(), $s
|
||||
{
|
||||
global $servers;
|
||||
|
||||
if( ! isset($servers[$server_id]) || $servers[$server_id]['host'] == '' )
|
||||
if( ! check_server_id( $server_id ) )
|
||||
return false;
|
||||
|
||||
if( $base_dn == null )
|
||||
$base_dn = $servers[$server_id]['base'];
|
||||
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
|
||||
switch( $scope ) {
|
||||
case 'base':
|
||||
$search = @ldap_read( $ds, $base_dn, $filter, $attrs );
|
||||
$search = @ldap_read( $ds, $base_dn, $filter, $attrs, 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
break;
|
||||
case 'one':
|
||||
$search = @ldap_list( $ds, $base_dn, $filter, $attrs );
|
||||
$search = @ldap_list( $ds, $base_dn, $filter, $attrs, 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
break;
|
||||
case 'sub':
|
||||
default:
|
||||
$search = @ldap_search( $ds, $base_dn, $filter, $attrs );
|
||||
$search = @ldap_search( $ds, $base_dn, $filter, $attrs, 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
break;
|
||||
}
|
||||
|
||||
if( ! $search )
|
||||
return array();
|
||||
|
||||
$search = ldap_get_entries( $ds, $search );
|
||||
//get the first entry identifier
|
||||
if( $entry_id = ldap_first_entry($ds,$search) )
|
||||
|
||||
$return = array();
|
||||
foreach( $search as $id => $attrs ) {
|
||||
if( ! is_array( $attrs ) )
|
||||
continue;
|
||||
for( $i=0; $i<$attrs['count']; $i++ )
|
||||
unset( $attrs[$i] );
|
||||
$dn = $attrs['dn'];
|
||||
foreach( $attrs as $attr => $vals ) {
|
||||
$count = $vals['count'];
|
||||
unset( $vals['count'] );
|
||||
if( $count == 1 )
|
||||
$return[$dn][$attr] = $vals[0];
|
||||
else
|
||||
$return[$dn][$attr] = $vals;
|
||||
}
|
||||
}
|
||||
//iterate over the entries
|
||||
while($entry_id) {
|
||||
|
||||
//get the distinguished name of the entry
|
||||
$dn = ldap_get_dn($ds,$entry_id);
|
||||
|
||||
//get the attributes of the entry
|
||||
$attrs = ldap_get_attributes($ds,$entry_id);
|
||||
$return[$dn]['dn'] = $dn;
|
||||
|
||||
//get the first attribute of the entry
|
||||
if($attr = ldap_first_attribute($ds,$entry_id,$attrs))
|
||||
|
||||
//iterate over the attributes
|
||||
while($attr){
|
||||
if( is_attr_binary($server_id,$attr))
|
||||
$values = ldap_get_values_len($ds,$entry_id,$attr);
|
||||
else
|
||||
$values = ldap_get_values($ds,$entry_id,$attr);
|
||||
|
||||
//get the number of values for this attribute
|
||||
$count = $values['count'];
|
||||
unset($values['count']);
|
||||
if($count==1)
|
||||
$return[$dn][$attr] = $values[0];
|
||||
else
|
||||
$return[$dn][$attr] = $values;
|
||||
|
||||
$attr = ldap_next_attribute($ds,$entry_id,$attrs);
|
||||
}// end while attr
|
||||
|
||||
$entry_id = ldap_next_entry($ds,$entry_id);
|
||||
|
||||
} // end while entry_id
|
||||
|
||||
if( $sort_results && is_array( $return ) )
|
||||
ksort( $return );
|
||||
|
||||
if( $sort_results ) ksort( $return );
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -798,10 +557,6 @@ function process_config()
|
||||
global $search_attributes;
|
||||
$search_attributes= explode( ",", $search_attributes);
|
||||
array_walk( $search_attributes, "trim_it" );
|
||||
|
||||
global $search_criteria_options;
|
||||
$search_criteria_options= explode( ",", $search_criteria_options);
|
||||
array_walk( $search_criteria_options, "trim_it" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -871,9 +626,15 @@ function get_avail_server_id()
|
||||
* For example. given 'cn=Manager,dc=example,dc=com', this function returns
|
||||
* 'cn=Manager' (it is really the exact opposite of get_container()).
|
||||
*/
|
||||
function get_rdn( $dn )
|
||||
function get_rdn( $dn, $include_attrs=0 )
|
||||
{
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
if( $dn == null )
|
||||
return null;
|
||||
$rdn = pla_explode_dn( $dn, $include_attrs );
|
||||
if( $rdn['count'] == 0 )
|
||||
return null;
|
||||
if( ! isset( $rdn[0] ) )
|
||||
return null;
|
||||
$rdn = $rdn[0];
|
||||
return $rdn;
|
||||
}
|
||||
@ -885,7 +646,7 @@ function get_rdn( $dn )
|
||||
*/
|
||||
function get_container( $dn )
|
||||
{
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = pla_explode_dn( $dn );
|
||||
$container = $rdn[ 1 ];
|
||||
for( $i=2; $i<count($rdn)-1; $i++ )
|
||||
$container .= ',' . $rdn[$i];
|
||||
@ -906,11 +667,11 @@ function pla_verbose_error( $err_no )
|
||||
|
||||
$err_codes_file = 'ldap_error_codes.txt';
|
||||
|
||||
if( ! file_exists( $err_codes_file ) )
|
||||
if( ! file_exists( realpath( $err_codes_file ) ) )
|
||||
return false;
|
||||
if( ! is_readable( $err_codes_file ) )
|
||||
if( ! is_readable( realpath( $err_codes_file ) ) )
|
||||
return false;
|
||||
if( ! ($f = fopen( $err_codes_file, 'r' )) )
|
||||
if( ! ($f = fopen( realpath( $err_codes_file ), 'r' ) ) )
|
||||
return false;
|
||||
|
||||
$contents = fread( $f, filesize( $err_codes_file ) );
|
||||
@ -938,31 +699,42 @@ function pla_error( $msg, $ldap_err_msg=null, $ldap_err_no=-1 )
|
||||
{
|
||||
include_once 'header.php';
|
||||
|
||||
echo "<center>";
|
||||
echo "<div class=\"error\">\n\n";
|
||||
echo "<center><h3>Error</h3></center>\n\n";
|
||||
echo "<center>$msg</center>";
|
||||
echo "<br /><br />\n";
|
||||
?>
|
||||
<center>
|
||||
<table class="error"><tr><td class="img"><img src="images/warning.png" /></td>
|
||||
<td><center><h2>Error</h2></center>
|
||||
<?php echo $msg; ?>
|
||||
<br />
|
||||
<?php
|
||||
|
||||
if( $ldap_err_msg )
|
||||
echo "LDAP Server Said: <tt>" . htmlspecialchars( $ldap_err_msg ) . "</tt><br /><br />\n";
|
||||
echo "<b>LDAP said</b>: " . htmlspecialchars( $ldap_err_msg ) . "<br /><br />\n";
|
||||
|
||||
if( $ldap_err_no != -1 ) {
|
||||
$ldap_err_no = ( '0x' . str_pad( dechex( $ldap_err_no ), 2, 0, STR_PAD_LEFT ) );
|
||||
$verbose_error = pla_verbose_error( $ldap_err_no );
|
||||
|
||||
if( $verbose_error ) {
|
||||
echo "Error number: <tt>$ldap_err_no (" .
|
||||
$verbose_error['title'] . ")</tt><br /><br />\n";
|
||||
echo "Description: <tt>" . $verbose_error['desc'] . "</tt><br /><br />\n\n";
|
||||
echo "<b>Error number</b>: $ldap_err_no <small>(" .
|
||||
$verbose_error['title'] . ")</small><br /><br />\n";
|
||||
echo "<b>Description</b>: " . $verbose_error['desc'] . "<br /><br />\n\n";
|
||||
} else {
|
||||
echo "Error number: <tt>$ldap_err_no</tt><br /><br />\n";
|
||||
echo "Description: (no description available)<br />\n\n";
|
||||
echo "<b>Error number</b>: $ldap_err_no<br /><br />\n";
|
||||
echo "<b>Description</b>: (no description available)<br />\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</div>\n";
|
||||
echo "</center>";
|
||||
?>
|
||||
<br />
|
||||
<br />
|
||||
<center>
|
||||
<small>
|
||||
Is this a phpLDAPadmin bug? If so, please
|
||||
<a href="<?php echo get_href( 'add_bug' ); ?>">report it</a>.
|
||||
</small>
|
||||
</center>
|
||||
</td></tr></table>
|
||||
</center>
|
||||
<?php
|
||||
die();
|
||||
}
|
||||
|
||||
@ -1031,13 +803,14 @@ function draw_jpeg_photos( $server_id, $dn, $draw_delete_buttons=false )
|
||||
for( $i=0; $i<$jpeg_data['count']; $i++ )
|
||||
{
|
||||
$jpeg_filename = $jpeg_temp_dir . '/' . basename( tempnam ('.', 'djp') );
|
||||
$jpeg_filename = realpath( $jpeg_filename );
|
||||
$outjpeg = fopen($jpeg_filename, "wb");
|
||||
fwrite($outjpeg, $jpeg_data[$i]);
|
||||
fclose ($outjpeg);
|
||||
$jpeg_data_size = filesize( $jpeg_filename );
|
||||
if( $jpeg_data_size < 6 ) {
|
||||
echo "jpegPhoto contains errors<br />";
|
||||
echo '<a href="javascript:deleteJpegPhoto();" style="color:red; font-size: 75%">Delete Photo</a>';
|
||||
echo '<a href="javascript:deleteAttribute( \'jpegPhoto\' );" style="color:red; font-size: 75%">Delete Photo</a>';
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1060,7 +833,7 @@ function draw_jpeg_photos( $server_id, $dn, $draw_delete_buttons=false )
|
||||
if( $draw_delete_buttons )
|
||||
{ ?>
|
||||
<!-- JavaScript function deleteJpegPhoto() to be defined later by calling script -->
|
||||
<a href="javascript:deleteJpegPhoto();" style="color:red; font-size: 75%">Delete Photo</a>
|
||||
<a href="javascript:deleteAttribute( 'jpegPhoto' );" style="color:red; font-size: 75%">Delete Photo</a>
|
||||
<?php }
|
||||
}
|
||||
echo "</center></td></table>\n\n";
|
||||
@ -1129,9 +902,13 @@ function password_hash( $password_clear, $enc_type )
|
||||
$new_value = '{md5}' . base64_encode( pack( 'H*' , md5( $password_clear) ) );
|
||||
break;
|
||||
case 'md5crypt':
|
||||
if( ! defined( 'CRYPT_MD5' ) || 0 == CRYPT_MD5 )
|
||||
pla_error( "Your PHP install does not support blowfish encryption." );
|
||||
$new_value = '{crypt}' . crypt( $password_clear , '$1$' . random_salt(9) );
|
||||
break;
|
||||
case 'blowfish':
|
||||
if( ! defined( 'CRYPT_BLOWFISH' ) || 0 == CRYPT_BLOWFISH )
|
||||
pla_error( "Your PHP install does not support blowfish encryption." );
|
||||
$new_value = '{crypt}' . crypt( $password_clear , '$2$' . random_salt(13) );
|
||||
break;
|
||||
case 'sha':
|
||||
@ -1155,20 +932,99 @@ function password_hash( $password_clear, $enc_type )
|
||||
*/
|
||||
function pla_version()
|
||||
{
|
||||
if( ! file_exists( 'VERSION' ) )
|
||||
if( ! file_exists( realpath( 'VERSION' ) ) )
|
||||
return 'unknown version';
|
||||
|
||||
$f = fopen( 'VERSION', 'r' );
|
||||
$version = fread( $f, filesize( 'VERSION' ) );
|
||||
$f = fopen( realpath( 'VERSION' ), 'r' );
|
||||
$version = fread( $f, filesize( realpath( 'VERSION' ) ) );
|
||||
fclose( $f );
|
||||
return $version;
|
||||
}
|
||||
|
||||
function draw_chooser_link( $form_element )
|
||||
{
|
||||
global $lang;
|
||||
$href = "javascript:dnChooserPopup('$form_element');";
|
||||
echo "<a href=\"$href\"><img src=\"images/find.png\" /></a>";
|
||||
echo "<a href=\"$href\">browse</a>\n";
|
||||
$title = $lang['chooser_link_tooltip'];
|
||||
echo "<a href=\"$href\" title=\"$title\"><img src=\"images/find.png\" /></a>";
|
||||
echo "<a href=\"$href\" title=\"$title\">browse</a>\n";
|
||||
}
|
||||
|
||||
function get_values($link_id,$entry_id,$attr){
|
||||
if( 0 == strcasecmp( $attr, 'jpegPhoto' ) ) {
|
||||
$values = ldap_get_values_len($link_id,$entry_id,$attr);
|
||||
} else {
|
||||
$values = ldap_get_values($link_id,$entry_id,$attr);
|
||||
unset($values['count']);
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
/*
|
||||
function utf8_decode($str)
|
||||
{
|
||||
global $code_page;
|
||||
if( ! $code_page )
|
||||
$code_page = "ISO-8859-1";
|
||||
return iconv("UTF8", $code_page, $str);
|
||||
}
|
||||
|
||||
function utf8_encode($str)
|
||||
{
|
||||
global $code_page;
|
||||
if( ! $code_page )
|
||||
$code_page = "ISO-8859-1";
|
||||
return iconv( $code_page, "UTF8", $str);
|
||||
}
|
||||
*/
|
||||
|
||||
function get_code_page()
|
||||
{
|
||||
global $code_page;
|
||||
if( ! $code_page )
|
||||
$code_page = "ISO-8859-1";
|
||||
return $code_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the string to the configured codepage and replace HTML chars
|
||||
* with their &-encoded equivelants, then echo to browser.
|
||||
*/
|
||||
function pla_echo( $str )
|
||||
{
|
||||
if( function_exists( "iconv" ) )
|
||||
$str = iconv( "UTF8", get_code_page(), $str );
|
||||
$str = htmlspecialchars( $str );
|
||||
echo $str;
|
||||
}
|
||||
|
||||
/*
|
||||
* UTF-8 safe method for exploding a DN into its RDN parts.
|
||||
*/
|
||||
function pla_explode_dn( $dn, $with_attributes=0 )
|
||||
{
|
||||
$dn = addcslashes( $dn, "<>" );
|
||||
$result = ldap_explode_dn( $dn, $with_attributes );
|
||||
//translate hex code into ascii again
|
||||
foreach( $result as $key => $value )
|
||||
$result[$key] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $value);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convenience function for fetching project HREFs (like bugs)
|
||||
*/
|
||||
function get_href( $type ) {
|
||||
$group_id = "61828";
|
||||
$bug_atid = "498546";
|
||||
$rfe_atid = "498549";
|
||||
switch( $type ) {
|
||||
case 'open_bugs': return "http://sourceforge.net/tracker/?group_id=$group_id&atid=$bug_atid";
|
||||
case 'add_bug': return "http://sourceforge.net/tracker/?func=add&group_id=$group_id&atid=$bug_atid";
|
||||
case 'open_rfes': return "http://sourceforge.net/tracker/?atid=$rfe_atid&group_id=$group_id&func=browse";
|
||||
case 'add_rfe': return "http://sourceforge.net/tracker/?func=add&group_id=$group_id&atid=$rfe_atid";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\?>\n"; ?>
|
||||
<?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>
|
||||
<title>phpLDAPadmin</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<script src="entry_chooser.js"></script>
|
||||
<script src="search_util.js"></script>
|
||||
</head>
|
||||
|
BIN
images/logo.jpg
Normal file
BIN
images/logo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
images/nt.png
Normal file
BIN
images/nt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 957 B |
BIN
images/warning.png
Normal file
BIN
images/warning.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
52
index.php
52
index.php
@ -1,26 +1,32 @@
|
||||
<?php/*
|
||||
<?php
|
||||
|
||||
/*******************************************
|
||||
<pre>
|
||||
|
||||
If you are seeing this in your browser,
|
||||
PHP is not installed on your web server!!!
|
||||
|
||||
*/?>
|
||||
</pre>
|
||||
*******************************************/
|
||||
|
||||
<?php require_once( 'functions.php' ); ?>
|
||||
@require 'common.php';
|
||||
|
||||
<?php if( ! file_exists( 'config.php' ) ) { ?>
|
||||
?>
|
||||
|
||||
<?php if( ! file_exists(realpath( 'config.php' )) ) { ?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>phpLDAPAdmin - <?php echo pla_version(); ?></title>
|
||||
<title>phpLDAPadmin - <?php echo pla_version(); ?></title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3 class="title">Configure phpLDAPAdmin</h1>
|
||||
<h3 class="title">Configure phpLDAPadmin</h1>
|
||||
<br />
|
||||
<br />
|
||||
<center>
|
||||
You need to configure phpLDAPAdmin. Edit the file 'config.php' to do so.<br />
|
||||
You need to configure phpLDAPadmin. Edit the file 'config.php' to do so.<br />
|
||||
<br />
|
||||
An example config file is provided in 'config.php.example'
|
||||
|
||||
@ -30,7 +36,7 @@ An example config file is provided in 'config.php.example'
|
||||
|
||||
<?php } elseif( check_config() ) {
|
||||
require 'config.php';
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\?>\n";
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
||||
|
||||
?>
|
||||
|
||||
@ -38,11 +44,11 @@ echo "<?xml version=\"1.0\" encoding=\"utf-8\?>\n";
|
||||
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 - <?php echo pla_version(); ?></title></head>
|
||||
<head><title>phpLDAPadmin - <?php echo pla_version(); ?></title></head>
|
||||
|
||||
<frameset cols="<?php echo $tree_width; ?>,*">
|
||||
<frame src="tree.php" name="left_frame" id="left_frame" />
|
||||
<frame src="search.php" name="right_frame" id="right_frame" />
|
||||
<frame src="welcome.php" name="right_frame" id="right_frame" />
|
||||
</frameset>
|
||||
|
||||
</html>
|
||||
@ -66,17 +72,35 @@ function check_config()
|
||||
if( ! extension_loaded( 'ldap' ) )
|
||||
{
|
||||
pla_error( "Your install of PHP appears to be missing LDAP support. Please install " .
|
||||
"LDAP support before using phpLDAPAdmin." );
|
||||
"LDAP support before using phpLDAPadmin." );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Make sure they have all the functions we will need */
|
||||
$required_functions = array( 'utf8_encode', 'utf8_decode', 'htmlspecialchars' );
|
||||
foreach( $required_functions as $function ) {
|
||||
if( ! function_exists( $function ) ) {
|
||||
pla_error( "Your install of PHP appears to be missing the function '<b>$function()</b>' " .
|
||||
"phpLDAPadmin requires this function to work properly." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure the config file is readable */
|
||||
if( ! is_readable( 'config.php' ) )
|
||||
//if( ! is_readable( 'config.php' ) )
|
||||
if( ! is_readable(realpath( 'config.php' )) )
|
||||
{
|
||||
echo "The config file 'config.php' is not readable. Please check its permissions.";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Make sure their PHP install is up to snuff */
|
||||
if( version_compare( phpversion(), "4.1.0" ) < 0 )
|
||||
{
|
||||
echo "You are using php version " . phpversion() . ". phpLDAPadmin requires version 4.1 or greater.";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check for syntax errors in config.php */
|
||||
// capture the result of including the file with output buffering
|
||||
ob_start();
|
||||
@ -92,7 +116,7 @@ function check_config()
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>phpLDAPAdmin Config File Error</title>
|
||||
<title>phpLDAPadmin Config File Error</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
|
||||
@ -151,7 +175,7 @@ function check_config()
|
||||
if( $count == 0 )
|
||||
{
|
||||
echo "None of the " . count($servers) . " servers in your \$servers array is ";
|
||||
echo "active in config.php. phpLDAPAdmin cannot proceed util you correct this.";
|
||||
echo "active in config.php. phpLDAPadmin cannot proceed util you correct this.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
142
lang/english.php
Normal file
142
lang/english.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
$lang = array();
|
||||
|
||||
// Search form
|
||||
$lang['simple_search_form_str'] = 'Simple Search Form';
|
||||
$lang['advanced_search_form_str'] = 'Advanced Search Form';
|
||||
$lang['server'] = 'Server';
|
||||
$lang['search_for_entries_whose'] = 'Search for entries whose';
|
||||
$lang['base_dn'] = 'Base DN';
|
||||
$lang['search_scope'] = 'Search Scope';
|
||||
$lang['search_ filter'] = 'Search Filter';
|
||||
$lang['show_attributes'] = 'Show Attributtes';
|
||||
$lang['Search'] = 'Search';
|
||||
$lang['equals'] = 'equals';
|
||||
$lang['starts_with'] = 'starts with';
|
||||
$lang['contains'] = 'contains';
|
||||
$lang['ends_with'] = 'ends with';
|
||||
$lang['sounds_like'] = 'sounds like';
|
||||
|
||||
// Tree browser
|
||||
$lang['request_new_feature'] = 'Request a new feature';
|
||||
$lang['see_open_requests'] = 'see open requests';
|
||||
$lang['report_bug'] = 'Report a bug';
|
||||
$lang['see_open_bugs'] = 'see open bugs';
|
||||
$lang['schema'] = 'schema';
|
||||
$lang['search'] = 'search';
|
||||
$lang['refresh'] = 'refresh';
|
||||
$lang['create'] = 'create';
|
||||
$lang['info'] = 'info';
|
||||
$lang['import'] = 'import';
|
||||
$lang['logout'] = 'logout';
|
||||
$lang['create_new'] = 'Create New';
|
||||
$lang['view_schema_for'] = 'View schema for';
|
||||
$lang['refresh_expanded_containers'] = 'Refresh all expanded containers for';
|
||||
$lang['create_new_entry_on'] = 'Create a new entry on';
|
||||
$lang['view_server_info'] = 'View server-supplied information';
|
||||
$lang['import_from_ldif'] = 'Import entries from an LDIF file';
|
||||
$lang['logout_of_this_server'] = 'Logout of this server';
|
||||
$lang['logged_in_as'] = 'Logged in as: ';
|
||||
$lang['read_only'] = 'read only';
|
||||
$lang['could_not_determine_root'] = 'Could not determin the root of your LDAP tree.';
|
||||
$lang['ldap_refuses_to_give_root'] = 'It appears that the LDAP server has been configured to not reveal its root.';
|
||||
$lang['please_specify_in_config'] = 'Please specify it in config.php';
|
||||
$lang['create_new_entry_in'] = 'Create a new entry in';
|
||||
|
||||
// Entry display
|
||||
$lang['delete_this_entry'] = 'Delete this entry';
|
||||
$lang['delete_this_entry_tooltip'] = 'You will be prompted to confirm this decision';
|
||||
$lang['copy_this_entry'] = 'Copy this entry';
|
||||
$lang['copy_this_entry_tooltip'] = 'Copy this object to another location, a new DN, or another server';
|
||||
$lang['export_to_ldif'] = 'Export to LDIF';
|
||||
$lang['export_to_ldif_tooltip'] = 'Save an LDIF dump of this object';
|
||||
$lang['export_subtree_to_ldif_tooltip'] = 'Save an LDIF dump of this object and all of its children';
|
||||
$lang['export_subtree_to_ldif'] = 'Export subtree to LDIF';
|
||||
$lang['export_to_ldif_mac'] = 'Macintosh style line ends';
|
||||
$lang['export_to_ldif_win'] = 'Windows style line ends';
|
||||
$lang['export_to_ldif_unix'] = 'Unix style line ends';
|
||||
$lang['create_a_child_entry'] = 'Create a child entry';
|
||||
$lang['add_a_jpeg_photo'] = 'Add a jpegPhoto';
|
||||
$lang['rename_entry'] = 'Rename Entry';
|
||||
$lang['rename'] = 'Rename';
|
||||
$lang['add'] = 'Add';
|
||||
$lang['view'] = 'View';
|
||||
$lang['add_new_attribute'] = 'Add New Attribute';
|
||||
$lang['add_new_attribute_tooltip'] = 'Add a new attribute/value to this entry';
|
||||
$lang['internal_attributes'] = 'Internal Attributes';
|
||||
$lang['hide_internal_attrs'] = 'Hide internal attributes';
|
||||
$lang['show_internal_attrs'] = 'Show internal attributes';
|
||||
$lang['internal_attrs_tooltip'] = 'Attributes set automatically by the system';
|
||||
$lang['entry_attributes'] = 'Entry Attributes';
|
||||
$lang['click_to_display'] = 'click to display';
|
||||
$lang['hidden'] = 'hidden';
|
||||
$lang['none'] = 'none';
|
||||
$lang['save_changes'] = 'Save Changes';
|
||||
$lang['add_value'] = 'add value';
|
||||
$lang['add_value_tooltip'] = 'Add an additional value to this attribute';
|
||||
$lang['refresh'] = 'refresh';
|
||||
$lang['refresh_this_entry'] = 'Refresh this entry';
|
||||
$lang['delete_hint'] = 'Hint: <b>To delete an attribute</b>, empty the text field and click save.';
|
||||
$lang['viewing_read_only'] = 'Viewing entry in read-only mode.';
|
||||
$lang['change_entry_rdn'] = 'Change this entry\'s RDN';
|
||||
$lang['no_new_attrs_available'] = 'no new attributes available for this entry';
|
||||
$lang['binary_value'] = 'Binary value';
|
||||
$lang['add_new_binary_attr'] = 'Add New Binary Attribute';
|
||||
$lang['add_new_binary_attr_tooltip'] = 'Add a new binary attribute/value from a file';
|
||||
$lang['alias_for'] = 'Alias for';
|
||||
$lang['download_value'] = 'download value';
|
||||
$lang['delete_attribute'] = 'delete attribute';
|
||||
$lang['true'] = 'true';
|
||||
$lang['false'] = 'false';
|
||||
$lang['none_remove_value'] = 'none, remove value';
|
||||
$lang['really_delete_attribute'] = 'Really delete attribute';
|
||||
|
||||
// Schema browser
|
||||
$lang['the_following_objectclasses'] = 'The following <b>objectClasses</b> are supported by this LDAP server.';
|
||||
$lang['the_following_attributes'] = 'The following <b>attributeTypes</b> are supported by this LDAP server.';
|
||||
$lang['the_following_matching'] = 'The following <b>matching rules</b> are supported by this LDAP server.';
|
||||
$lang['the_following_syntaxes'] = 'The following <b>syntaxes</b> are supported by this LDAP server.';
|
||||
$lang['jump_to_objectclass'] = 'Jump to an objectClass';
|
||||
$lang['jump_to_attr'] = 'Jump to an attribute';
|
||||
$lang['schema_for_server'] = 'Schema for server';
|
||||
$lang['required_attrs'] = 'Required Attributes';
|
||||
$lang['optional_attrs'] = 'Optional Attributes';
|
||||
$lang['OID'] = 'OID';
|
||||
$lang['desc'] = 'Description';
|
||||
$lang['is_obsolete'] = 'This objectClass is <b>obsolete</b>';
|
||||
$lang['inherits'] = 'Inherits';
|
||||
$lang['jump_to_this_oclass'] = 'Jump to this objectClass definition';
|
||||
$lang['matching_rule_oid'] = 'Matching Rule OID';
|
||||
$lang['syntax_oid'] = 'Syntax OID';
|
||||
|
||||
// Adding objectClass form
|
||||
$lang['new_required_attrs'] = 'New Required Attributes';
|
||||
$lang['requires_to_add'] = 'This action requires you to add';
|
||||
$lang['new_attributes'] = 'new attributes';
|
||||
$lang['new_required_attrs_instructions'] = 'Instructions: In order to add this objectClass to this entry, you must specify';
|
||||
$lang['that_this_oclass_requires'] = 'that this objectClass requires. You can do so in this form.';
|
||||
$lang['add_oclass_and_attrs'] = 'Add ObjectClass and Attributes';
|
||||
|
||||
// General
|
||||
$lang['chooser_link_tooltip'] = 'Click to popup a dialog to select an entry (DN) graphically';
|
||||
$lang['no_updates_in_read_only_mode'] = 'You cannot perform updates while server is in read-only mode';
|
||||
$lang['bad_server_id'] = 'Bad server id';
|
||||
$lang['not_enough_login_info'] = 'Not enough information to login to server. Please check your configuration.';
|
||||
$lang['could_not_connect'] = 'Could not connect to LDAP server.';
|
||||
$lang['could_not_perform_ldap_mod_add'] = 'Could not perform ldap_mod_add operation.';
|
||||
|
||||
// Add value form
|
||||
$lang['add_new'] = 'Add new';
|
||||
$lang['value_to'] = 'value to';
|
||||
$lang['server'] = 'Server';
|
||||
$lang['distinguished_name'] = 'Distinguished Name';
|
||||
$lang['current_list_of'] = 'Current list of';
|
||||
$lang['values_for_attribute'] = 'values for attribute';
|
||||
$lang['inappropriate_matching_note'] = 'Note: You will get an "inappropriate matching" error if you have not<br />' .
|
||||
'setup an <tt>EQUALITY</tt> rule on your LDAP server for this attribute.';
|
||||
$lang['enter_value_to_add'] = 'Enter the value you would like to add:';
|
||||
$lang['new_required_attrs_note'] = 'Note: you may be required to enter new attributes<br />that this objectClass requires.';
|
||||
$lang['syntax'] = 'Syntax';
|
||||
|
||||
?>
|
70
lang/french.php
Normal file
70
lang/french.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
$lang = array();
|
||||
|
||||
// Advanced/simple search form
|
||||
$lang['simple_search_form_str'] = 'Recherche Simple';
|
||||
$lang['advanced_search_form_str'] = 'Recherche avancée';
|
||||
$lang['server'] = 'Serveur';
|
||||
$lang['search_for_entries_whose'] = 'Chercher les entrées dont';
|
||||
$lang['base_dn'] = 'Base DN';
|
||||
$lang['search_scope'] = 'Portée de la recherche';
|
||||
$lang['search_ filter'] = 'Filtre de la recherche';
|
||||
$lang['show_attributes'] = 'Montrer les attributs';
|
||||
$lang['Search'] = 'Chercher';
|
||||
$lang['equals'] = 'est égal à';
|
||||
$lang['starts_with'] = 'commence par';
|
||||
$lang['contains'] = 'contient';
|
||||
$lang['ends_with'] = 'finit par';
|
||||
$lang['sounds_like'] = 'ressemble à';
|
||||
|
||||
// tree.php
|
||||
$lang['request_new_feature'] = 'Demander une nouvelle fonctionnalité';
|
||||
$lang['see_open_requests'] = 'voir les demandes en cours';
|
||||
$lang['report_bug'] = 'Signaler un bogue';
|
||||
$lang['see_open_bugs'] = 'voir les bogues en cours';
|
||||
$lang['schema'] = 'schema';
|
||||
$lang['search'] = 'chercher';
|
||||
$lang['refresh'] = 'rafraîchir';
|
||||
$lang['create'] = 'créer';
|
||||
$lang['info'] = 'info';
|
||||
$lang['import'] = 'importer';
|
||||
$lang['logout'] = 'logout (FIXME)';
|
||||
$lang['create_new'] = 'Créer';
|
||||
|
||||
|
||||
// entry display
|
||||
$lang['delete_this_entry'] = 'Supprimer cette entrée';
|
||||
$lang['delete_this_entry_tooltip'] = 'Il vous sera demander confirmation';
|
||||
$lang['copy_this_entry'] = 'Copier cette entrée';
|
||||
$lang['copy_this_entry_tooltip'] = 'Copier cet objet vers un autre endroit, un nouveau DN ou un autre serveur';
|
||||
$lang['export_to_ldif'] = 'Exporter au format LDIF';
|
||||
$lang['export_to_ldif_tooltip'] = 'Sauvegarder cet objet au format ldif';
|
||||
$lang['export_subtree_to_ldif_tooltip'] = 'Sauvegarder cet objet ainsi que tous les sous-objets au format ldif';
|
||||
$lang['export_subtree_to_ldif'] = 'Exporter l\'arborescence au format ldif';
|
||||
$lang['export_to_ldif_mac'] = 'Fins de ligne Macintosh';
|
||||
$lang['export_to_ldif_win'] = 'Fins de lignes Windows';
|
||||
$lang['export_to_ldif_unix'] = 'Fins de ligne Unix ';
|
||||
$lang['create_a_child_entry'] = 'Créer une sous-entrée';
|
||||
$lang['add_a_jpeg_photo'] = 'Ajouter une jpegPhoto';
|
||||
$lang['rename_entry'] = 'Renommer l\'entrée';
|
||||
$lang['rename'] = 'Renommer';
|
||||
$lang['add'] = 'Ajouter';
|
||||
$lang['view'] = 'Ajouter';
|
||||
$lang['add_new_attribute'] = 'Ajouter un nouvel attribut';
|
||||
$lang['add_new_attribute_tooltip'] = 'Ajouter un nouvel attribut/une nouvelle valeur à cette entrée';
|
||||
$lang['internal_attributes'] = 'Attributs Internes';
|
||||
$lang['hide_internal_attrs'] = 'Cacher les attributs internes';
|
||||
$lang['show_internal_attrs'] = 'Montrer les attributs internes';
|
||||
$lang['internal_attrs_tooltip'] = 'Attributs établis automatiquement par le système';
|
||||
$lang['entry_attributes'] = 'Attributs de l\'entrée';
|
||||
$lang['click_to_display'] = 'Cliquer pour afficher';
|
||||
$lang['hidden'] = 'caché';
|
||||
$lang['none'] = 'aucun';
|
||||
$lang['save_changes'] = 'Sauver les modifications';
|
||||
$lang['add_value'] = 'ajouter une valeur';
|
||||
|
||||
|
||||
// Repeat above for *every* string in phpLDAPadmin
|
||||
|
||||
?>
|
103
lang/german.php
Normal file
103
lang/german.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
$lang = array();
|
||||
|
||||
// Search form
|
||||
$lang['simple_search_form_str'] = 'Einfache Suche';//'Simple Search Form';
|
||||
$lang['advanced_search_form_str'] = 'Experten Suche';//'Advanced Search Form';
|
||||
$lang['server'] = 'Server';//'Server';
|
||||
$lang['search_for_entries_whose'] = 'Suche nach Einträgen die';//'Search for entries whose';
|
||||
$lang['base_dn'] = 'Base DN';//'Base DN';
|
||||
$lang['search_scope'] = 'Suchart';//'Search Scope';
|
||||
$lang['search_ filter'] = 'Suchfilter';//'Search Filter';
|
||||
$lang['show_attributes'] = 'Zeige Attribute';//'Show Attributtes';
|
||||
$lang['Search'] = 'Suchen';//'Search';
|
||||
$lang['equals'] = 'gleich';//'equals';
|
||||
$lang['starts_with'] = 'beginnt mit';//'starts with';
|
||||
$lang['contains'] = 'enthä';//'contains';
|
||||
$lang['ends_with'] = 'endet mit';//'ends with';
|
||||
$lang['sounds_like'] = 'änlich wie';//'sounds like';
|
||||
|
||||
// Tree browser
|
||||
$lang['request_new_feature'] = 'Anfragen von neuen Möglichkeiten';//'Request a new feature';
|
||||
$lang['see_open_requests'] = 'Siehe offene Anfragen';//'see open requests';
|
||||
$lang['report_bug'] = 'Einen Fehler berichten';//'Report a bug';
|
||||
$lang['see_open_bugs'] = 'Siehe offene Fehler';//'see open bugs';
|
||||
$lang['schema'] = 'schema';//'schema';
|
||||
$lang['search'] = 'suche';//'search';
|
||||
$lang['refresh'] = 'aktualisieren';//'refresh';
|
||||
$lang['create'] = 'Neu';//'create';
|
||||
$lang['info'] = 'info';//'info';
|
||||
$lang['import'] = 'import';//'import';
|
||||
$lang['logout'] = 'logout';// 'Abmelden' 'logout';
|
||||
$lang['create_new'] = 'Neuen erzeugen';//'Create New';
|
||||
|
||||
|
||||
// Entry display
|
||||
$lang['delete_this_entry'] = 'Diesen Eintrag löschen';//'Delete this entry';
|
||||
$lang['delete_this_entry_tooltip'] = 'You will be prompted to confirm this decision';
|
||||
$lang['copy_this_entry'] = 'Diesen Eintrag kopieren';//'Copy this entry';
|
||||
$lang['copy_this_entry_tooltip'] = 'Copy this object to another location, a new DN, or another server';
|
||||
$lang['export_to_ldif'] = 'Exportieren nach LDIF';//'Export to LDIF';
|
||||
$lang['export_to_ldif_tooltip'] = 'Speichere einen LDIF-Abzug diese Objektes';//'Save an LDIF dump of this object';
|
||||
$lang['export_subtree_to_ldif_tooltip'] = 'Speicher eine LDIF-Abzug ab diesem Objekt und alle seine Untereinträge';//'Save an LDIF dump of this object and all of its children';
|
||||
$lang['export_subtree_to_ldif'] = 'Export Unterbaum nach LDIF';//'Export subtree to LDIF';
|
||||
$lang['export_to_ldif_mac'] = 'Zeilenende für Macintosh';//'Macintosh style line ends';
|
||||
$lang['export_to_ldif_win'] = 'Zeilenende für Windows';//'Windows style line ends';
|
||||
$lang['export_to_ldif_unix'] = 'Zeilenende für Unix';//'Unix style line ends';
|
||||
$lang['create_a_child_entry'] = 'Erzeuge einen Untereintrag';//'Create a child entry';
|
||||
$lang['add_a_jpeg_photo'] = 'Ein JPEG-Foto hinzufügen';//'Add a jpegPhoto';
|
||||
$lang['rename_entry'] = 'Eintrag umbenennen';//'Rename Entry';
|
||||
$lang['rename'] = 'Umbenennen';//'Rename';
|
||||
$lang['add'] = 'Hinzufügen';//'Add';
|
||||
$lang['view'] = 'Ansehen';//'View';
|
||||
$lang['add_new_attribute'] = 'Neues Attribut hinzügen';//'Add New Attribute';
|
||||
$lang['add_new_attribute_tooltip'] = 'Füge ein neues Attribut/Wert zu diesem Eintrag hinzu';// 'Add a new attribute/value to this entry';
|
||||
$lang['internal_attributes'] = 'Interne Attribute';//'Internal Attributes';
|
||||
$lang['hide_internal_attrs'] = 'Verdecke interne Attribute';//'Hide internal attributes';
|
||||
$lang['show_internal_attrs'] = 'Zeige interne Attribute';//'Show internal attributes';
|
||||
$lang['internal_attrs_tooltip'] = 'Attribute werden automatisch vom System erzeugt.';//'Attributes set automatically by the system';
|
||||
$lang['entry_attributes'] = 'Attribute des Eintrages';//'Entry Attributes';
|
||||
$lang['click_to_display'] = 'Klicken zum Ansehen';//'click to display';
|
||||
$lang['hidden'] = 'verdeckt';//'hidden';
|
||||
$lang['none'] = 'Keine';//'none';
|
||||
$lang['save_changes'] = 'Änderungen speichern';//'Save Changes';
|
||||
$lang['add_value'] = 'Wert hinzufügen';//'add value';
|
||||
$lang['add_value_tooltip'] = 'Füg einen weiteren Wert zu dem Attribut hinzu';//'Add an additional value to this attribute';
|
||||
//$lang['refresh'] = 'Refresh';
|
||||
$lang['refresh_this_entry'] = 'Aktualisiere den Entrag';//'Refresh this entry';
|
||||
$lang['delete_hint'] = 'Hinweis: Um ein Attribute zu löschen, leeren Sie den Inhalt des Wertes.';//'Hint: <b>To delete an attribute</b>, empty the text field and click save.';
|
||||
$lang['viewing_read_only'] = 'Zeige Eintrag im Nurlesemodus';//'Viewing entry in read-only mode.';
|
||||
$lang['change_entry_rdn'] = 'Ändere den RDN des Eintrages';//'Change this entry\'s RDN';
|
||||
$lang['no_new_attrs_available'] = 'Keine weiteren Attribute verfügbar für diesen Eintrag';//'no new attributes available for this entry';
|
||||
$lang['binary_value'] = 'Binärwert';//'Binary value';
|
||||
$lang['add_new_binary_attr'] = 'Neuen Binärwert hinzufügen';//'Add New Binary Attribute';
|
||||
$lang['add_new_binary_attr_tooltip'] = 'ABCDEFGH';//'Add a new binary attribute/value from a file';
|
||||
$lang['alias_for'] = 'Alias für';//'Alias for';
|
||||
$lang['download_value'] = 'Wert herunterladen';//'download value';
|
||||
$lang['delete_attribute'] = 'Lösche Attribut';//'delete attribute';
|
||||
$lang['true'] = 'Wahr';//'true';
|
||||
$lang['false'] = 'Falsch';//'false';
|
||||
$lang['none_remove_value'] = 'nichts, entferne den Wert';//?? //'none, remove value';
|
||||
$lang['really_delete_attribute'] = 'Lösche das Attribut wirklich';//'Really delete attribute';
|
||||
|
||||
// Schema browser
|
||||
$lang['the_following_objectclasses'] = 'Die folgenden objectClass werden vom LDAP-Server unterstützt.';//'The following <b>objectClasses</b> are supported by this LDAP server.';
|
||||
$lang['the_following_attributes'] = 'Die folgenden Attribute werden vom LDAP-Server unterstützt.';//'The following <b>attributeTypes</b> are supported by this LDAP server.';
|
||||
$lang['the_following_matching'] = 'Die folgenden Suchregeln werden vom LDAP-Server unterstützt.';//'The following <b>matching rules</b> are supported by this LDAP server.';
|
||||
$lang['the_following_syntaxes'] = 'Die folgenden Syntaxe werden vom LDAP-Server unterstützt.';//'The following <b>syntaxes</b> are supported by this LDAP server.';
|
||||
$lang['jump_to_objectclass'] = 'Gehe zur objectClass';//'Jump to an objectClass';
|
||||
$lang['jump_to_attr'] = 'Gehe zum Attribut';//'Jump to an attribute';
|
||||
$lang['schema_for_server'] = 'Schema für Server';//'Schema for server';
|
||||
$lang['required_attrs'] = 'Notwendige Attribute';//'Required Attributes';
|
||||
$lang['optional_attrs'] = 'Optionale Attribute';//'Optional Attributes';
|
||||
$lang['OID'] = 'OID';//'OID';
|
||||
$lang['desc'] = 'Beschreibung';//'Description';
|
||||
$lang['is_obsolete'] = 'Diese objectClass ist veraltet';//'This objectClass is <b>obsolete</b>';
|
||||
$lang['inherits'] = 'Abgeleitet von';//'Inherits';
|
||||
$lang['jump_to_this_oclass'] = 'Gehe zur objectClass Definition';//'Jump to this objectClass definition';
|
||||
|
||||
// General
|
||||
$lang['chooser_link_tooltip'] = "Click to popup a dialog to select an entry (DN) graphically";
|
||||
|
||||
?>
|
@ -18,9 +18,11 @@
|
||||
0x10 LDAP_NO_SUCH_ATTRIBUTE "That entry does not contain the attribute specified."
|
||||
0x11 LDAP_UNDEFINED_TYPE "The attribute type specified is invalid."
|
||||
0x12 LDAP_INAPPROPRIATE_MATCHING "This usually means that your LDAP server has not defined an equality rule
|
||||
for the attribute you are trying to alter. This is not phpLDAPAdmin's fault as the
|
||||
for the attribute you are trying to alter. This is not phpLDAPadmin's fault as the
|
||||
LDAP server has refused to perform the operation (as well it should if there is
|
||||
no equality rule for it to use for the operation)."
|
||||
no equality rule for it to use for the operation). This generally applies when
|
||||
adding a new value to a binary attribute, or removing a single value from a
|
||||
multi-valued binary attribute."
|
||||
0x13 LDAP_CONSTRAINT_VIOLATION "Some constraint would be violated by performing the action. This can happen when
|
||||
you try to add a second value to a single-valued attribute, for example."
|
||||
0x14 LDAP_TYPE_OR_VALUE_EXISTS "An attribute type or attribute value
|
||||
@ -51,7 +53,8 @@
|
||||
to exist or that would remove a required attribute, given the current list
|
||||
of ObjectClasses."
|
||||
0x42 LDAP_NOT_ALLOWED_ON_NONLEAF "The entry you tried to operate on has children. (usually this means you
|
||||
tried to delete the entry, which you cannot do to an entry with children)."
|
||||
tried to delete or rename the entry, which you cannot do to an entry
|
||||
with children)."
|
||||
0x43 LDAP_NOT_ALLOWED_ON_RDN "You cannot preform that operation on a the relative distinguished name
|
||||
(RDN) of an object."
|
||||
0x44 LDAP_ALREADY_EXISTS "The object already exists (usually you are trying to create a new object
|
||||
|
@ -11,10 +11,9 @@
|
||||
* - scope (one of 'sub', 'base', or 'one')
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_GET['dn'] ) );
|
||||
$dn = rawurldecode( $_GET['dn'] );
|
||||
$server_id = $_GET['server_id'];
|
||||
$format = $_GET['format'];
|
||||
$scope = $_GET['scope'] ? $_GET['scope'] : 'base';
|
||||
@ -23,12 +22,15 @@ check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
$objects = pla_ldap_search( $server_id, 'objectClass=*', $dn, array(), $scope, false );
|
||||
$server_name = $servers[ $server_id ][ 'name' ];
|
||||
$server_host = $servers[ $server_id ][ 'host' ];
|
||||
|
||||
//echo "<pre>";
|
||||
//print_r( $objects );
|
||||
//exit;
|
||||
|
||||
$rdn = get_rdn( $dn );
|
||||
$friendly_rdn = get_rdn( $dn, 1 );
|
||||
|
||||
switch( $format ) {
|
||||
case 'win': $br = "\r\n"; break;
|
||||
@ -40,44 +42,62 @@ switch( $format ) {
|
||||
if( ! $objects )
|
||||
pla_error( "Search on dn (" . htmlspecialchars($dn) . ") came back empty" );
|
||||
|
||||
header( "Content-type: text/plain" );
|
||||
header( "Content-disposition: attachment; filename=\"$rdn.ldif\"" );
|
||||
// define the max length of a ldif line to 76
|
||||
// as it is suggested (implicitely) for (some) binary
|
||||
// attributes in rfc 2849 (see note 10)
|
||||
|
||||
define("MAX_LDIF_LINE_LENGTH",76);
|
||||
|
||||
header( "Content-type: application/download" );
|
||||
header( "Content-Disposition: filename=$friendly_rdn.ldif" );
|
||||
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 );
|
||||
header( "Pragma: no-cache" );
|
||||
|
||||
echo "version: 1$br$br";
|
||||
echo "# LDIF Export for: $rdn$br";
|
||||
echo "# Scope: $scope, " . count( $objects ) . " entries$br";
|
||||
echo "# Generated by phpLDAPAdmin on " . date("F j, Y g:i a") . "$br";
|
||||
echo "# LDIF Export for: " . utf8_decode( $dn ) . "$br";
|
||||
echo "# Generated by phpLDAPadmin on " . date("F j, Y g:i a") . "$br";
|
||||
echo "# Server: " . utf8_decode( $server_name ) . " ($server_host)$br";
|
||||
echo "# Search Scope: $scope$br";
|
||||
echo "# Total entries: " . count( $objects ) . "$br";
|
||||
echo $br;
|
||||
|
||||
$counter = 0;
|
||||
foreach( $objects as $dn => $attrs )
|
||||
{
|
||||
$counter++;
|
||||
unset( $attrs['dn'] );
|
||||
unset( $attrs['count'] );
|
||||
|
||||
if( is_safe_ascii( $dn ) )
|
||||
echo "dn: $dn$br";
|
||||
else
|
||||
echo "dn:: " . base64_encode( $dn ) . $br;
|
||||
|
||||
// display "# Entry 3: cn=test,dc=example,dc=com..."
|
||||
$title_string = "# Entry $counter: " . utf8_decode( $dn );
|
||||
if( strlen( $title_string ) > MAX_LDIF_LINE_LENGTH-3 )
|
||||
$title_string = substr( $title_string, 0, MAX_LDIF_LINE_LENGTH-3 ) . "...";
|
||||
echo "$title_string$br";
|
||||
|
||||
// display the DN
|
||||
if( is_safe_ascii( $dn ) )
|
||||
multi_lines_display("dn: $dn");
|
||||
else
|
||||
multi_lines_display("dn:: " . base64_encode( $dn ));
|
||||
|
||||
// display all the attrs/values
|
||||
foreach( $attrs as $attr => $val ) {
|
||||
if( is_array( $val ) ) {
|
||||
foreach( $val as $v ) {
|
||||
if( is_safe_ascii( $v ) ) {
|
||||
echo "$attr: $v$br";
|
||||
multi_lines_display("$attr: $v");
|
||||
} else {
|
||||
echo "$attr:: " . base64_encode( $v ) . $br;
|
||||
multi_lines_display("$attr:: " . base64_encode( $v ));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$v = $val;
|
||||
if( is_safe_ascii( $v ) ) {
|
||||
echo "$attr: $v$br";
|
||||
multi_lines_display("$attr: $v");
|
||||
} else {
|
||||
echo "$attr:: " . base64_encode( $v ) . $br;
|
||||
multi_lines_display("$attr:: " . base64_encode( $v ));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,3 +111,26 @@ function is_safe_ascii( $str )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function multi_lines_display($str){
|
||||
global $br;
|
||||
|
||||
$length_string = strlen($str);
|
||||
$max_length = MAX_LDIF_LINE_LENGTH;
|
||||
|
||||
while ($length_string > $max_length){
|
||||
echo substr($str,0,$max_length).$br." ";
|
||||
$str= substr($str,$max_length,$length_string);
|
||||
$length_string = strlen($str);
|
||||
|
||||
// need to do minus one to align on the right
|
||||
// the first line with the possible following lines
|
||||
// as these will have an extra space
|
||||
$max_length = MAX_LDIF_LINE_LENGTH-1;
|
||||
}
|
||||
echo $str."".$br;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
418
ldif_functions.php
Normal file
418
ldif_functions.php
Normal file
@ -0,0 +1,418 @@
|
||||
<?php
|
||||
/**
|
||||
* file: ldif_functions.php
|
||||
* ------------------------
|
||||
* Declare the functions for handling ldif file
|
||||
* this is considered as beta version, there is some things to improve:
|
||||
* -change some method
|
||||
* -make it more modular
|
||||
* -review error message
|
||||
* -handle the number version
|
||||
* -review regexp
|
||||
* -make a class ?
|
||||
* -handle base64 for modrdn
|
||||
*/
|
||||
|
||||
//warning flag;
|
||||
$warning=0;
|
||||
|
||||
// warning message if any
|
||||
$warning_message;
|
||||
|
||||
// boolean flag in case of error
|
||||
$error=0;
|
||||
|
||||
// the error mesage if any
|
||||
$error_message;
|
||||
|
||||
// to keep track of the line number while parsing the file
|
||||
$line_number = 0;
|
||||
|
||||
// keep track of the current line while parsing the file
|
||||
$current_line;
|
||||
|
||||
|
||||
|
||||
$fp;
|
||||
|
||||
function ldif_open_file($file_name){
|
||||
global $fp;
|
||||
$fp=fopen($file_name,"r");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function ldif_eof(){
|
||||
global $fp;
|
||||
return feof($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current line is a comment line
|
||||
*
|
||||
* @return true if the current line is a ldif comment,false otherwise
|
||||
*/
|
||||
|
||||
function ldif_is_comment_line(){
|
||||
global $current_line;
|
||||
return substr(trim($current_line),0,1)=="#"?1:0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is the curent line is a blank line
|
||||
*
|
||||
* @return true if it is a blank line,false otherwise
|
||||
*/
|
||||
|
||||
function ldif_is_blank_line(){
|
||||
global $current_line;
|
||||
return(trim($current_line)=="")?1:0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current line is a line with a dn
|
||||
*
|
||||
* @return true if the line contains a dn line, false otherwise.
|
||||
*/
|
||||
|
||||
function ldif_is_dn_line(){
|
||||
global $current_line;
|
||||
return ereg("^dn:",$current_line)?1:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the next line of the ldif file
|
||||
*/
|
||||
|
||||
function ldif_next_line(){
|
||||
global $line_number;
|
||||
global $current_line;
|
||||
global $fp;
|
||||
|
||||
$current_line = fgets($fp,1024);
|
||||
while(!ereg("\n|\r\n",$current_line)&&!ldif_eof()){
|
||||
$current_line.=fgets($fp,1024);
|
||||
}
|
||||
|
||||
$line_number++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the version of the ldif file
|
||||
*
|
||||
**/
|
||||
|
||||
function ldif_check_version(){
|
||||
global $warning;
|
||||
global $warning_message;
|
||||
global $error_message;
|
||||
global $error;
|
||||
global $line_number;
|
||||
global $current_line;
|
||||
|
||||
// boolean flag to see if any valid ldif line is found
|
||||
$ldif_line_found=0;
|
||||
|
||||
while(!ldif_eof()&&!$ldif_line_found &&!$warning){
|
||||
|
||||
//get the first line
|
||||
ldif_next_line();
|
||||
|
||||
// skip line with comment and blank line
|
||||
if(ldif_is_comment_line()||ldif_is_blank_line()){
|
||||
//debug usage
|
||||
//echo "$line_number -".(ldif_is_comment_line()?"comment":"blank line")."<br/>";
|
||||
}
|
||||
elseif(ereg("^version",trim($current_line))){
|
||||
$ldif_line_found=1;
|
||||
ldif_next_line();
|
||||
// TODO: handle the version number here
|
||||
}
|
||||
// not valid ldif line was found
|
||||
else{
|
||||
//set the flag warning
|
||||
$warning=1;
|
||||
$warning_message = "No version found - assuming 1";
|
||||
}
|
||||
|
||||
}//end while
|
||||
|
||||
$warning?0:1;
|
||||
}// end get_version() method
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a warning message
|
||||
*
|
||||
* @return a warning message
|
||||
*/
|
||||
|
||||
function ldif_warning_message(){
|
||||
global $warning_message;
|
||||
return $warning_message;
|
||||
}
|
||||
|
||||
function ldif_error_message(){
|
||||
global $error_message;
|
||||
return $error_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the file is valie
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function is_valid_file($path_to_file){
|
||||
|
||||
return file_exists($path_to_file)&&is_file($path_to_file)&&is_readable($path_to_file);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the file
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function ldif_close(){
|
||||
global $fp;
|
||||
@fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the action that the ldap server should do with an entry
|
||||
* The default action is add.
|
||||
*
|
||||
* @return the action the server should do.
|
||||
*/
|
||||
|
||||
function ldif_get_action(){
|
||||
global $current_line;
|
||||
|
||||
// default action is add
|
||||
$action ="add";
|
||||
if(ereg("changetype:[ ]*(delete|add|modrdn|moddn|modify)",$current_line,$arr)){
|
||||
$action = $arr[1];
|
||||
ldif_next_line();
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the dn of an entry
|
||||
|
||||
* @return the dn value of an entry
|
||||
*/
|
||||
|
||||
function ldif_fetch_dn_entry(){
|
||||
|
||||
global $error;
|
||||
global $current_line;
|
||||
global $error_message;
|
||||
global $line_number;
|
||||
global $number_of_lines;
|
||||
// the value of the dn
|
||||
$current_dn_value;
|
||||
|
||||
//boolean flag to see if any dn was found
|
||||
$dn_found=0;
|
||||
|
||||
|
||||
while(!ldif_eof()&&!$dn_found&&!$error){
|
||||
|
||||
//skip comment and blank line
|
||||
if(ldif_is_blank_line()||ldif_is_comment_line()){
|
||||
//debug
|
||||
//echo "$line_number - comment\n<br>";
|
||||
ldif_next_line();
|
||||
}
|
||||
// case where the dn is found
|
||||
elseif(ldif_is_dn_line()){
|
||||
$current_dn=$current_line;
|
||||
//debug
|
||||
//echo "$line_number - $current_line<br>";
|
||||
$dn_found=1;
|
||||
}
|
||||
else{
|
||||
$error=1;
|
||||
$error_message = "Error: Line ".$line_number." - a valid dn is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
}//fin while
|
||||
|
||||
|
||||
|
||||
// if mainly to hanlde the case
|
||||
//where a dn was found and is written on several lines
|
||||
// could be use to test if any white line appears after
|
||||
if($dn_found&&!ldif_eof()){
|
||||
|
||||
//boolean flag to see if the dn is written on more than one line
|
||||
$dn_has_next=0;
|
||||
|
||||
//keeping track of the line number of the dn when first encountered
|
||||
$dn_line_number = $line_number;
|
||||
// empty string to store the possible following lines
|
||||
while(!$dn_has_next){
|
||||
ldif_next_line();
|
||||
|
||||
//if next line begin with a space and is not empty
|
||||
// append to the previous line
|
||||
if((substr($current_line,0,1)==" ")){
|
||||
ereg_replace("\n|\r|\r\n","",$current_dn =trim($current_dn).trim($current_line));
|
||||
}
|
||||
//else leaving the while loop
|
||||
else{
|
||||
$dn_has_next=1;
|
||||
|
||||
}
|
||||
|
||||
}//end while
|
||||
|
||||
//debug
|
||||
//echo $dn_line_number." - ".$current_dn."\r\n<br>";
|
||||
// handle base 64 case here
|
||||
if(ereg("^dn::",$current_dn)){
|
||||
|
||||
$current_dn = base64_decode(trim(substr($current_dn,4,strlen($current_dn)-1)));
|
||||
|
||||
}else{
|
||||
$current_dn = trim(substr($current_dn,3,strlen($current_dn)-1));
|
||||
|
||||
|
||||
}
|
||||
// echo $dn_line_number."-".$current_dn."<br />";
|
||||
}
|
||||
|
||||
return $current_dn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* functions which will return a array of attributes
|
||||
* for this entry
|
||||
*
|
||||
* @return attrs the array of attributes
|
||||
*/
|
||||
|
||||
function ldif_fetch_attributes_for_entry(){
|
||||
global $error;
|
||||
global $current_line;
|
||||
global $line_number;
|
||||
global $error_message;
|
||||
|
||||
global $server_id;
|
||||
$attribute_value="";
|
||||
|
||||
//array to store the attribute
|
||||
$attrs = array();
|
||||
|
||||
|
||||
// while we dont find any empty line or any error occur
|
||||
while(trim($current_line)!=""&&$error!=1){
|
||||
|
||||
|
||||
//1 - we need to check if it's a valid ldif line.
|
||||
//-----------------------------------------------
|
||||
|
||||
if(ereg(":",trim($current_line),$arr)&&substr($current_line,0,1)!=" "){
|
||||
|
||||
//get the position of the character ":"
|
||||
$pos = strpos($current_line,":");
|
||||
|
||||
//get the name of the attribute
|
||||
|
||||
$attribute_name = substr($current_line,0, $pos);
|
||||
// get the value part of the attribute
|
||||
$attribute_value_part = trim(substr($current_line,$pos+1,strlen($current_line)));
|
||||
|
||||
//2 - we get the description and the "value" part
|
||||
// now check if it's split over several lines
|
||||
|
||||
$att_has_next = 0;
|
||||
$attr_line_number=$line_number;
|
||||
|
||||
while(!$att_has_next){
|
||||
ldif_next_line();
|
||||
|
||||
//if there is a another line for the attribute value,it should:
|
||||
// 1 - begin with a white space
|
||||
// 2 - have a length > 1
|
||||
// 3 - not have the character :
|
||||
if((substr($current_line,0,1)==" ")&&!ereg(":",trim($current_line))){
|
||||
ereg_replace("\n|\r|\r\n","",$attribute_value_part =trim($attribute_value_part).trim($current_line));
|
||||
}
|
||||
else{
|
||||
$att_has_next=1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//3 - need to see if the value is base 64 encoded,an url
|
||||
//-------------------------------------------------------
|
||||
$attribute_value="";
|
||||
//if the next character in the value part is ":";it's it base 64 encoded
|
||||
if(substr($attribute_value_part,0,1)==":"){
|
||||
|
||||
// it is binary data,so we just decode it
|
||||
$attribute_value = base64_decode(trim(substr($attribute_value_part,1)));
|
||||
|
||||
}
|
||||
//else if the next charachter is <, we have to handle an url
|
||||
elseif(substr($attribute_value_part,0,1)=="<"){
|
||||
// we need to handle the case for the scheme "file://" as it
|
||||
//doesn't seem to be supported by fopen
|
||||
|
||||
$file_path_with_scheme= trim(substr($attribute_value_part,1));
|
||||
|
||||
if(ereg("^file://",$file_path_with_scheme)){
|
||||
|
||||
$file_path = substr(trim($file_path_with_scheme),7);
|
||||
if($handle = @fopen($file_path, "rb")){
|
||||
$attribute_value = @fread($handle,filesize($file_path));
|
||||
@fclose($handle);
|
||||
}
|
||||
else{
|
||||
$error=1;
|
||||
$error_message = "Line: ".$attr_line_number. " - Unable to open file ".
|
||||
$file_path_with_scheme;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$error=1;
|
||||
$error_message = "Line: ".$attr_line_number. " - the URL seems no to be well formed ";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//it's a string
|
||||
else{
|
||||
$attribute_value = trim($attribute_value_part);
|
||||
}
|
||||
|
||||
$attrs[$attribute_name][] = $attribute_value;
|
||||
//debug
|
||||
// echo $attr_line_number."- ".$attribute_name.":".$attribute_value."\r\n<br>";
|
||||
|
||||
}
|
||||
// the attribute line contains the charachter ":" or there is
|
||||
// at least a white space at the begining
|
||||
else{
|
||||
$error_message = "Line ". $line_number. " - Attribute not well formed";
|
||||
$error=1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
|
119
ldif_import.php
Normal file
119
ldif_import.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ldif_import.php
|
||||
* Imports an LDIF file to the specified server_id.
|
||||
*
|
||||
* Variables that come in as POST vars:
|
||||
* - ldif_file (as an uploaded file)
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'common.php';
|
||||
|
||||
$debug = true;
|
||||
|
||||
$server_id = $_POST['server_id'];
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
$file = $_FILES['ldif_file']['tmp_name'];
|
||||
$remote_file = $_FILES['ldif_file']['name'];
|
||||
$file_len = $_FILES['ldif_file']['size'];
|
||||
|
||||
is_array( $_FILES['ldif_file'] ) or pla_error( "Missing uploaded file." );
|
||||
file_exists( $file ) or pla_error( "No LDIF file specified. Please try again." );
|
||||
$file_len > 0 or pla_error( "Uploaded file is empty." );
|
||||
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." );
|
||||
|
||||
include 'header.php'; ?>
|
||||
|
||||
<body>
|
||||
|
||||
<h3 class="title">Import LDIF File</h3>
|
||||
<h3 class="subtitle">
|
||||
Server: <b><?php echo htmlspecialchars( $server_name ); ?></b>
|
||||
File: <b><?php echo htmlspecialchars( $remote_file ); ?>
|
||||
(<?php echo number_format( $file_len ); ?> bytes)</b>
|
||||
</h3>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<center><i>This is an experimental and untested feature. Proceed at your own risk.</i><br />
|
||||
<i>The add and delete operations are the only operations currently supported.</i>
|
||||
</center>
|
||||
<br />
|
||||
|
||||
<?php
|
||||
include("ldif_functions.php");
|
||||
@set_time_limit( 0 );
|
||||
ldif_open_file($file);
|
||||
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
|
||||
if(!ldif_check_version()){
|
||||
display_warning(ldif_warning_message());
|
||||
}
|
||||
while($dn_entry= ldif_fetch_dn_entry() ){
|
||||
$action = ldif_get_action();
|
||||
if($action=="add"){
|
||||
echo "Adding dn:".utf8_decode($dn_entry) ."... ";
|
||||
flush();
|
||||
if($attributes = ldif_fetch_attributes_for_entry()){
|
||||
if(@ldap_add($ds,$dn_entry,$attributes)){
|
||||
echo "<span style=\"color:green;\">Success</span><br>";
|
||||
}
|
||||
else{
|
||||
echo "<span style=\"color:red;\">failed</span><br><br>";
|
||||
pla_error( "Could not add object: " . htmlspecialchars( utf8_decode( $dn ) ), ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo "<span style=\"color:red;\">failed</span><br><br>";
|
||||
echo "<div style=\"color:red\">".display_error_message(ldif_error_message())."</div>";
|
||||
flush();
|
||||
}
|
||||
}
|
||||
elseif($action=="delete"){
|
||||
echo "Deleting dn: ".$dn_entry." ";
|
||||
if(@ldap_delete($ds,$dn_entry)){
|
||||
echo "<span style=\"color:green;\">Success</span><br>";
|
||||
flush();
|
||||
}
|
||||
else{
|
||||
echo "<span style=\"color:red;\">Failed</span><br><br>";
|
||||
flush();
|
||||
pla_error( "Could not delete object: " . htmlspecialchars( utf8_decode( $dn ) ), ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
reload_left_frame();
|
||||
|
||||
|
||||
function reload_left_frame(){
|
||||
global $server_id;
|
||||
|
||||
echo "<script>\r\n";
|
||||
echo "parent.left_frame.document.location='refresh.php?server_id=".$server_id."';\r\n";
|
||||
echo "</script>\r\n";
|
||||
}
|
||||
|
||||
function display_error_message($error_message){
|
||||
echo "<div style=\"color:red;\">".$error_message."</div>";
|
||||
}
|
||||
function display_warning($warning){
|
||||
echo "<div style=\"color:orange\">".$warning."</div>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
48
ldif_import_form.php
Normal file
48
ldif_import_form.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ldif_import_form.php
|
||||
* Displays a form to allow the user to upload and import
|
||||
* an LDIF file.
|
||||
*
|
||||
* Variables expected as GET vars:
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_GET['server_id'];
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
|
||||
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." );
|
||||
|
||||
include 'header.php'; ?>
|
||||
|
||||
<body>
|
||||
|
||||
<h3 class="title">Import LDIF File</h3>
|
||||
<h3 class="subtitle">Server: <b><?php echo htmlspecialchars( $server_name ); ?></b></h3>
|
||||
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<center><i>This is an experimental and untested feature. Proceed at your own risk.</i>
|
||||
<br />
|
||||
<i>The add operation is the only operation currently supported.</i>
|
||||
</center>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
Select an LDIF file:<br />
|
||||
<br />
|
||||
|
||||
<form action="ldif_import.php" method="post" class="new_value" enctype="multipart/form-data">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="file" name="ldif_file" /><br />
|
||||
<br />
|
||||
<input type="submit" value="Proceed >>" />
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
28
login.php
28
login.php
@ -15,12 +15,12 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_POST['server_id'];
|
||||
$dn = stripslashes( $_POST['login_dn'] );
|
||||
$pass = stripslashes( $_POST['login_pass'] );
|
||||
$dn = $_POST['login_dn'];
|
||||
$uid = $_POST['uid'];
|
||||
$pass = $_POST['login_pass'];
|
||||
$redirect = rawurldecode( $_POST['redirect'] );
|
||||
$anon_bind = $_POST['anonymous_bind'] == 'on' ? true : false;
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
@ -37,6 +37,22 @@ if( $anon_bind ) {
|
||||
$host = $servers[$server_id]['host'];
|
||||
$port = $servers[$server_id]['port'];
|
||||
|
||||
if ( isset( $servers[$server_id]['login_attr'] ) &&
|
||||
$servers[$server_id]['login_attr'] != "dn" &&
|
||||
$servers[$server_id]['login_attr'] != "") {
|
||||
|
||||
// search for the "uid" first
|
||||
$ds = ldap_connect ( $host, $port );
|
||||
$ds or pla_error( "Could not contact '" . htmlspecialchars( $host ) . "' on port '" . htmlentities( $port ) . "'" );
|
||||
@ldap_bind ($ds) or pla_error( "Could not bind anonymously to server. " .
|
||||
"Unless your server accepts anonymous binds, " .
|
||||
"the login_attr feature will not work properly.");
|
||||
$sr=@ldap_search($ds,$servers[$server_id]['base'],$servers[$server_id]['login_attr'] ."=". $uid, array("dn"), 0, 1);
|
||||
$result = @ldap_get_entries($ds,$sr);
|
||||
$dn = $result[0]["dn"];
|
||||
@ldap_unbind ($ds);
|
||||
}
|
||||
|
||||
// verify that the login is good
|
||||
$ds = @ldap_connect( $host, $port );
|
||||
$ds or pla_error( "Could not connect to '" . htmlspecialchars( $host ) . "' on port '" . htmlentities( $port ) . "'" );
|
||||
@ -49,7 +65,9 @@ $bind_result = @ldap_bind( $ds, $dn, $pass );
|
||||
if( ! $bind_result )
|
||||
pla_error( "Bad username/password. Try again" );
|
||||
|
||||
$expire = $cookie_time==0 ? null : time()+$cookie_time;
|
||||
if( ! isset( $cookie_time ) )
|
||||
$cookie_time = 0;
|
||||
$expire = $cookie_time == 0 ? null : time()+$cookie_time;
|
||||
if( $anon_bind ) {
|
||||
// we set the cookie val to 0 for anonymous binds.
|
||||
$res1 = setcookie( "pla_login_dn_$server_id", '0', $expire, dirname( $_SERVER['PHP_SELF'] ) );
|
||||
|
@ -9,8 +9,7 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_GET['server_id'];
|
||||
$server = $servers[$server_id];
|
||||
@ -43,9 +42,9 @@ check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars
|
||||
|
||||
<?php if( $_SERVER['SERVER_PORT'] != 443 ) { ?>
|
||||
|
||||
<span style="color:red">Warning: this is an insecure (non-SSL) connection!<br />
|
||||
SSL is recommended when transmitting sensitive passwords.</span>
|
||||
<br />
|
||||
<center>
|
||||
<span style="color:red">Warning: This web connection is <acronym title="Your login and password will be transmitted in clear text">unencrypted</acronym> (not https).<br />
|
||||
</span>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
@ -64,8 +63,12 @@ check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars
|
||||
<td colspan="2"><small>Anonymous Bind</small> <input type="checkbox" name="anonymous_bind" onclick="toggle_disable_login_fields(this)" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!--
|
||||
<td><small>Login <acronym title="Distinguished Name">DN</acronym></small></td>
|
||||
<td><input type="text" name="login_dn" size="40" value="<?php echo $servers[$server_id]['login_dn']; ?>" name="login_dn" /></td>
|
||||
-->
|
||||
<td><small>Login <?php if ( $servers[$server_id]['login_attr'] == "dn" || $servers[$server_id]['login_attr'] == "") { echo '<acronym title="Distinguished Name">DN</acronym>';} ?></small></td>
|
||||
<td><input type="text" name="<?php if ( $servers[$server_id]['login_attr'] == "dn" || $servers[$server_id]['login_attr'] == "" ) {echo 'login_dn';} else {echo 'uid';} ?>" size="40" value="<?php echo $servers[$server_id]['login_dn']; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><small>Password</small></td>
|
||||
|
@ -9,8 +9,7 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_GET['server_id'];
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
|
43
new_attr.php
43
new_attr.php
@ -9,33 +9,52 @@
|
||||
* - server_id
|
||||
* - attr
|
||||
* - val
|
||||
* - binary
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$dn = rawurldecode( $_POST['dn'] );
|
||||
$server_id = $_POST['server_id'];
|
||||
$attr = stripslashes( $_POST['attr'] );
|
||||
$val = stripslashes( $_POST['val'] );
|
||||
$attr = $_POST['attr'];
|
||||
$val = $_POST['val'];
|
||||
$val = utf8_encode( $val );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$encoded_attr = rawurlencode( $attr );
|
||||
$is_binary_val = isset( $_POST['binary'] ) ? true : false;
|
||||
|
||||
if( ! $is_binary_val && $val == "" ) {
|
||||
pla_error( "You left the attribute value blank. Please go back and try again." );
|
||||
}
|
||||
|
||||
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." );
|
||||
|
||||
// special case for jpegPhoto attributes:
|
||||
// we must go read the data from the file.
|
||||
if( 0 == strcasecmp( $attr, 'jpegPhoto' ) )
|
||||
{
|
||||
$file = $_FILES['jpeg_photo_file']['tmp_name'];
|
||||
// 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
|
||||
if( $is_binary_val ) {
|
||||
$file = $_FILES['val']['tmp_name'];
|
||||
$f = fopen( $file, 'r' );
|
||||
$jpeg_data = fread( $f, filesize( $file ) );
|
||||
$binary_data = fread( $f, filesize( $file ) );
|
||||
fclose( $f );
|
||||
$val = $jpeg_data;
|
||||
$val = $binary_data;
|
||||
}
|
||||
|
||||
// Automagically hash new userPassword attributes according to the
|
||||
// chosen in config.php.
|
||||
if( 0 == strcasecmp( $attr, 'userpassword' ) )
|
||||
{
|
||||
if( $servers[$server_id]['default_hash'] != '' ) {
|
||||
$enc_type = $servers[$server_id]['default_hash'];
|
||||
$new_val = password_hash( $new_val, $enc_type );
|
||||
$val = $new_val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
|
||||
$new_entry = array( $attr => $val );
|
||||
$result = @ldap_mod_add( $ds, $dn, $new_entry );
|
||||
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* new_jpeg_photo_form.php
|
||||
* Displays a form to allow the user to a jpegPhoto to an object.
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_GET['dn'] ) );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = $rdn[0];
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
|
||||
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." );
|
||||
|
||||
include 'header.php'; ?>
|
||||
|
||||
<body>
|
||||
|
||||
<h3 class="title">Add a <b>jpegPhoto</b> to <b><?php echo htmlspecialchars($rdn); ?></b></h3>
|
||||
<h3 class="subtitle">Server2: <b><?php echo $server_name; ?></b> Distinguished Name: <b><?php echo $dn; ?>
|
||||
</b></h3>
|
||||
|
||||
|
||||
Select a jpeg file:<br />
|
||||
<br />
|
||||
|
||||
<form action="new_attr.php" method="post" class="new_value" 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="jpegPhoto" />
|
||||
<input type="file" name="jpeg_photo_file" /><br />
|
||||
<br />
|
||||
<input type="submit" value="Proceed >>" />
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
14
rdelete.php
14
rdelete.php
@ -9,16 +9,18 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$encoded_dn = $_POST['dn'];
|
||||
$dn = stripslashes( rawurldecode( $encoded_dn ) );
|
||||
$dn = rawurldecode( $encoded_dn );
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
if( ! $dn )
|
||||
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." );
|
||||
pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
|
||||
@ -66,7 +68,7 @@ if( $del_result )
|
||||
parent.left_frame.location.reload();
|
||||
</script>
|
||||
|
||||
Object <b><?php echo htmlspecialchars( utf8_decode( $dn ) ); ?></b> and sub-tree deleted successfully.
|
||||
Object <b><?php echo htmlspecialchars( $dn ); ?></b> and sub-tree deleted successfully.
|
||||
|
||||
<?php
|
||||
|
||||
@ -86,7 +88,7 @@ function pla_rdelete( $server_id, $dn )
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! is_array( $children ) || count( $children ) == 0 ) {
|
||||
echo "<nobr>Deleting " . htmlspecialchars( utf8_decode( $dn ) ) . "...";
|
||||
echo "<nobr>Deleting " . htmlspecialchars( $dn ) . "...";
|
||||
flush();
|
||||
if( ldap_delete( $ds, $dn ) ) {
|
||||
echo " <span style=\"color:green\">Success</span></nobr><br />\n";
|
||||
@ -99,7 +101,7 @@ function pla_rdelete( $server_id, $dn )
|
||||
foreach( $children as $child_dn ) {
|
||||
pla_rdelete( $server_id, $child_dn );
|
||||
}
|
||||
echo "<nobr>Deleting " . htmlspecialchars( utf8_decode( $dn ) ) . "...";
|
||||
echo "<nobr>Deleting " . htmlspecialchars( $dn ) . "...";
|
||||
flush();
|
||||
if( ldap_delete( $ds, $dn ) ) {
|
||||
echo " <span style=\"color:green\">Success</span></nobr><br />\n";
|
||||
|
@ -9,8 +9,7 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_GET['server_id'];
|
||||
|
||||
|
15
rename.php
15
rename.php
@ -10,21 +10,26 @@
|
||||
* - new_rdn
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = rawurldecode( stripslashes( $_POST['dn'] ) );
|
||||
$dn = rawurldecode( $_POST['dn'] );
|
||||
$server_id = $_POST['server_id'];
|
||||
$new_rdn = stripslashes( $_POST['new_rdn'] );
|
||||
$new_rdn = $_POST['new_rdn'];
|
||||
$new_rdn = utf8_encode($new_rdn);
|
||||
|
||||
if( is_server_read_only( $server_id ) )
|
||||
pla_error( "You cannot perform updates while server is in read-only mode" );
|
||||
|
||||
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 sever" );
|
||||
|
||||
// build the container string
|
||||
$old_rdn = ldap_explode_dn( $dn, 0 );
|
||||
$old_rdn = pla_explode_dn( $dn );
|
||||
$container = $old_rdn[ 1 ];
|
||||
for( $i=2; $i<count($old_rdn)-1; $i++ )
|
||||
$container .= ',' . $old_rdn[$i];
|
||||
|
450
schema.php
450
schema.php
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* schema.php
|
||||
@ -10,8 +10,7 @@
|
||||
* - attr (optional)
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_GET['server_id'];
|
||||
$view = isset( $_GET['view'] ) ? $_GET['view'] : 'objectClasses';
|
||||
@ -23,203 +22,310 @@ have_auth_info( $server_id ) or
|
||||
pla_ldap_connect( $server_id ) or
|
||||
pla_error( "Coult not connect to LDAP server." );
|
||||
|
||||
$schema = get_schema( $server_id );
|
||||
|
||||
include 'header.php';
|
||||
|
||||
$schema_error_str = "Could not retrieve schema from <b>" . htmlspecialchars($servers[$server_id]['name']) . "</b>.<br />
|
||||
<br />
|
||||
</center>
|
||||
This could happen for several reasons, the most probable of which are:
|
||||
<ul>
|
||||
<li>The server does not fully support the LDAP protocol.</li>
|
||||
<li>Your version of PHP does not correctly perform the query.</li>
|
||||
<li>Or lastly, phpLDAPadmin doesn't know how to fetch the schema for your server.</li>
|
||||
</ul>
|
||||
Please <a href=\"https://sourceforge.net/tracker/?func=add&group_id=61828&atid=498546\" target=\"new\">
|
||||
report this as a bug</a>";
|
||||
|
||||
?>
|
||||
|
||||
<body>
|
||||
|
||||
<?php if( ! $schema ) {
|
||||
<h3 class="title"><?php echo $lang['schema_for_server']; ?>
|
||||
<b><?php echo htmlspecialchars($servers[$server_id]['name']); ?></b></h3>
|
||||
|
||||
pla_error( "Could not retrieve schema from <b>" . htmlspecialchars($servers[$server_id]['name']) . "</b>.<br />
|
||||
<br />
|
||||
This could happen for several reasons, the most probable of which are:
|
||||
<ul>
|
||||
<li>The server does not fully support the LDAP protocol.</li>
|
||||
<li>Your version of PHP does not correctly perform the query.</li>
|
||||
<li>Or lastly, phpLDAPAdmin doesn't know how to fetch the schema for your server.</li>
|
||||
</ul>
|
||||
Please <a href=\"http://sourceforge.net/tracker/?func=add&group_id=80217&atid=559082\">report this</a>
|
||||
as a bug.
|
||||
" );
|
||||
<br />
|
||||
<center>
|
||||
<?php echo ( $view=='objectClasses' ?
|
||||
'objectClasses' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=objectClasses">objectClasses</a>' ); ?>
|
||||
|
|
||||
<?php echo ( $view=='attributes' ?
|
||||
'Attributes' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=attributes">Attributes</a>' ); ?>
|
||||
|
|
||||
<?php echo ( $view=='syntaxes' ?
|
||||
'Syntaxes' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=syntaxes">Syntaxes</a>' ); ?>
|
||||
|
|
||||
<?php echo ( $view=='matching_rules' ?
|
||||
'Matching Rules' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=matching_rules">Matching Rules</a>' ); ?>
|
||||
</center>
|
||||
<br />
|
||||
|
||||
} else { ?>
|
||||
<?php flush(); ?>
|
||||
|
||||
<h3 class="title">Schema for server <b><?php echo htmlspecialchars($servers[$server_id]['name']); ?></b></h3>
|
||||
<?php
|
||||
|
||||
<br />
|
||||
<center>
|
||||
<?php echo ( $view=='objectClasses' ?
|
||||
'objectClasses' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=objectClasses">objectClasses</a>' ); ?>
|
||||
|
|
||||
<?php echo ( $view=='syntaxes' ?
|
||||
'Syntaxes' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=syntaxes">Syntaxes</a>' ); ?>
|
||||
|
|
||||
<?php echo ( $view=='attributes' ?
|
||||
'Attributes' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=attributes">Attributes</a>' ); ?>
|
||||
|
|
||||
<?php echo ( $view=='matching_rules' ?
|
||||
'Matching Rules' :
|
||||
'<a href="schema.php?server_id=' . $server_id . '&view=matching_rules">Matching Rules</a>' ); ?>
|
||||
</center>
|
||||
<br />
|
||||
if( $view == 'syntaxes' ) {
|
||||
$highlight_oid = isset( $_GET['highlight_oid'] ) ? $_GET['highlight_oid'] : false;
|
||||
echo "<center>" . $lang['the_following_syntaxes'] . "</center><br />\n\n";
|
||||
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n";
|
||||
echo "<tr><th>" . $lang['syntax_oid'] . "</th><th>" . $lang['desc'] . "</th></tr>\n";
|
||||
flush();
|
||||
$counter=1;
|
||||
$schema_syntaxes = get_schema_syntaxes( $server_id );
|
||||
if( ! $schema_syntaxes ) pla_error( $schema_error_str );
|
||||
foreach( $schema_syntaxes as $oid => $desc ) {
|
||||
$counter++;
|
||||
$oid = htmlspecialchars( $oid );
|
||||
$desc = htmlspecialchars( $desc['description'] );
|
||||
if( $highlight_oid && $highlight_oid == $oid )
|
||||
echo "<tr class=\"highlight\">";
|
||||
else
|
||||
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\">";
|
||||
echo "<td><a name=\"$oid\">$oid</a></td><td>$desc</td></tr>\n\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
<?php flush(); ?>
|
||||
} elseif( $view == 'attributes' ) {
|
||||
echo "<center>" . $lang['the_following_attributes'] . "</center><br />\n";
|
||||
flush();
|
||||
$schema_attrs = get_schema_attributes( $server_id );
|
||||
$schema_object_classes = get_schema_objectclasses( $server_id );
|
||||
if( ! $schema_attrs || ! $schema_object_classes )
|
||||
pla_error( $schema_error_str );
|
||||
|
||||
// do a reverse-mapping to add in which objectClasses each attributeType is used
|
||||
foreach( $schema_object_classes as $object_class ) {
|
||||
if( isset( $object_class['must_attrs'] ) && is_array( $object_class['must_attrs'] ) )
|
||||
$must_attrs = $object_class['must_attrs'];
|
||||
else
|
||||
$must_attrs = array();
|
||||
if( isset( $object_class['may_attrs'] ) && is_array( $object_class['may_attrs'] ) )
|
||||
$may_attrs = $object_class['may_attrs'];
|
||||
else
|
||||
$may_attrs = array();
|
||||
$attrs = array_unique( array_merge( $must_attrs, $may_attrs ) );
|
||||
foreach( $attrs as $attr_name )
|
||||
if( isset( $schema_attrs[ strtolower( $attr_name ) ] ) )
|
||||
$schema_attrs[ strtolower( $attr_name ) ]->addUsedInObjectClass( $object_class['name'] );
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
if( $view == 'attr' )
|
||||
{
|
||||
$attr = $_GET['attr'];
|
||||
if( ! isset( $_GET['attr'] ) )
|
||||
pla_error( "No attribute specified in the query string." );
|
||||
//echo "<pre>";
|
||||
//print_r( $schema_attrs );
|
||||
//echo "</pre>";
|
||||
|
||||
//echo '<pre>'; print_r( $schema['attrs'] );
|
||||
?>
|
||||
?>
|
||||
<small><?php echo $lang['jump_to_attr']; ?>:</small>
|
||||
<select name="oclass_jumper"
|
||||
onChange="window.location.href='schema.php?server_id=<?php echo $server_id; ?>&view=attributes#'+this.value">
|
||||
|
||||
<center>
|
||||
Attribute definition for <b><?php echo htmlspecialchars( $attr ); ?></b><br /><br />
|
||||
<table class="schema_attr">
|
||||
<?php foreach( $schema_attrs as $attr ) { ?>
|
||||
<option value="<?php echo strtolower( $attr->getName() ); ?>"><?php echo $attr->getName(); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
<?php
|
||||
if( is_array( $schema['attrs'][strtolower($attr)] ) )
|
||||
{
|
||||
$counter = 0;
|
||||
foreach( $schema['attrs'][strtolower($attr)] as $key => $val )
|
||||
{
|
||||
if( $key != 'val' && $val != null ) {
|
||||
$counter++;
|
||||
echo "<tr class=\"" . ($counter%2==0 ? 'even' : 'odd') . "\"><td>$key</td><td>$val</td></tr>\n";
|
||||
}
|
||||
}
|
||||
<br />
|
||||
<table class="schema_attr" width="100%">
|
||||
<?php foreach( $schema_attrs as $attr ) {
|
||||
echo "<tr><th colspan=\"2\"><a name=\"" . strtolower( $attr->getName() ) . "\">";
|
||||
echo $attr->getName() . "</a></th></tr>\n\n";
|
||||
$counter = 0;
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Description</td>\n";
|
||||
echo "<td>" . ( $attr->getDescription() == null ? '(no description)' : $attr->getDescription() ). "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td><acronym title=\"Object Identier\">OID</acronym></td>\n";
|
||||
echo "<td>" . $attr->getOID() . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Obsolete?</td>\n";
|
||||
echo "<td>" . ( $attr->getIsObsolete() ? '<b>Yes</b>' : 'No' ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Inherits</td>\n";
|
||||
echo "<td>" . ( $attr->getSupAttribute()==null? '(none)' : $attr->getSupAttribute() ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Equality</td>\n";
|
||||
echo "<td>" . ( $attr->getEquality() == null ? '(not specified)' : $attr->getEquality() ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Ordering</td>\n";
|
||||
echo "<td>" . ( $attr->getOrdering()==null? '(not specified)' : $attr->getOrdering() ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Substring Rule</td>\n";
|
||||
echo "<td>" . ( $attr->getSubstr()==null? '(not specified)' : $attr->getSubstr() ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Syntax</td>\n";
|
||||
echo "<td>";
|
||||
if( null != $attr->getType() ) {
|
||||
echo "<a href=\"schema.php?server_id=$server_id&view=syntaxes&highlight_oid=";
|
||||
echo $attr->getSyntaxOID() . "#" . $attr->getSyntaxOID();
|
||||
echo "\">" . $attr->getType() . " (" . $attr->getSyntaxOID() . ")</a>";
|
||||
} else {
|
||||
echo $attr->getSyntaxOID();
|
||||
}
|
||||
else
|
||||
pla_error( "Bad schema entry for attribute: " . htmlspecialchars( $attr ) );
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
?>
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Single Valued</td>\n";
|
||||
echo "<td>" . ( $attr->getIsSingleValue() ? 'Yes' : 'No' ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Collective?</td>\n";
|
||||
echo "<td>" . ( $attr->getIsCollective() ? 'Yes' : 'No' ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
} elseif( $view == 'syntaxes' ) {
|
||||
echo "<center>The following <b>syntaxes</b> are supported by this LDAP server</center><br />\n\n";
|
||||
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n";
|
||||
echo "<tr><th>Syntax OID</th><th>Description</th></tr>\n";
|
||||
$counter=1;
|
||||
foreach( get_schema_syntaxes( $server_id ) as $oid => $desc ) {
|
||||
$counter++;
|
||||
$oid = htmlspecialchars( $oid );
|
||||
$desc = htmlspecialchars( $desc['description'] );
|
||||
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\"><td>$oid</td><td>$desc</td></tr>\n";
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>User Modification</td>\n";
|
||||
echo "<td>" . ( $attr->getIsNoUserModification() ? 'No' : 'Yes' ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Usage</td>\n";
|
||||
echo "<td>" . ( $attr->getUsage() ? $attr->getUsage() : '(not specified)' ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Maximum Length</td>\n";
|
||||
echo "<td>" . ( $attr->getMaxLength() === null ?
|
||||
'(not applicable)' :
|
||||
number_format( $attr->getMaxLength() ) . ' characters' ) . "</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Aliases</td>\n";
|
||||
echo "<td>";
|
||||
if( count( $attr->getAliases() ) == 0 )
|
||||
echo "(none)";
|
||||
else
|
||||
foreach( $attr->getAliases() as $alias_attr_name )
|
||||
echo "<a href=\"#" . strtolower($alias_attr_name) . "\">$alias_attr_name</a> ";
|
||||
echo "</td>";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
|
||||
echo "<td>Used by objectClasses</td>\n";
|
||||
echo "<td>";
|
||||
if( count( $attr->getUsedInObjectClasses() ) == 0 )
|
||||
echo "(none)";
|
||||
else
|
||||
foreach( $attr->getUsedInObjectClasses() as $used_in_oclass)
|
||||
echo "<a href=\"schema.php?server_id=$server_id&view=objectClasses#" .
|
||||
strtolower($used_in_oclass) . "\">$used_in_oclass</a> ";
|
||||
echo "</td>";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
flush();
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
} elseif( $view == 'matching_rules' ) {
|
||||
echo "<center>" . $lang['the_following_matching'] . "</center><br />\n\n";
|
||||
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n";
|
||||
echo "<tr><th>" . $lang['matching_rule_oid'] . "</th><th>" . $lang['desc'] . "</th></tr>\n";
|
||||
flush();
|
||||
$counter=1;
|
||||
$schema_matching_rules = get_schema_matching_rules( $server_id );
|
||||
if( ! $schema_matching_rules ) pla_error( $schema_error_str );
|
||||
foreach( $schema_matching_rules as $oid => $attr ) {
|
||||
$counter++;
|
||||
$oid = htmlspecialchars( $oid );
|
||||
$desc = htmlspecialchars( $attr );
|
||||
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\"><td>$oid</td><td>$attr</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
} else {
|
||||
echo "<center>" . $lang['the_following_objectclasses'] . "</center><br />\n";
|
||||
flush();
|
||||
$schema_oclasses = get_schema_objectclasses( $server_id );
|
||||
if( ! $schema_oclasses ) pla_error( $schema_error_str );
|
||||
?>
|
||||
<small><?php echo $lang['jump_to_objectclass']; ?>:</small>
|
||||
<select name="oclass_jumper"
|
||||
onChange="window.location.href='schema.php?server_id=<?php echo $server_id; ?>#'+this.value">
|
||||
<?php foreach( $schema_oclasses as $oclass => $desc ) { ?>
|
||||
<option value="<?php echo $oclass; ?>"><?php echo $desc['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<br />
|
||||
<?php foreach( $schema_oclasses as $oclass => $attrs ) { ?>
|
||||
<!--<small>[<a name="<?php echo $oclass; ?>" href="#" title="Head on up to the top.">top</a>]</small>-->
|
||||
<h4 class="oclass"><a name="<?php echo $oclass; ?>"><?php echo $attrs['name']; ?></a></h4>
|
||||
<h4 class="oclass_sub"><?php echo $lang['OID']; ?>: <b><?php echo $attrs['oid']; ?></b></h4>
|
||||
<?php if( $attrs['description'] ) { ?>
|
||||
<h4 class="oclass_sub"><?php echo $lang['desc']; ?>: <b><?php echo $attrs['description']; ?></b></h4>
|
||||
<?php } ?>
|
||||
<h4 class="oclass_sub">Type: <b><?php echo $attrs['type']; ?></b></h4>
|
||||
<?php if( isset( $attrs['is_obsolete'] ) && $attrs['is_obsolete'] == true ) { ?>
|
||||
<h4 class="oclass_sub"><?php echo $lang['is_obsolete']; ?></h4>
|
||||
<?php } ?>
|
||||
|
||||
<h4 class="oclass_sub"><?php echo $lang['inherits']; ?>: <b><?php
|
||||
if( count( $attrs['sup'] ) == 0 )
|
||||
echo "(" . $lang['none'] . ")";
|
||||
else
|
||||
foreach( $attrs['sup'] as $i => $object_class ) {
|
||||
echo '<a title="' . $lang['jump_to_this_oclass'] . ' "
|
||||
href="#' . strtolower( htmlspecialchars( $object_class ) );
|
||||
echo '">' . htmlspecialchars( $object_class ) . '</a>';
|
||||
if( $i < count( $attrs['sup'] ) - 1 )
|
||||
echo ', ';
|
||||
}
|
||||
echo "</table>\n";
|
||||
?></b></h4>
|
||||
|
||||
} elseif( $view == 'attributes' ) {
|
||||
echo "<center>The following <b>attributes</b> are supported by this LDAP server</center><br />\n\n";
|
||||
echo "<table class=\"schema_attr\" width=\"100%\">\n";
|
||||
foreach( get_schema_attributes( $server_id ) as $attr ) {
|
||||
echo "<tr><th colspan=\"2\">" . $attr['name'] . "</th></tr>\n";
|
||||
$counter = 0;
|
||||
foreach( $attr as $key => $val )
|
||||
{
|
||||
if( $key != 'val' && $val != null ) {
|
||||
$counter++;
|
||||
echo "<tr class=\"" . ($counter%2==0 ? 'even' : 'odd') . "\">";
|
||||
echo "<td>$key</td><td>$val</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>\n";
|
||||
} elseif( $view == 'matching_rules' ) {
|
||||
echo "<center>The following <b>matching rules</b> are supported by this LDAP server</center><br />\n\n";
|
||||
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n";
|
||||
echo "<tr><th>Matching Rule OID</th><th>Description</th></tr>\n";
|
||||
$counter=1;
|
||||
foreach( get_schema_matching_rules( $server_id ) as $oid => $attr ) {
|
||||
$counter++;
|
||||
$oid = htmlspecialchars( $oid );
|
||||
$desc = htmlspecialchars( $attr );
|
||||
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\"><td>$oid</td><td>$attr</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
|
||||
|
||||
} else { ?>
|
||||
|
||||
<small>Jump to an objectClass:</small>
|
||||
<select name="oclass_jumper"
|
||||
onChange="window.location.href='schema.php?server_id=<?php echo $server_id; ?>#'+this.value">
|
||||
|
||||
<?php foreach( $schema['oclasses'] as $oclass => $desc ) { ?>
|
||||
<option value="<?php echo $oclass; ?>"><?php echo $desc['name']; ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
<br />
|
||||
|
||||
<?php foreach( $schema['oclasses'] as $oclass => $attrs ) { ?>
|
||||
|
||||
<small>[<a name="<?php echo $oclass; ?>" href="#" title="Head on up to the top.">top</a>]</small>
|
||||
<h4 class="oclass">objectClass <b><?php echo $attrs['name']; ?></b></h4>
|
||||
<h4 class="oclass_sub">OID <b><?php echo $attrs['oid']; ?></b></h4>
|
||||
<?php if( $attrs['description'] ) { ?>
|
||||
<h4 class="oclass_sub">Description <b><?php echo $attrs['description']; ?></b></h4>
|
||||
<?php } ?>
|
||||
<h4 class="oclass_sub">Inherits <b><?php echo $attrs['sup']; ?></b></h4>
|
||||
<br />
|
||||
<table width="100%" class="schema_oclasses">
|
||||
<tr>
|
||||
<th width="50%"><b>Required Attributes</b></th>
|
||||
<th width="50%"><b>Optional Attributes</b></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<table width="100%" class="schema_oclasses">
|
||||
<tr>
|
||||
<th width="50%"><b><?php echo $lang['required_attrs']; ?></b></th>
|
||||
<th width="50%"><b><?php echo $lang['optional_attrs']; ?></b></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
if( count( $attrs['must_attrs'] ) > 0 ) {
|
||||
<?php if( count( $attrs['must_attrs'] ) > 0 ) {
|
||||
echo '<ul class="schema">';
|
||||
foreach( $attrs['must_attrs'] as $attr )
|
||||
echo "<li><a href=\"schema.php?server_id=$server_id&view=attr&attr=" .
|
||||
rawurlencode( $attr ) . "\">" . htmlspecialchars($attr) . "</a></li>\n";
|
||||
}
|
||||
else
|
||||
echo "<center>(none)</center>\n";
|
||||
|
||||
echo "<li><a href=\"schema.php?server_id=$server_id&view=attributes#" .
|
||||
strtolower( rawurlencode( $attr ) ). "\">" . htmlspecialchars($attr) . "</a></li>\n";
|
||||
} else
|
||||
echo "<center>(" . $lang['none'] . ")</center>\n";
|
||||
?>
|
||||
</ul>
|
||||
</td>
|
||||
<td width="50%">
|
||||
<?php
|
||||
if( count( $attrs['may_attrs'] ) > 0 ) {
|
||||
echo '<ul class="schema">';
|
||||
foreach( $attrs['may_attrs'] as $attr )
|
||||
echo "<li><a href=\"schema.php?server_id=$server_id&view=attributes#" .
|
||||
strtolower( rawurlencode( $attr ) ) . "\">" . htmlspecialchars($attr) . "</a></li>\n";
|
||||
}
|
||||
else
|
||||
echo "<center>(" . $lang['none'] . ")</center>\n";
|
||||
?>
|
||||
|
||||
</ul>
|
||||
</td>
|
||||
<td width="50%">
|
||||
<?php
|
||||
|
||||
if( count( $attrs['may_attrs'] ) > 0 ) {
|
||||
echo '<ul class="schema">';
|
||||
foreach( $attrs['may_attrs'] as $attr )
|
||||
echo "<li><a href=\"schema.php?server_id=$server_id&view=attr&attr=" .
|
||||
rawurlencode( $attr ) . "\">" . htmlspecialchars($attr) . "</a></li>\n";
|
||||
}
|
||||
else
|
||||
echo "<center>(none)</center>\n";
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
?>
|
||||
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php } /* End foreach objectClass */ ?>
|
||||
<?php } /* End else (displaying objectClasses */ ?>
|
||||
<?php } /* End else (schema _is_ available) */ ?>
|
||||
<?php } /* End foreach objectClass */ ?>
|
||||
<?php } /* End else (displaying objectClasses */ ?>
|
||||
|
||||
</body>
|
||||
|
||||
|
910
schema_functions.php
Normal file
910
schema_functions.php
Normal file
@ -0,0 +1,910 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Represents an LDAP objectClass
|
||||
*/
|
||||
class ObjectClass
|
||||
{
|
||||
/* This objectClass' OID, ie "2.16.840.1.113730.3.2.2" */
|
||||
var $oid;
|
||||
/* This objectClass' name, ie "inetOrgPerson" */
|
||||
var $name;
|
||||
/* This objectClass' description */
|
||||
var $description;
|
||||
/* array of objectClass names from which this objectClass inherits */
|
||||
var $sup_classes;
|
||||
/* one of STRUCTURAL, ABSTRACT, or AUXILIARY */
|
||||
var $type;
|
||||
/* arrays of attribute names that this objectClass requires */
|
||||
var $must_attrs;
|
||||
/* arrays of attribute names that this objectClass allows, but does not require */
|
||||
var $may_attrs;
|
||||
/* boolean value indicating whether this objectClass is obsolete */
|
||||
var $is_obsolete;
|
||||
|
||||
/* Initialize the class' member variables */
|
||||
function initVars()
|
||||
{
|
||||
$this->oid = null;
|
||||
$this->name = null;
|
||||
$this->description = null;
|
||||
$this->sup_classes = array();
|
||||
$this->type = null;
|
||||
$this->must_attrs = array();
|
||||
$this->may_attrs = array();
|
||||
$this->is_obsolete = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses a raw LDAP objectClass string into this object's $this vars
|
||||
*/
|
||||
function ObjectClass( $raw_ldap_schema_string )
|
||||
{
|
||||
$this->initVars();
|
||||
$class = $raw_ldap_schema_string;
|
||||
$strings = preg_split ("/[\s,]+/", $class, -1,PREG_SPLIT_DELIM_CAPTURE);
|
||||
for($i=0; $i<count($strings); $i++) {
|
||||
switch($strings[$i]) {
|
||||
case '(':
|
||||
break;
|
||||
case 'NAME':
|
||||
if($strings[$i+1]!="(") {
|
||||
do {
|
||||
$i++;
|
||||
if(strlen($this->name)==0)
|
||||
$this->name = $strings[$i];
|
||||
else
|
||||
$this->name .= " " . $strings[$i];
|
||||
}while(!preg_match("/\'$/s", $strings[$i]));
|
||||
} else {
|
||||
$i++;
|
||||
do {
|
||||
$i++;
|
||||
if(strlen($this->name) == 0)
|
||||
$this->name = $strings[$i];
|
||||
else
|
||||
$this->name .= " " . $strings[$i];
|
||||
} while(!preg_match("/\'$/s", $strings[$i]));
|
||||
do {
|
||||
$i++;
|
||||
}while($strings[$i]!=")");
|
||||
}
|
||||
break;
|
||||
case 'DESC':
|
||||
do {
|
||||
$i++;
|
||||
if(strlen($this->description)==0)
|
||||
$this->description=$this->description . $strings[$i];
|
||||
else
|
||||
$this->description=$this->description . " " . $strings[$i];
|
||||
}while(!preg_match("/\'$/s", $strings[$i]));
|
||||
break;
|
||||
case 'OBSOLETE':
|
||||
$this->is_obsolete = TRUE;
|
||||
break;
|
||||
case 'SUP':
|
||||
if($strings[$i+1]!="(") {
|
||||
$i++;
|
||||
array_push ($this->sup_classes, $strings[$i]);
|
||||
}else{
|
||||
$i++;
|
||||
do {
|
||||
$i++;
|
||||
if($strings[$i]!="$")
|
||||
array_push( $this->sup_classes, $strings[$i] );
|
||||
}while($strings[$i+1]!=")");
|
||||
}
|
||||
break;
|
||||
case 'ABSTRACT':
|
||||
$this->type='abstract';
|
||||
break;
|
||||
case 'STRUCTURAL':
|
||||
$this->type='structural';
|
||||
break;
|
||||
case 'AUXILIARY':
|
||||
$this->type='auxiliary';
|
||||
break;
|
||||
case 'MUST':
|
||||
if($strings[$i+1]!="(") {
|
||||
$i++;
|
||||
array_push ($this->must_attrs, $strings[$i]);
|
||||
}else{
|
||||
$i++;
|
||||
do {
|
||||
$i++;
|
||||
if($strings[$i]!="$")
|
||||
array_push ($this->must_attrs, $strings[$i]);
|
||||
}while($strings[$i+1]!=")");
|
||||
}
|
||||
sort($this->must_attrs);
|
||||
break;
|
||||
case 'MAY':
|
||||
if($strings[$i+1]!="(") {
|
||||
$i++;
|
||||
array_push ($this->may_attrs, $strings[$i]);
|
||||
}else{
|
||||
$i++;
|
||||
do
|
||||
{
|
||||
$i++;
|
||||
if($strings[$i]!="$")
|
||||
array_push ($this->may_attrs, $strings[$i]);
|
||||
}while($strings[$i+1]!=")");
|
||||
}
|
||||
sort($this->may_attrs);
|
||||
break;
|
||||
default:
|
||||
if(preg_match ("/[\d\.]+/i",$strings[$i]))
|
||||
$this->oid = $strings[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$this->name = preg_replace("/^\'/", "", $this->name);
|
||||
$this->name = preg_replace("/\'$/", "", $this->name);
|
||||
$this->description = preg_replace("/^\'/", "", $this->description);
|
||||
$this->description = preg_replace("/\'$/", "", $this->description);
|
||||
}
|
||||
|
||||
/* Getters */
|
||||
function getMustAttrs()
|
||||
{
|
||||
return $this->must_attrs;
|
||||
}
|
||||
|
||||
function getMayAttrs()
|
||||
{
|
||||
return $this->may_attrs;
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
function getSupClasses()
|
||||
{
|
||||
return $this->sup_classes;
|
||||
}
|
||||
|
||||
function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
function getIsObsolete()
|
||||
{
|
||||
return $this->is_obsolete;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds the specified array of attributes to this objectClass' list of
|
||||
* MUST attributes. The resulting array of must attributes will contain
|
||||
* unique members.
|
||||
*/
|
||||
function addMustAttrs( $new_must_attrs )
|
||||
{
|
||||
if( ! is_array( $new_must_attrs ) )
|
||||
return;
|
||||
if( 0 == count( $new_must_attrs ) )
|
||||
return;
|
||||
$this->must_attrs = array_values( array_unique( array_merge( $this->must_attrs, $new_must_attrs ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Behaves identically to addMustAttrs, but it operates on the MAY
|
||||
* attributes of this objectClass.
|
||||
*/
|
||||
function addMayAttrs( $new_may_attrs )
|
||||
{
|
||||
if( ! is_array( $new_may_attrs ) )
|
||||
return;
|
||||
if( 0 == count( $new_may_attrs ) )
|
||||
return;
|
||||
$this->may_attrs = array_values( array_unique( array_merge( $this->may_attrs, $new_may_attrs ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associative array of this objectClass.
|
||||
* This exists for backwards compatibility for portions of PLA
|
||||
* that have not yet been made aware of the new object oriented
|
||||
* ObjectClass code.
|
||||
*/
|
||||
function toAssoc()
|
||||
{
|
||||
return array (
|
||||
'oid' => $this->oid,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'sup' => $this->sup_classes,
|
||||
'type' => $this->type,
|
||||
'must_attrs' => $this->must_attrs,
|
||||
'may_attrs' => $this->may_attrs,
|
||||
'is_obsolete' => $this->is_obsolete );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Represents an LDAP AttributeType
|
||||
*/
|
||||
class AttributeType
|
||||
{
|
||||
/* The OID of this attributeType: ie, 1.2.3.4*/
|
||||
var $oid;
|
||||
/* The name of this attributeType */
|
||||
var $name;
|
||||
/* string: the description */
|
||||
var $description;
|
||||
/* boolean: is it obsoloete */
|
||||
var $is_obsolete;
|
||||
/* The attribute from which this attribute inherits (if any) */
|
||||
var $sup_attribute;
|
||||
/* The equality rule used */
|
||||
var $equality;
|
||||
/* The ordering of the attributeType */
|
||||
var $ordering;
|
||||
/* Boolean: supports substring matching? */
|
||||
var $sub_str;
|
||||
/* The full syntax string, ie 1.2.3.4{16} */
|
||||
var $syntax;
|
||||
/* boolean: is single valued only? */
|
||||
var $is_single_value;
|
||||
/* boolean: is collective? */
|
||||
var $is_collective;
|
||||
/* boolean: can use modify? */
|
||||
var $is_no_user_modification;
|
||||
/* The usage string set by the LDAP schema */
|
||||
var $usage;
|
||||
/* An array of alias attribute names, strings */
|
||||
var $aliases;
|
||||
/* The max number of characters this attribute can be */
|
||||
var $max_length;
|
||||
/* A string description of the syntax type (taken from the LDAPSyntaxes) */
|
||||
var $type;
|
||||
/* An array of objectClasses which use this attributeType (must be set by caller) */
|
||||
var $used_in_object_classes;
|
||||
|
||||
/*
|
||||
* Initialize the class' member variables
|
||||
*/
|
||||
function initVars()
|
||||
{
|
||||
$this->oid = null;
|
||||
$this->name = null;
|
||||
$this->description = null;
|
||||
$this->is_obsolete = false;
|
||||
$this->sup_attribute = null;
|
||||
$this->equality = null;
|
||||
$this->ordering = null;
|
||||
$this->sub_str = null;
|
||||
$this->syntax_oid = null;
|
||||
$this->syntax = null;
|
||||
$this->max_length = null;
|
||||
$this->is_single_value= false;
|
||||
$this->is_collective = false;
|
||||
$this->is_no_user_modification = false;
|
||||
$this->usage = null;
|
||||
$this->aliases = array();
|
||||
$this->type = null;
|
||||
$this->used_in_object_classes = array();
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses a raw LDAP objectClass string into this object's $this vars
|
||||
*/
|
||||
function AttributeType( $raw_ldap_attr_string )
|
||||
{
|
||||
//echo "<nobr>$raw_ldap_attr_string</nobr><Br />";
|
||||
$this->initVars();
|
||||
$attr = $raw_ldap_attr_string;
|
||||
$strings = preg_split ("/[\s,]+/", $attr, -1,PREG_SPLIT_DELIM_CAPTURE);
|
||||
for($i=0; $i<count($strings); $i++) {
|
||||
switch($strings[$i]) {
|
||||
case '(':
|
||||
break;
|
||||
case 'NAME':
|
||||
if($strings[$i+1]!="(") {
|
||||
do {
|
||||
$i++;
|
||||
if(strlen($this->name)==0)
|
||||
$this->name = $strings[$i];
|
||||
else
|
||||
$this->name .= " " . $strings[$i];
|
||||
}while(!preg_match("/\'$/s", $strings[$i]));
|
||||
// this attribute has no aliases
|
||||
$this->aliases = array();
|
||||
} else {
|
||||
$i++;
|
||||
do {
|
||||
$i++;
|
||||
if(strlen($this->name) == 0)
|
||||
$this->name = $strings[$i];
|
||||
else
|
||||
$this->name .= " " . $strings[$i];
|
||||
} while(!preg_match("/\'$/s", $strings[$i]));
|
||||
// add alias names for this attribute
|
||||
while($strings[++$i]!=")") {
|
||||
$alias = $strings[$i];
|
||||
$alias = preg_replace("/^\'/", "", $alias );
|
||||
$alias = preg_replace("/\'$/", "", $alias );
|
||||
$this->aliases[] = $alias;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'DESC':
|
||||
do {
|
||||
$i++;
|
||||
if(strlen($this->description)==0)
|
||||
$this->description=$this->description . $strings[$i];
|
||||
else
|
||||
$this->description=$this->description . " " . $strings[$i];
|
||||
}while(!preg_match("/\'$/s", $strings[$i]));
|
||||
break;
|
||||
case 'OBSOLETE':
|
||||
$this->is_obsolete = TRUE;
|
||||
break;
|
||||
case 'SUP':
|
||||
$i++;
|
||||
$this->sup_attribute = $strings[$i];
|
||||
break;
|
||||
case 'EQUALITY':
|
||||
$i++;
|
||||
$this->equality = $strings[$i];
|
||||
break;
|
||||
case 'ORDERING':
|
||||
$i++;
|
||||
$this->ordering = $strings[$i];
|
||||
break;
|
||||
case 'SUBSTR':
|
||||
$i++;
|
||||
$this->sub_str = $strings[$i];
|
||||
break;
|
||||
case 'SYNTAX':
|
||||
$i++;
|
||||
$this->syntax = $strings[$i];
|
||||
$this->syntax_oid = preg_replace( "/{\d+}$/", "", $this->syntax );
|
||||
// does this SYNTAX string specify a max length (ie, 1.2.3.4{16})
|
||||
if( preg_match( "/{(\d+)}$/", $this->syntax, $this->max_length ) )
|
||||
$this->max_length = $this->max_length[1];
|
||||
else
|
||||
$this->max_length = null;
|
||||
if($strings[$i+1]=="{") {
|
||||
do {
|
||||
$i++;
|
||||
$this->name .= " " . $strings[$i];
|
||||
} while($strings[$i]!="}");
|
||||
}
|
||||
break;
|
||||
case 'SINGLE-VALUE':
|
||||
$this->is_single_value = TRUE;
|
||||
break;
|
||||
case 'COLLECTIVE':
|
||||
$this->is_collective = TRUE;
|
||||
break;
|
||||
case 'NO-USER-MODIFICATION':
|
||||
$this->is_no_user_modification = TRUE;
|
||||
break;
|
||||
case 'USAGE':
|
||||
$i++;
|
||||
$this->usage = $strings[$i];
|
||||
break;
|
||||
default:
|
||||
if(preg_match ("/[\d\.]+/i",$strings[$i]))
|
||||
$this->oid = $strings[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$this->name = preg_replace("/^\'/", "", $this->name);
|
||||
$this->name = preg_replace("/\'$/", "", $this->name);
|
||||
$this->description = preg_replace("/^\'/", "", $this->description);
|
||||
$this->description = preg_replace("/\'$/", "", $this->description);
|
||||
}
|
||||
|
||||
/* Getters */
|
||||
function getOID()
|
||||
{
|
||||
return $this->oid;
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
function getIsObsolete()
|
||||
{
|
||||
return $this->is_obsolete;
|
||||
}
|
||||
|
||||
function getUsage()
|
||||
{
|
||||
return $this->usage;
|
||||
}
|
||||
|
||||
function getSupAttribute()
|
||||
{
|
||||
return $this->sup_attribute;
|
||||
}
|
||||
|
||||
function getEquality()
|
||||
{
|
||||
return $this->equality;
|
||||
}
|
||||
|
||||
function getOrdering()
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
function getSubstr()
|
||||
{
|
||||
return $this->sub_str;
|
||||
}
|
||||
|
||||
function getAliases()
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the entire raw syntax string for this attr, for example: 1.2.3.4{16}
|
||||
*/
|
||||
function getSyntaxString()
|
||||
{
|
||||
return $this->syntax;
|
||||
}
|
||||
|
||||
/*
|
||||
* Differs from getSyntaxString() in that it only returns the actual OID with any length
|
||||
* specification removed. Ie, if the syntax string is 1.2.3.4{16}, this retruns
|
||||
* 1.2.3.4.
|
||||
*/
|
||||
function getSyntaxOID()
|
||||
{
|
||||
return $this->syntax_oid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the maximum length specified by this attribute (ie, "16" in 1.2.3.4{16})
|
||||
*/
|
||||
function getMaxLength()
|
||||
{
|
||||
return $this->max_length;
|
||||
}
|
||||
|
||||
function getIsSingleValue()
|
||||
{
|
||||
return $this->is_single_value;
|
||||
}
|
||||
|
||||
function getIsCollective()
|
||||
{
|
||||
return $this->is_collective;
|
||||
}
|
||||
|
||||
function getIsNoUserModification()
|
||||
{
|
||||
return $this->is_no_user_modification;
|
||||
}
|
||||
|
||||
function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes an attribute name from the alias array.
|
||||
*/
|
||||
function removeAlias( $remove_alias_name )
|
||||
{
|
||||
foreach( $this->aliases as $i => $alias_name ) {
|
||||
if( 0 == strcasecmp( $alias_name, $remove_alias_name ) ) {
|
||||
unset( $this->aliases[ $i ] );
|
||||
$this->aliases = array_values( $this->aliases );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds an attribute name to the alias array.
|
||||
*/
|
||||
function addAlias( $new_alias_name )
|
||||
{
|
||||
$this->aliases[] = $new_alias_name;
|
||||
}
|
||||
|
||||
function setName( $new_name )
|
||||
{
|
||||
$this->name = $new_name;
|
||||
}
|
||||
|
||||
function setDescription( $new_desc )
|
||||
{
|
||||
$this->description = $new_desc;
|
||||
}
|
||||
|
||||
function setSupAttribute( $new_sup_attr )
|
||||
{
|
||||
$this->sup_attribute = $new_sup_attr;
|
||||
}
|
||||
|
||||
function setAliases( $new_aliases )
|
||||
{
|
||||
$this->aliases = $new_aliases;
|
||||
}
|
||||
|
||||
function setType( $new_type )
|
||||
{
|
||||
$this->type = $new_type;
|
||||
}
|
||||
|
||||
function addUsedInObjectClass( $object_class_name )
|
||||
{
|
||||
if( ! in_array( $object_class_name, $this->used_in_object_classes ) ) {
|
||||
$this->used_in_object_classes[] = $object_class_name;
|
||||
}
|
||||
}
|
||||
|
||||
function getUsedInObjectClasses()
|
||||
{
|
||||
return $this->used_in_object_classes;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associative array of objectClasses for the specified
|
||||
* $server_id. Each array entry's key is the name of the objectClass
|
||||
* in lower-case.
|
||||
* The sub-entries consist of sub-arrays called 'must_attrs' and
|
||||
* 'may_attrs', and sub-entries called 'oid', 'name' and 'description'.
|
||||
*
|
||||
* The bulk of this function came from the good code in the
|
||||
* GPL'ed LDAP Explorer project. Thank you.
|
||||
*/
|
||||
function get_schema_objectclasses( $server_id )
|
||||
{
|
||||
// cache the schema to prevent multiple schema fetches from LDAP server
|
||||
static $cache = array();
|
||||
if( isset( $cache[$server_id] ) ) {
|
||||
//echo "Using oclass cache.<br />";
|
||||
return $cache[$server_id];
|
||||
}
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// try with the standard DN
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'objectclasses' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
// try again, with a different schema DN
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'objectclasses' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
// give up
|
||||
return false;
|
||||
|
||||
$raw_oclasses = @ldap_get_entries($ds,$result );
|
||||
|
||||
// build the array of objectClasses
|
||||
$object_classes = array();
|
||||
for( $i=0; $i < $raw_oclasses[0]['objectclasses']['count']; $i++ ) {
|
||||
$class_string = $raw_oclasses[0]["objectclasses"][$i];
|
||||
if( $class_string == null || 0 == strlen( $class_string ) )
|
||||
continue;
|
||||
$object_class = new ObjectClass( $class_string );
|
||||
$name = $object_class->getName();
|
||||
$key = strtolower( $name );
|
||||
$object_classes[ $key ] = $object_class->toAssoc();
|
||||
}
|
||||
|
||||
// go back and add any inherited MUST/MAY attrs to each objectClass
|
||||
foreach( $object_classes as $name => $object_class ) {
|
||||
$sup_classes = $object_class['sup'];
|
||||
$must = $object_class['must_attrs'];
|
||||
$may = $object_class['may_attrs'];
|
||||
|
||||
foreach( $sup_classes as $sup_class )
|
||||
add_sup_class_attrs( $name, $sup_class, $object_classes, $must, $may );
|
||||
$object_classes[ $name ][ 'must_attrs' ] = $must;
|
||||
$object_classes[ $name ][ 'may_attrs' ] = $may;
|
||||
}
|
||||
|
||||
ksort( $object_classes );
|
||||
|
||||
// cache the schema to prevent multiple schema fetches from LDAP server
|
||||
$cache[ $server_id ] = $object_classes;
|
||||
return( $object_classes );
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function for get_schema_objectclasses. This is a recursive function that
|
||||
* will add MUST and MAY attributes based on an objectclas' inherited objectclasses.
|
||||
*/
|
||||
function add_sup_class_attrs( $oclass, $sup_class, &$oclasses, &$must_attrs, &$may_attrs )
|
||||
{
|
||||
//echo "add_sup_class_attrs( $oclass, $sup_class )<br />";
|
||||
// base cases
|
||||
if( 0 == strcasecmp( $sup_class, 'top' ) ) return;
|
||||
if( ! isset( $oclasses[ strtolower( $sup_class ) ] ) ) return;
|
||||
|
||||
// recursive case
|
||||
$new_must = $oclasses[ strtolower( $sup_class ) ]['must_attrs'];
|
||||
$new_may = $oclasses[ strtolower( $sup_class ) ]['may_attrs'];
|
||||
$must_attrs = array_unique( array_merge( $new_must, $must_attrs ) );
|
||||
$may_attrs = array_unique( array_merge( $new_may, $may_attrs ) );
|
||||
|
||||
$sup_classes = $oclasses[ strtolower( $sup_class ) ]['sup'];
|
||||
if( is_array( $sup_classes ) && count( $sup_classes ) > 0 )
|
||||
foreach( $sup_classes as $sup_sup_class )
|
||||
add_sup_class_attrs( $sup_class, $sup_sup_class, $oclasses, $must_attrs, $may_attrs );
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves the schema for a single attribute.
|
||||
*/
|
||||
function get_schema_attribute( $server_id, $attr_name )
|
||||
{
|
||||
$attr_name = preg_replace( "/;.*$/U", "", $attr_name );
|
||||
$schema_attrs = get_schema_attributes( $server_id );
|
||||
$attr_name = strtolower( $attr_name );
|
||||
$schema_attr = isset( $schema_attrs[ $attr_name ] ) ?
|
||||
$schema_attrs[ $attr_name ] :
|
||||
null;
|
||||
return $schema_attr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associative array of attributes for the specified
|
||||
* $server_id. Each array entry's key is the name of the attribute,
|
||||
* in lower-case.
|
||||
* The sub-entries are 'oid', 'syntax', 'equality', 'substr', 'name',
|
||||
* and 'single_value'.
|
||||
*
|
||||
* The bulk of this function came from the good code in the
|
||||
* GPL'ed LDAP Explorer project. Thank you. It was extended
|
||||
* considerably for application here.
|
||||
*/
|
||||
function get_schema_attributes( $server_id, $lower_case_keys = false )
|
||||
{
|
||||
// Cache gets filled in later (bottom). each subsequent call uses
|
||||
// the cache which has the attributes already fetched and parsed
|
||||
static $cache = null;
|
||||
if( isset( $cache[ $server_id ] ) ) {
|
||||
//echo "Using attr cache<br />";
|
||||
return $cache[ $server_id ];
|
||||
}
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// get all the attributeTypes
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'attributeTypes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'attributeTypes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( $result )
|
||||
$raw_attrs = ldap_get_entries( $ds, $result );
|
||||
else
|
||||
$raw_attrs = array();
|
||||
|
||||
$syntaxes = get_schema_syntaxes( $server_id );
|
||||
|
||||
// build the array of attribueTypes
|
||||
$attrs = array();
|
||||
for( $i=0; $i < $raw_attrs[0]['attributetypes']['count']; $i++ ) {
|
||||
$attr_string = $raw_attrs[0]['attributetypes'][$i];
|
||||
if( $attr_string == null || 0 == strlen( $attr_string ) )
|
||||
continue;
|
||||
$attr = new AttributeType( $attr_string );
|
||||
if( isset( $syntaxes[ $attr->getSyntaxOID() ] ) )
|
||||
$attr->setType( $syntaxes[ $attr->getSyntaxOID() ]['description'] );
|
||||
$name = $attr->getName();
|
||||
$key = strtolower( $name );
|
||||
$attrs[ $key ] = $attr;
|
||||
}
|
||||
|
||||
add_aliases_to_attrs( $attrs );
|
||||
add_sup_to_attrs( $attrs );
|
||||
|
||||
ksort( $attrs );
|
||||
|
||||
// cache the schema to prevent multiple schema fetches from LDAP server
|
||||
$cache[ $server_id ] = $attrs;
|
||||
return( $attrs );
|
||||
}
|
||||
|
||||
/*
|
||||
* For each attribute that has multiple names, this function adds unique entries to
|
||||
* the attrs array for those names. Ie, attributeType has name 'gn' and 'givenName'.
|
||||
* This function will create a unique entry for 'gn' and 'givenName'.
|
||||
*/
|
||||
function add_aliases_to_attrs( &$attrs )
|
||||
{
|
||||
// go back and add data from aliased attributeTypes
|
||||
foreach( $attrs as $name => $attr ) {
|
||||
$aliases = $attr->getAliases();
|
||||
if( is_array( $aliases ) && count( $aliases ) > 0 ) {
|
||||
// foreach of the attribute's aliases, create a new entry in the attrs array
|
||||
// with its name set to the alias name, and all other data copied
|
||||
foreach( $aliases as $i => $alias_attr_name ) {
|
||||
$new_attr = $attr;
|
||||
$new_attr->setName( $alias_attr_name );
|
||||
$new_attr->addAlias( $attr->getName() );
|
||||
$new_attr->removeAlias( $alias_attr_name );
|
||||
$new_attr_key = strtolower( $alias_attr_name );
|
||||
$attrs[ $new_attr_key ] = $new_attr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds inherited values to each attributeType specified by the SUP directive.
|
||||
* Supports infinite levels of inheritance.
|
||||
*/
|
||||
function add_sup_to_attrs( &$attrs )
|
||||
{
|
||||
// go back and add any inherited descriptions from parent attributes (ie, cn inherits name)
|
||||
foreach( $attrs as $key => $attr ) {
|
||||
$sup_attr = $attr->getSupAttribute();
|
||||
while( $sup_attr != null ) {
|
||||
if( ! isset( $attrs[ strtolower( $sup_attr ) ] ) ){
|
||||
pla_error( "Warning: attributeType '" . $attr->getName() . "' inherits from
|
||||
'" . $sup_attr . "', but attributeType '" . $sup_attr . "' does not
|
||||
exist." );
|
||||
return;
|
||||
}
|
||||
|
||||
$sup_attr = $attrs[ strtolower( $sup_attr ) ];
|
||||
// if the inhertied attriute does not inherit any furth attributes,
|
||||
// copy its values and move on to the next attributeType
|
||||
if( null == $sup_attr->getSupAttribute() ) {
|
||||
// only three values are allowed to be set when an attributeType SUPs another
|
||||
// attributeType: NAME, DESC, and SUP
|
||||
$tmp_name = $attr->getName();
|
||||
$tmp_desc = $attr->getDescription();
|
||||
$tmp_sup = $attr->getSupAttribute();
|
||||
$tmp_aliases = $attr->getAliases();
|
||||
|
||||
$attr = $sup_attr;
|
||||
|
||||
$attr->setName( $tmp_name );
|
||||
$attr->setDescription( $tmp_desc );
|
||||
$attr->setSupAttribute( $tmp_sup);
|
||||
$attr->setAliases( $tmp_aliases );
|
||||
// replace this attribute in the attrs array now that we have populated
|
||||
// new values therein
|
||||
$attrs[$key] = $attr;
|
||||
$sup_attr = null;
|
||||
} else {
|
||||
// set the sup_attr to the name of the attributeType from which
|
||||
// this attributeType inherits and move up the inheritance chain.
|
||||
$sup_attr = $sup_attr->getSupAttribute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associate array of the server's schema matching rules
|
||||
*/
|
||||
function get_schema_matching_rules( $server_id )
|
||||
{
|
||||
static $cache;
|
||||
|
||||
// cache the schema to prevent multiple schema fetches from LDAP server
|
||||
if( isset( $cache[$server_id] ) ) {
|
||||
//echo "Using matching rules cache.<br />";
|
||||
return $cache[$server_id];
|
||||
}
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// get all the attributeTypes
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'matchingRules', 'matchingRuleUse' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'matchingRules', 'matchingRuleUse' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( $result )
|
||||
$raw = ldap_get_entries( $ds, $result );
|
||||
else
|
||||
return( array() );
|
||||
|
||||
// build the array of attributes
|
||||
$rules = array();
|
||||
for( $i=0; $i < $raw[0]['matchingrules']['count']; $i++ )
|
||||
{
|
||||
$rule = $raw[0]['matchingrules'][$i];
|
||||
preg_match( "/[\s]+([\d\.]+)[\s]+/", $rule, $oid);
|
||||
preg_match( "/[\s]+NAME[\s]+'([\)\(:?\.a-zA-Z0-9\-_ ]+)'/", $rule, $name );
|
||||
|
||||
$key = strtolower( trim( $oid[1] ) );
|
||||
if( ! $key ) continue;
|
||||
|
||||
$rules[$key] = $name[1];
|
||||
//$rules[$key]['name'] = $name[1];
|
||||
}
|
||||
|
||||
ksort( $rules );
|
||||
|
||||
// cache the schema to prevent multiple schema fetches from LDAP server
|
||||
$cache[$server_id] = $rules;
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an associate array of the syntax OIDs that this LDAP server uses mapped to
|
||||
* their descriptions.
|
||||
*/
|
||||
function get_schema_syntaxes( $server_id )
|
||||
{
|
||||
static $cache;
|
||||
|
||||
// cache the schema to prevent multiple schema fetches from LDAP server
|
||||
if( isset( $cache[$server_id] ) ) {
|
||||
//echo "Using syntax cache.<br />";
|
||||
return $cache[$server_id];
|
||||
}
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
|
||||
if( ! $ds )
|
||||
return false;
|
||||
|
||||
// get all the attributeTypes
|
||||
$result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)',
|
||||
array( 'ldapSyntaxes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
if( ! $result )
|
||||
$result = @ldap_read($ds, 'cn=schema', '(objectClass=*)',
|
||||
array( 'ldapSyntaxes' ), 0, 200, 0, LDAP_DEREF_ALWAYS );
|
||||
|
||||
if( $result )
|
||||
$raw = ldap_get_entries( $ds, $result );
|
||||
else
|
||||
return( array() );
|
||||
|
||||
// build the array of attributes
|
||||
$syntaxes = array();
|
||||
for( $i=0; $i < $raw[0]['ldapsyntaxes']['count']; $i++ )
|
||||
{
|
||||
$syntax = $raw[0]['ldapsyntaxes'][$i];
|
||||
preg_match( "/[\s]+([\d\.]+)[\s]+/", $syntax, $oid);
|
||||
preg_match( "/[\s]+DESC[\s]+'([\)\(:?\.a-zA-Z0-9\-_ ]+)'/", $syntax, $description );
|
||||
|
||||
$key = strtolower( trim( $oid[1] ) );
|
||||
if( ! $key ) continue;
|
||||
|
||||
$syntaxes[$key] = array();
|
||||
$syntaxes[$key]['description'] = $description[1];
|
||||
}
|
||||
|
||||
ksort( $syntaxes );
|
||||
|
||||
// cache the schema to prevent multiple schema fetches from LDAP server
|
||||
$cache[$server_id] = $syntaxes;
|
||||
|
||||
return $syntaxes;
|
||||
}
|
||||
|
||||
?>
|
68
search.php
68
search.php
@ -13,8 +13,7 @@
|
||||
* - base_dn, scope, filter
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_GET['server_id'];
|
||||
|
||||
@ -27,25 +26,33 @@ else
|
||||
{
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . var_dump( htmlspecialchars( $server_id ) ) );
|
||||
}
|
||||
$js_on_change_string ='';
|
||||
if( $_GET['form'] == 'advanced' ) {
|
||||
$js_on_change_string = 'onChange="document.forms[0].base_dn.value=servers[document.forms[0].server_id.value].getBaseDn()"';
|
||||
}
|
||||
|
||||
// build the server drop-down html and JavaScript array (for base_dns)
|
||||
$server_menu_html = '<select name="server_id" onChange="base_dn.value = server_base_dns[ this.value ]">';
|
||||
$js_dn_list = '';
|
||||
$server_menu_html = '<select name="server_id" '.$js_on_change_string.'>';
|
||||
|
||||
$server_info_list =array();
|
||||
|
||||
foreach( $servers as $id => $server ) {
|
||||
$base_dn = $server['base'] ? $server['base'] : try_to_get_root_dn( $id );
|
||||
$js_dn_list .= '"' . $server['base'] . '",';
|
||||
$server_info_list[$id]['id'] = $id;
|
||||
$server_info_list[$id]['name'] = $server['name'];
|
||||
$server_info_list[$id]['base_dn'] = $base_dn;
|
||||
|
||||
if( $server['host'] ) {
|
||||
$server_menu_html .= '<option value="'.$id.'"' . ( $id==$server_id? ' selected' : '' ) . '>';
|
||||
$server_menu_html .= $server['name'] . '</option>';
|
||||
}
|
||||
}
|
||||
// trim off the trailing comma
|
||||
$js_dn_list = substr( $js_dn_list, 0, strlen($js_dn_list)-1 );
|
||||
|
||||
$server_menu_html .= '</select>';
|
||||
|
||||
$filter = stripslashes( $_GET['filter'] );
|
||||
$filter = $_GET['filter'];
|
||||
$filter = utf8_encode($filter);
|
||||
$attr = stripslashes( $_GET['attribute'] );
|
||||
$attr = $_GET['attribute'];
|
||||
|
||||
// grab the base dn for the search
|
||||
if( isset( $_GET['base_dn'] ) )
|
||||
@ -55,8 +62,8 @@ elseif( '' != $servers[$server_id]['base'] )
|
||||
else
|
||||
$base_dn = try_to_get_root_dn( $server_id );
|
||||
|
||||
$criterion = stripslashes( $_GET['criterion'] );
|
||||
$form = stripslashes( $_GET['form'] );
|
||||
$criterion = $_GET['criterion'];
|
||||
$form = $_GET['form'];
|
||||
$scope = $_GET['scope'] ? $_GET['scope'] : 'sub';
|
||||
//echo "<PRE>";print_r( $_GET );echo "</pre>";
|
||||
?>
|
||||
@ -88,7 +95,7 @@ if( $_GET['search'] )
|
||||
|
||||
if( $form == 'advanced' ) {
|
||||
$search_result_attributes = isset( $_GET['display_attrs'] ) ?
|
||||
stripslashes( $_GET['display_attrs'] ) :
|
||||
$_GET['display_attrs'] :
|
||||
$search_result_attributes;
|
||||
process_config();
|
||||
}
|
||||
@ -117,12 +124,22 @@ if( $_GET['search'] )
|
||||
{
|
||||
switch( $criterion ) {
|
||||
case 'starts with':
|
||||
// to fix bug 789113
|
||||
if( $filter == "*" )
|
||||
$filter = "";
|
||||
$filter = "($attr=$filter*)";
|
||||
break;
|
||||
case 'contains':
|
||||
$filter = "($attr=*$filter*)";
|
||||
// to fix bug 789113
|
||||
if( $filter == "*" )
|
||||
$filter = "($attr=*)";
|
||||
else
|
||||
$filter = "($attr=*$filter*)";
|
||||
break;
|
||||
case 'ends with':
|
||||
// to fix bug 789113
|
||||
if( $filter == "*" )
|
||||
$filter = "";
|
||||
$filter = "($attr=*$filter)";
|
||||
break;
|
||||
case 'equals':
|
||||
@ -139,12 +156,11 @@ if( $_GET['search'] )
|
||||
}
|
||||
|
||||
$time_start = utime();
|
||||
$results = pla_ldap_search( $server_id, $filter, $base_dn,
|
||||
array_merge( $search_result_attributes, array( $search_result_title_attribute ) ),
|
||||
$scope );
|
||||
$results = pla_ldap_search( $server_id, $filter, $base_dn, $search_result_attributes, $scope );
|
||||
$time_end = utime();
|
||||
$time_elapsed = round( $time_end - $time_start, 2 );
|
||||
$count = count( $results );
|
||||
|
||||
?>
|
||||
|
||||
<br />
|
||||
@ -159,25 +175,27 @@ if( $_GET['search'] )
|
||||
<?php flush(); ?>
|
||||
|
||||
<?php if( $results ) foreach( $results as $dn => $attrs ) { ?>
|
||||
<?php $encoded_dn = rawurlencode($attrs['dn']); ?>
|
||||
<?php $rdn = utf8_decode( get_rdn( $attrs['dn'] ) ); ?>
|
||||
<?php $encoded_dn = rawurlencode( $dn ); ?>
|
||||
<?php $rdn = utf8_decode( get_rdn( $dn ) ); ?>
|
||||
<div class="search_result">
|
||||
<a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>">
|
||||
<?php echo htmlspecialchars($rdn); ?>
|
||||
</a>
|
||||
</div>
|
||||
<table class="attrs">
|
||||
<?php if( is_array( $search_result_attributes ) ) foreach( $search_result_attributes as $attr ) { ?>
|
||||
<?php foreach( $attrs as $attr => $values ) { ?>
|
||||
|
||||
<tr>
|
||||
<td class="attr" valign="top"><?php echo htmlspecialchars($attr); ?></td>
|
||||
<td class="attr" valign="top"><?php echo htmlspecialchars( $attr ); ?></td>
|
||||
<td class="val">
|
||||
<?php if( is_array( $attrs[strtolower($attr)] ) ) { ?>
|
||||
<?php foreach( $attrs[strtolower($attr)] as $a ) { ?>
|
||||
<?php echo str_replace( ' ', ' ', htmlspecialchars(utf8_decode($a))); ?><br />
|
||||
<?php if( is_array( $values ) ) { ?>
|
||||
<?php foreach( $values as $value ) { ?>
|
||||
<?php echo str_replace( ' ', ' ',
|
||||
htmlspecialchars( utf8_decode( $value ) ) ); ?><br />
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<?php echo str_replace( ' ', ' ', htmlspecialchars(utf8_decode($attrs[strtolower($attr)]))); ?>
|
||||
<?php echo str_replace( ' ', ' ',
|
||||
htmlspecialchars( utf8_decode( $values ) ) ); ?>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
@ -188,7 +206,7 @@ if( $_GET['search'] )
|
||||
<?php } ?>
|
||||
|
||||
<br /><br />
|
||||
<div class="search_result"><center><span style="font-weight:normal;font-size:75%;">Search happily performed by phpLDAPAdmin in
|
||||
<div class="search_result"><center><span style="font-weight:normal;font-size:75%;">Search happily performed by phpLDAPadmin in
|
||||
<b><?php echo $time_elapsed; ?></b> seconds.</small></center></div>
|
||||
<?php
|
||||
}
|
||||
|
@ -1,9 +1,20 @@
|
||||
<script>
|
||||
<?
|
||||
$num_server = count($server_info_list);
|
||||
for($i=0;$i<$num_server;$i++){
|
||||
?>
|
||||
addToServersList(new server(<?=$i?>,"<?=$server_info_list[$i]['name']?>","<?=$server_info_list[$i]['base_dn']?>"));
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</script>
|
||||
|
||||
<form action="search.php" method="get" class="search">
|
||||
<input type="hidden" name="search" value="true" />
|
||||
<input type="hidden" name="form" value="advanced" />
|
||||
|
||||
<center><b>Advanced Search Form</b></center>
|
||||
<small>(<a href="search.php?server_id=<?php echo $server_id; ?>&form=simple">Simple Search Form</a>)</small><br />
|
||||
<center><b><?php echo $lang['advanced_search_form_str']; ?></b></center>
|
||||
<small>(<a href="search.php?server_id=<?php echo $server_id; ?>&form=simple"><?php echo $lang['simple_search_form_str']; ?></a>)</small><br />
|
||||
<br />
|
||||
|
||||
<table>
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
<table>
|
||||
<td>
|
||||
<center><b>Simple Search Form</b><br />
|
||||
<small>(<a href="search.php?server_id=<?php echo $server_id; ?>&form=advanced">Advanced Search Form</a>)</small><br />
|
||||
<center><b><?php echo $lang['simple_search_form_str']; ?></b><br />
|
||||
<small>(<a href="search.php?server_id=<?php echo $server_id; ?>&form=advanced"><?php echo $lang['advanced_search_form_str']; ?></a>)</small><br />
|
||||
<br />
|
||||
</center>
|
||||
|
||||
@ -24,7 +24,11 @@
|
||||
</select>
|
||||
|
||||
<select name="criterion">
|
||||
<?php foreach( $search_criteria_options as $c ) { ?>
|
||||
|
||||
|
||||
<?php
|
||||
$search_criteria_options = array( "equals", "starts with", "contains", "ends with", "sounds like" );
|
||||
foreach( $search_criteria_options as $c ) { ?>
|
||||
<option value="<?php echo $c; ?>"<?php echo $c==$criterion?' selected':''; ?>>
|
||||
<?php echo htmlspecialchars($c); ?>
|
||||
</option>
|
||||
|
76
search_util.js
Normal file
76
search_util.js
Normal file
@ -0,0 +1,76 @@
|
||||
// File: search_util.js
|
||||
// Purpose:
|
||||
// This JavaScript file defines some functions used by the two search forms for
|
||||
// auto-populating the base DN dynamically when a server is selected from the
|
||||
// drop-down.
|
||||
//
|
||||
|
||||
//the array to store the server
|
||||
var servers = new Array();
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Definition of the object server
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
//constructor of the server
|
||||
//param id the id of the server
|
||||
//param name the name of the server
|
||||
//param base_dn the base dn of the server
|
||||
|
||||
function server(id,name,base_dn){
|
||||
|
||||
//the properties of the object
|
||||
this.id =id;
|
||||
this.name = name;
|
||||
this.base_dn = base_dn;
|
||||
|
||||
// the method of the server
|
||||
this.getId=getId;
|
||||
this.setId=setId;
|
||||
this.getName = getName;
|
||||
this.setName = setName;
|
||||
this.setBaseDn = setBaseDn;
|
||||
this.getBaseDn = getBaseDn;
|
||||
}
|
||||
// set the id of the server
|
||||
function setId(id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
//return the id of the server
|
||||
function getId(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
// set the name of the server
|
||||
function setName(name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// return the name of the server
|
||||
function getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
// return the base dn of the server
|
||||
function getBaseDn(){
|
||||
return this.base_dn;
|
||||
}
|
||||
|
||||
// set the base dn of the server
|
||||
function setBaseDn(base_dn){
|
||||
this.base_dn = base_dn;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// End of the definition of the server
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
// add a server object to the array of server
|
||||
function addToServersList(obj_server){
|
||||
servers[servers.length] = obj_server;
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$server_id = $_GET['server_id'];
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
|
93
style.css
93
style.css
@ -1,17 +1,29 @@
|
||||
table.schema_oclasses {
|
||||
border-left: 1px solid black;
|
||||
border-right: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
border-top: 0;
|
||||
margin-bottom: 10px;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
table.schema_oclasses td {
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
table.schema_attr th {
|
||||
background-color: #016;
|
||||
padding: 5px;
|
||||
color: white;
|
||||
font-weight: normal;
|
||||
font-weight: bold;
|
||||
font-size: 125%;
|
||||
}
|
||||
|
||||
table.schema_attr td {
|
||||
padding: 5px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table.schema_attr tr.even {
|
||||
@ -22,13 +34,32 @@ table.schema_attr tr.odd {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
div.error {
|
||||
background-color: #eec;
|
||||
border: solid black 1px;
|
||||
padding: 15px;
|
||||
padding-top: 0px;
|
||||
width: 380px;
|
||||
table.schema_attr tr.highlight{
|
||||
background-color: #bcd;
|
||||
font-weight: Bold;
|
||||
}
|
||||
|
||||
table.error {
|
||||
width: 500px;
|
||||
border: 2px solid black;
|
||||
}
|
||||
|
||||
table.error tr td {
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
padding: 15px;
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
table.error tr td h2 {
|
||||
margin: 5px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
table.error tr td.img {
|
||||
vertical-align: center;
|
||||
text-align: center;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
table.confirm th {
|
||||
@ -79,6 +110,20 @@ body {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
table.tree tr.login td {
|
||||
}
|
||||
|
||||
table.tree td.links {
|
||||
padding: 0px;
|
||||
font-size: 10px;
|
||||
padding-left: 12px;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
table.tree td.links a {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
table.tree {
|
||||
border: 0px;
|
||||
}
|
||||
@ -86,7 +131,7 @@ table.tree {
|
||||
table.tree img {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
|
||||
table.tree td {
|
||||
padding: 2px;
|
||||
border: 0px solid black;
|
||||
@ -95,14 +140,27 @@ table.tree td {
|
||||
table.tree tr {
|
||||
}
|
||||
|
||||
table.tree tr.server {
|
||||
table.tree tr.server td.icon {
|
||||
width: 14px;
|
||||
}
|
||||
|
||||
table.tree tr.server td {
|
||||
padding-top: 15px;
|
||||
padding-bottom: 0px;
|
||||
vertical-align: top;
|
||||
font-size: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
table.tree td.icon {
|
||||
text-align: center;
|
||||
padding: 0px;
|
||||
width: 22px;
|
||||
width: 14px;
|
||||
font-size: 1px;
|
||||
}
|
||||
|
||||
table.tree td.rdn {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
table.tree td.rdn a {
|
||||
@ -115,6 +173,9 @@ table.tree td.rdn a:hover {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
table.tree td.create {
|
||||
}
|
||||
|
||||
table.tree td.create a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
@ -133,6 +194,7 @@ table.tree td.spacer {
|
||||
table.tree td.expander {
|
||||
text-align: center;
|
||||
width: 22px;
|
||||
max-width: 22px;
|
||||
min-width: 22px;
|
||||
}
|
||||
|
||||
@ -167,7 +229,7 @@ h3.subtitle {
|
||||
}
|
||||
|
||||
table.edit_dn tr.spacer td {
|
||||
height: 20px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
table.edit_dn {
|
||||
@ -200,6 +262,7 @@ table.edit_dn tr td.val {
|
||||
vertical-align: center;
|
||||
}
|
||||
|
||||
/* When an attr is updated, it is displayed in light blue to indicate such */
|
||||
table.edit_dn tr.updated_attr {
|
||||
background: #def;
|
||||
}
|
||||
@ -210,6 +273,12 @@ table.edit_dn tr.updated_attr td {
|
||||
color: #005;
|
||||
}
|
||||
|
||||
/* Neede to prevent sub-tables (like the one in which jpegPhotos are displayed)
|
||||
* from drawing borders as well. */
|
||||
table.edit_dn tr.updated_attr td table td {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
table.edit_dn tr.updated_attr a {
|
||||
}
|
||||
|
||||
@ -239,7 +308,7 @@ form.edit_dn {
|
||||
}
|
||||
|
||||
h4.oclass {
|
||||
background: #88b;
|
||||
background: #016;
|
||||
padding: 5px;
|
||||
margin: 0px;
|
||||
margin-top: 8px;
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require 'common.php';
|
||||
|
||||
// Common to all templates
|
||||
$rdn = stripslashes( $_POST['rdn'] );
|
||||
$container = stripslashes( $_POST['container'] );
|
||||
$rdn = isset( $_POST['rdn'] ) ? $_POST['rdn'] : null;
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Unique to this template
|
||||
$step = $_POST['step'];
|
||||
$step = isset( $_POST['step'] ) ? $_POST['step'] : null;
|
||||
if( ! $step )
|
||||
$step = 1;
|
||||
|
||||
@ -34,7 +34,7 @@ if( $step == 1 )
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="heading">Container:</td>
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars($container); ?>" />
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars( $container ); ?>" />
|
||||
<?php draw_chooser_link( 'creation_form.container' ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -74,32 +74,55 @@ if( $step == 2 )
|
||||
|
||||
// build a list of required attributes:
|
||||
$dn = $rdn . ',' . $container;
|
||||
$schema = get_schema( $server_id );
|
||||
$attrs = $schema['attrs'];
|
||||
//$attrs = get_schema_attributes( $server_id );
|
||||
$schema_oclasses = get_schema_objectclasses( $server_id );
|
||||
$required_attrs = array();
|
||||
$all_attrs = array();
|
||||
foreach( $oclasses as $oclass ) {
|
||||
$required_attrs = array_merge( $required_attrs, $schema['oclasses'][strtolower($oclass)]['must_attrs'] );
|
||||
$all_attrs = array_merge( $all_attrs, $schema['oclasses'][strtolower($oclass)]['must_attrs'],
|
||||
$schema['oclasses'][strtolower($oclass)]['may_attrs'] );
|
||||
$required_attrs = array_merge( $required_attrs, $schema_oclasses[strtolower($oclass)]['must_attrs'] );
|
||||
$all_attrs = array_merge( $all_attrs, $schema_oclasses[strtolower($oclass)]['must_attrs'],
|
||||
$schema_oclasses[strtolower($oclass)]['may_attrs'] );
|
||||
}
|
||||
|
||||
$required_attrs = array_unique( $required_attrs );
|
||||
$all_attrs = array_unique( $all_attrs );
|
||||
sort( $required_attrs );
|
||||
sort( $all_attrs );
|
||||
|
||||
// remove binary attributes and add them to the binary_attrs array
|
||||
$binary_attrs = array();
|
||||
foreach( $all_attrs as $i => $attr_name ) {
|
||||
if( is_attr_binary( $server_id, $attr_name ) ) {
|
||||
unset( $all_attrs[ $i ] );
|
||||
$binary_attrs[] = $attr_name;
|
||||
}
|
||||
}
|
||||
|
||||
$attr_select_html = "";
|
||||
foreach( $all_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) . ")";
|
||||
htmlspecialchars($a) . ")";
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $a );
|
||||
}
|
||||
|
||||
echo $attr_display;
|
||||
$attr_select_html .= "<option>$attr_display</option>\n";
|
||||
$attr_select_html .= "<option value=\"$a\">$attr_display</option>\n";
|
||||
}
|
||||
|
||||
$binary_select_html = "";
|
||||
if( count( $binary_attrs ) > 0 ) {
|
||||
foreach( $binary_attrs as $a ) {
|
||||
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
|
||||
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
|
||||
htmlspecialchars( $a ) . ")";
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $a );
|
||||
}
|
||||
|
||||
$binary_attr_select_html .= "<option>$attr_display</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// add the required attribute based on the RDN provided by the user
|
||||
@ -107,29 +130,19 @@ if( $step == 2 )
|
||||
// in the list of required attributes.
|
||||
$rdn_attr = trim( substr( $rdn, 0, strpos( $rdn, '=' ) ) );
|
||||
$rdn_value = trim( substr( $rdn, strpos( $rdn, '=' ) + 1 ) );
|
||||
if( ! in_array( $rdn_attr, $required_attrs ) )
|
||||
if( in_array( $rdn_attr, $all_attrs ) && ! in_array( $rdn_attr, $required_attrs ) )
|
||||
$required_attrs[] = $rdn_attr;
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<h4>Step 2 of 2: Specify attributes and values</h4>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td style="padding-right:10px">
|
||||
<small>Creating entry with <acronym title="Distinguished Name">DN</acronym>:
|
||||
<b><?php echo htmlspecialchars( $dn ); ?></b></small></td>
|
||||
<small><b>Instructions</b>:
|
||||
Enter values for the <?php echo count($required_attrs); ?> required attributes.<br/>
|
||||
Then specify any optional attributes. <?php if( count( $binary_attrs ) > 0 ) { ?>
|
||||
Finally, you may<br />specify optional binary attributes from a file if needed. <?php } ?>
|
||||
</small>
|
||||
|
||||
<td>
|
||||
<small><b>Instrucions</b>: Enter values for the <?php echo count($required_attrs); ?>
|
||||
required attributes. Then create any optional attributes. You
|
||||
can specify multi-valued attributes as well.</small><br />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<form action="create.php" method="post">
|
||||
<form action="create.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="step" value="2" />
|
||||
<input type="hidden" name="new_dn" value="<?php echo htmlspecialchars( $dn ); ?>" />
|
||||
<input type="hidden" name="new_rdn" value="<?php echo htmlspecialchars( $rdn ); ?>" />
|
||||
@ -139,7 +152,11 @@ if( $step == 2 )
|
||||
|
||||
<table class="edit_dn" cellspacing="0">
|
||||
<tr><th colspan="2">Required Attributes</th></tr>
|
||||
<?php foreach( $required_attrs as $count => $attr ) { ?>
|
||||
<?php if( count( $required_attrs ) == 0 ) {
|
||||
echo "<tr class=\"row1\"><td colspan=\"2\"><center>(none)</center></td></tr>\n";
|
||||
} else
|
||||
|
||||
foreach( $required_attrs as $count => $attr ) { ?>
|
||||
<?php if( $count % 2 == 0 ) { ?>
|
||||
<tr class="row1">
|
||||
<?php } else { ?>
|
||||
@ -150,7 +167,7 @@ if( $step == 2 )
|
||||
// is there a user-friendly translation available for this attribute?
|
||||
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) {
|
||||
$attr_display = "<acronym title=\"Alias for " . htmlspecialchars($attr) . "\">" .
|
||||
htmlspecialchars( $friendly_attrs[ strtolower( $attr ) ] ) . "</acronym>";
|
||||
htmlspecialchars( $friendly_attrs[ strtolower( $attr ) ] ) . "</acronym>";
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $attr );
|
||||
}
|
||||
@ -158,7 +175,7 @@ if( $step == 2 )
|
||||
echo $attr_display;
|
||||
|
||||
?></b></td>
|
||||
<td class="val"><input type="text"
|
||||
<td class="val"><input type="<?php echo (is_attr_binary( $server_id, $attr ) ? "file" : "text"); ?>"
|
||||
name="required_attrs[<?php echo htmlspecialchars($attr); ?>]"
|
||||
value="<?php echo $attr == $rdn_attr ? $rdn_value : '' ?>" size="40" />
|
||||
</tr>
|
||||
@ -166,16 +183,33 @@ if( $step == 2 )
|
||||
|
||||
<tr><th colspan="2">Optional Attributes</th></tr>
|
||||
|
||||
<?php for($i=0; $i<10; $i++ ) { ?>
|
||||
<?php if( count( $all_attrs ) == 0 ) { ?>
|
||||
<tr class="row1"><td colspan="2"><center>(none)</center></td></tr>
|
||||
<?php } else { ?>
|
||||
<?php for($i=0; $i<min( count( $all_attrs ), 10 ); $i++ ) { ?>
|
||||
<?php if( $i % 2 == 0 ) { ?>
|
||||
<tr class="row1">
|
||||
<?php } else { ?>
|
||||
<tr class="row2">
|
||||
<?php } ?>
|
||||
<td class="attr"><select name="attrs[<?php echo $i; ?>]"><?php echo $attr_select_html; ?></select></td>
|
||||
<td class="val"><input type="text" name="vals[<?php echo $i; ?>]" value="" size="40" />
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if( count( $binary_attrs ) > 0 ) { ?>
|
||||
<tr><th colspan="2">Optional Binary Attributes</th></tr>
|
||||
<?php for( $k=$i; $k<$i+count($binary_attrs); $k++ ) { $attr = $binary_attrs[$k]; ?>
|
||||
<?php if( $i % 2 == 0 ) { ?>
|
||||
<tr class="row1">
|
||||
<?php } else { ?>
|
||||
<tr class="row2">
|
||||
<?php } ?>
|
||||
<td class="attr"><select name="attrs[<?php echo $i; ?>]"><?php echo $attr_select_html; ?></select></td>
|
||||
<td class="val"><input type="text" name="vals[<?php echo $i; ?>]" value="" size="40" />
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<td class="attr"><select name="attrs[<?php echo $k; ?>]"><?php echo $binary_attr_select_html;?></select></td>
|
||||
<td class="val"><input type="file" name="vals[<?php echo $k; ?>]" value="" size="40" />
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<center>
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require 'common.php';
|
||||
|
||||
// customize this to your needs
|
||||
$default_container = "ou=Addresses";
|
||||
|
||||
// Common to all templates
|
||||
$container = stripslashes( $_POST['container'] );
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Unique to this template
|
||||
@ -65,8 +65,10 @@ function autoFillCommonName( form )
|
||||
<td><img src="images/uid.png" /></td>
|
||||
<td class="heading">Name:</td>
|
||||
<td>
|
||||
<input type="text" name="first_name" id="first_name" value="first" onChange="autoFillCommonName(this.form)" />
|
||||
<input type="text" name="last_name" id="last_name" value="last" onChange="autoFillCommonName(this.form)" />
|
||||
<input type="text" name="first_name"
|
||||
id="first_name" value="first" onChange="autoFillCommonName(this.form)" />
|
||||
<input type="text" name="last_name"
|
||||
id="last_name" value="last" onChange="autoFillCommonName(this.form)" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -136,18 +138,18 @@ function autoFillCommonName( form )
|
||||
|
||||
<?php } elseif( $step == 2 ) {
|
||||
|
||||
$common_name = trim( stripslashes( $_POST['common_name'] ) );
|
||||
$first_name = trim( stripslashes( $_POST['first_name'] ) );
|
||||
$last_name = trim( stripslashes( $_POST['last_name'] ) );
|
||||
$organization = trim( stripslashes( $_POST['organization'] ) );
|
||||
$city = trim( stripslashes( $_POST['city'] ) );
|
||||
$postal_code = trim( stripslashes( $_POST['postal_code'] ) );
|
||||
$street = trim( stripslashes( $_POST['street'] ) );
|
||||
$telephone_number = trim( stripslashes( $_POST['telephone_number'] ) );
|
||||
$fax_number = trim( stripslashes( $_POST['fax_number'] ) );
|
||||
$mobile_number = trim( stripslashes( $_POST['mobile_number'] ) );
|
||||
$email_address = trim( stripslashes( $_POST['email_address'] ) );
|
||||
$container = trim( stripslashes( $_POST['container'] ) );
|
||||
$common_name = trim( $_POST['common_name'] );
|
||||
$first_name = trim( $_POST['first_name'] );
|
||||
$last_name = trim( $_POST['last_name'] );
|
||||
$organization = trim( $_POST['organization'] );
|
||||
$city = trim( $_POST['city'] );
|
||||
$postal_code = trim( $_POST['postal_code'] );
|
||||
$street = trim( $_POST['street'] );
|
||||
$telephone_number = trim( $_POST['telephone_number'] );
|
||||
$fax_number = trim( $_POST['fax_number'] );
|
||||
$mobile_number = trim( $_POST['mobile_number'] );
|
||||
$email_address = trim( $_POST['email_address'] );
|
||||
$container = trim( $_POST['container'] );
|
||||
|
||||
/* Critical assertions */
|
||||
0 != strlen( $common_name ) or
|
||||
@ -191,20 +193,60 @@ function autoFillCommonName( form )
|
||||
|
||||
<center>
|
||||
<table class="confirm">
|
||||
<tr class="even"><td class="heading">Common name:</td><td><b><?php echo htmlspecialchars( $common_name ); ?></b></td></tr>
|
||||
<tr class="odd"><td class="heading">First name:</td><td><b><?php echo htmlspecialchars( $first_name ); ?></b></td></tr>
|
||||
<tr class="even"><td class="heading">Last name:</td><td><b><?php echo htmlspecialchars( $last_name ); ?></b></td></tr>
|
||||
<tr class="odd"><td class="heading">Organization:</td><td><?php echo htmlspecialchars( $organization ); ?></td></tr>
|
||||
<tr class="even"><td class="heading">City:</td><td><?php echo htmlspecialchars( $city ); ?></td></tr>
|
||||
<tr class="odd"><td class="heading">Postal code:</td><td><?php echo htmlspecialchars( $postal_code ); ?></td></tr>
|
||||
<tr class="even"><td class="heading">Street:</td><td><?php echo htmlspecialchars( $street ); ?></td></tr>
|
||||
<tr class="odd"><td class="heading">Work phone:</td><td><?php echo htmlspecialchars( $telephone_number ); ?></td></tr>
|
||||
<tr class="even"><td class="heading">Fax:</td><td><?php echo htmlspecialchars( $fax_number ); ?></td></tr>
|
||||
<tr class="odd"><td class="heading">Mobile:</td><td><?php echo htmlspecialchars( $mobile_number ); ?></td></tr>
|
||||
<tr class="even"><td class="heading">Email:</td><td><?php echo htmlspecialchars( $email_address ); ?></td></tr>
|
||||
<tr class="odd"><td class="heading">Container:</td><td><?php echo htmlspecialchars( $container ); ?></td></tr>
|
||||
<tr class="even">
|
||||
<td class="heading">Common name:</td>
|
||||
<td><b><?php echo htmlspecialchars( $common_name ); ?></b></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="heading">First name:</td>
|
||||
<td><b><?php echo htmlspecialchars( $first_name ); ?></b></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td class="heading">Last name:</td>
|
||||
<td><b><?php echo htmlspecialchars( $last_name ); ?></b></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="heading">Organization:</td>
|
||||
<td><?php echo htmlspecialchars( $organization ); ?></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td class="heading">City:</td>
|
||||
<td><?php echo htmlspecialchars( $city ); ?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="heading">Postal code:</td>
|
||||
<td><?php echo htmlspecialchars( $postal_code ); ?></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td class="heading">Street:</td>
|
||||
<td><?php echo htmlspecialchars( $street ); ?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="heading">Work phone:</td>
|
||||
<td><?php echo htmlspecialchars( $telephone_number ); ?></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td class="heading">Fax:</td>
|
||||
<td><?php echo htmlspecialchars( $fax_number ); ?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="heading">Mobile:</td>
|
||||
<td><?php echo htmlspecialchars( $mobile_number ); ?></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td class="heading">Email:</td>
|
||||
<td><?php echo htmlspecialchars( $email_address ); ?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="heading">Container:</td>
|
||||
<td><?php echo htmlspecialchars( $container ); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br /><input type="submit" value="Create Address" />
|
||||
</center>
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require 'common.php';
|
||||
|
||||
// Common to all templates
|
||||
$container = stripslashes( $_POST['container'] );
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Unique to this template
|
||||
@ -40,7 +40,7 @@ if( ! $step )
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Container <acronym title="Distinguished Name">DN</acronym>:</td>
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars( utf8_decode( $container ) ); ?>" />
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars( $container ); ?>" />
|
||||
<?php draw_chooser_link( 'dns_form.container' ); ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
@ -52,9 +52,9 @@ if( ! $step )
|
||||
|
||||
<?php } elseif( $step == 2 ) {
|
||||
|
||||
$dc_name = trim( stripslashes( $_POST['dc_name'] ) );
|
||||
$container = trim( stripslashes( $_POST['container'] ) );
|
||||
$associateddomain = trim( stripslashes( $_POST['associateddomain'] ) );
|
||||
$dc_name = trim( $_POST['dc_name'] );
|
||||
$container = trim( $_POST['container'] );
|
||||
$associateddomain = trim( $_POST['associateddomain'] );
|
||||
|
||||
dn_exists( $server_id, $container ) or
|
||||
pla_error( "The container you specified (" . htmlspecialchars( $container ) . ") does not exist. " .
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require 'common.php';
|
||||
|
||||
// Common to all templates
|
||||
$container = stripslashes( $_POST['container'] );
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ have_auth_info( $server_id ) or pla_error( "Not enough information to login to s
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Container:</td>
|
||||
<td><input type="text" size="40" name="container" value="<?php echo htmlspecialchars( utf8_decode( $container ) ); ?>" />
|
||||
<td><input type="text" size="40" name="container" value="<?php echo htmlspecialchars( $container ); ?>" />
|
||||
<?php draw_chooser_link( 'machine_form.container' ); ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
@ -67,7 +67,7 @@ have_auth_info( $server_id ) or pla_error( "Not enough information to login to s
|
||||
<li>gidNumber <b><?php echo htmlspecialchars( $default_gid_number ); ?></b></li>
|
||||
<li>acctFlags <b><?php echo str_replace(' ', " ", htmlspecialchars($default_acct_flags)); ?></b></li>
|
||||
<li>cn <b><?php echo htmlspecialchars($default_cn); ?></b></li>
|
||||
<li>in container <b><?php echo htmlspecialchars($container); ?></b></li>
|
||||
<li>in container <b><?php echo htmlspecialchars( $container ); ?></b></li>
|
||||
</ul>
|
||||
To change these values, edit the template file:
|
||||
<code>templates/creation/new_nt_machine.php</code><br />
|
||||
@ -81,8 +81,8 @@ have_auth_info( $server_id ) or pla_error( "Not enough information to login to s
|
||||
|
||||
<?php } elseif( $step == 2 ) {
|
||||
|
||||
$machine_name = trim( stripslashes( $_POST['machine_name'] ) );
|
||||
$uid_number = trim( stripslashes( $_POST['uid_number'] ) );
|
||||
$machine_name = trim( $_POST['machine_name'] );
|
||||
$uid_number = trim( $_POST['uid_number'] );
|
||||
|
||||
dn_exists( $server_id, $container ) or
|
||||
pla_error( "The container you specified (" . htmlspecialchars( $container ) . ") does not exist. " .
|
||||
@ -94,7 +94,7 @@ have_auth_info( $server_id ) or pla_error( "Not enough information to login to s
|
||||
<input type="hidden" name="new_dn" value="<?php echo htmlspecialchars( 'uid=' . $machine_name . '$,' . $container ); ?>" />
|
||||
|
||||
<!-- ObjectClasses -->
|
||||
<?php $object_classes = rawurlencode( serialize( array( 'top', 'sambaAccount', 'posixAccount' ) ) ); ?>
|
||||
<?php $object_classes = rawurlencode( serialize( array( 'top', 'sambaAccount', 'posixAccount', 'account' ) ) ); ?>
|
||||
|
||||
<input type="hidden" name="object_classes" value="<?php echo $object_classes; ?>" />
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require 'common.php';
|
||||
|
||||
// Common to all templates
|
||||
$container = stripslashes( $_POST['container'] );
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Unique to this template
|
||||
@ -35,7 +35,7 @@ have_auth_info( $server_id ) or pla_error( "Not enough information to login to s
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Container <acronym title="Distinguished Name">DN</acronym>:</td>
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars( utf8_decode( $container ) ); ?>" />
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars( $container ); ?>" />
|
||||
<?php draw_chooser_link( 'ou_form.container' ); ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
@ -47,8 +47,8 @@ have_auth_info( $server_id ) or pla_error( "Not enough information to login to s
|
||||
|
||||
<?php } elseif( $step == 2 ) {
|
||||
|
||||
$ou_name = trim( stripslashes( $_POST['ou_name'] ) );
|
||||
$container = trim( stripslashes( $_POST['container'] ) );
|
||||
$ou_name = trim( $_POST['ou_name'] );
|
||||
$container = trim( $_POST['container'] );
|
||||
|
||||
dn_exists( $server_id, $container ) or
|
||||
pla_error( "The container you specified (" . htmlspecialchars( $container ) . ") does not exist. " .
|
||||
|
117
templates/creation/new_posix_group_template.php
Normal file
117
templates/creation/new_posix_group_template.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
require 'common.php';
|
||||
|
||||
// Common to all templates
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Change this to suit your needs
|
||||
$default_number_of_users = 10;
|
||||
|
||||
$step = $_POST['step'];
|
||||
if( ! $step )
|
||||
$step = 1;
|
||||
|
||||
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." );
|
||||
|
||||
?>
|
||||
|
||||
<center><h2>New Posix Group</h2></center>
|
||||
|
||||
<?php if( $step == 1 ) { ?>
|
||||
|
||||
<form action="creation_template.php" method="post" name="posix_group_form">
|
||||
<input type="hidden" name="step" value="2" />
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="template" value="<?php echo htmlspecialchars( $_POST['template'] ); ?>" />
|
||||
|
||||
<center>
|
||||
<table class="confirm">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Posix Group Name:</td>
|
||||
<td><input type="text" name="posix_group_name" value="" /> <small>(example: MyGroup, do not include "cn=")</small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading"><acronym title="Group Identification">GID</acronym> Number:</td>
|
||||
<td><input type="text" name="gid_number" value="" /> <small>(example: 2000)</small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Container <acronym title="Distinguished Name">DN</acronym>:</td>
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars( $container ); ?>" />
|
||||
<?php draw_chooser_link( 'posix_group_form.container' ); ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Users:</td>
|
||||
<td><input type="text" name="member_uids[]" value="" /> <small>(example: dsmith)</small><br />
|
||||
<?php for( $i=1; $i<$default_number_of_users; $i++ ) { ?>
|
||||
<input type="text" name="member_uids[]" value="" /><br />
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"><center><br /><input type="submit" value="Proceed >>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<?php } elseif( $step == 2 ) {
|
||||
|
||||
$group_name = trim( $_POST['posix_group_name'] );
|
||||
$container = trim( $_POST['container'] );
|
||||
$gid_number = trim( $_POST['gid_number'] );
|
||||
$uids = $_POST['member_uids'];
|
||||
$member_uids = array();
|
||||
foreach( $uids as $uid )
|
||||
if( '' != trim( $uid ) && ! in_array( $uid, $member_uids ) )
|
||||
$member_uids[] = $uid;
|
||||
|
||||
dn_exists( $server_id, $container ) or
|
||||
pla_error( "The container you specified (" . htmlspecialchars( $container ) . ") does not exist. " .
|
||||
"Please go back and try again." );
|
||||
|
||||
?>
|
||||
<form action="create.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="new_dn" value="<?php echo htmlspecialchars( 'cn='.$group_name.','.$container ); ?>" />
|
||||
|
||||
<!-- ObjectClasses -->
|
||||
<?php $object_classes = rawurlencode( serialize( array( 'top', 'posixGroup' ) ) ); ?>
|
||||
|
||||
<input type="hidden" name="object_classes" value="<?php echo $object_classes; ?>" />
|
||||
|
||||
<!-- The array of attributes/values -->
|
||||
<input type="hidden" name="attrs[]" value="cn" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($posix_group_name);?>" />
|
||||
<input type="hidden" name="attrs[]" value="gidNumber" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($gid_number);?>" />
|
||||
<?php foreach( $member_uids as $uid ) { ?>
|
||||
<input type="hidden" name="attrs[]" value="memberUid" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($uid);?>" />
|
||||
<?php } ?>
|
||||
|
||||
<center>
|
||||
Really create this new Posix Group entry?<br />
|
||||
<br />
|
||||
|
||||
<table class="confirm">
|
||||
<tr class="even"><td>Name</td><td><b><?php echo htmlspecialchars($group_name); ?></b></td></tr>
|
||||
<tr class="odd"><td>Container</td><td><b><?php echo htmlspecialchars( $container ); ?></b></td></tr>
|
||||
<tr class="even"><td>gidNumber</td><td><b><?php echo htmlspecialchars( $gid_number ); ?></b></td></tr>
|
||||
<tr class="odd"><td>Member UIDs</td><td><b>
|
||||
<?php foreach( $member_uids as $i => $uid )
|
||||
echo htmlspecialchars($uid) . "<br />"; ?>
|
||||
</b></td></tr>
|
||||
</table>
|
||||
<br /><input type="submit" value="Create Group" />
|
||||
</center>
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
||||
|
276
templates/creation/new_smbuser_template.php
Normal file
276
templates/creation/new_smbuser_template.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
require realpath( 'common.php' );
|
||||
|
||||
// customize this to your needs
|
||||
$default_samba_sid = "S-1-5-21-3509297442-4087397136-3591104989";
|
||||
$default_container = "ou=Users";
|
||||
$default_home = "/export/home";
|
||||
$mkntpwdCommand = "./templates/creation/mkntpwd";
|
||||
|
||||
// Common to all templates
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Unique to this template
|
||||
$step = $_POST['step'];
|
||||
if( ! $step )
|
||||
$step = 1;
|
||||
|
||||
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." );
|
||||
?>
|
||||
|
||||
<script language="javascript">
|
||||
<!--
|
||||
function autoFillUserName( form ) {
|
||||
var first_name;
|
||||
var last_name;
|
||||
var user_name;
|
||||
|
||||
first_name = form.first_name.value.toLowerCase();
|
||||
last_name = form.last_name.value.toLowerCase();
|
||||
if( last_name == '' ) {
|
||||
return false;
|
||||
}
|
||||
user_name = first_name.substr( 0,1 ) + last_name;
|
||||
user_name = first_name.substr( 0,8 );
|
||||
|
||||
form.user_name.value = user_name;
|
||||
autoFillHomeDir( form );
|
||||
}
|
||||
function autoFillHomeDir( form ){
|
||||
var user_name;
|
||||
var home_dir;
|
||||
|
||||
user_name = form.user_name.value.toLowerCase();
|
||||
|
||||
home_dir = '<?php echo $default_home; ?>/';
|
||||
home_dir += user_name;
|
||||
form.home_dir.value = home_dir;
|
||||
|
||||
}
|
||||
function autoFillSambaSID( form ){
|
||||
var sambaSID;
|
||||
var uidNumber;
|
||||
|
||||
uidNumber = form.uid_number.value;
|
||||
sambaSID = '<?php echo $default_samba_sid; ?>-'+(2*uidNumber+1000);
|
||||
|
||||
form.samba_sid.value = sambaSID;
|
||||
|
||||
}
|
||||
-->
|
||||
</script>
|
||||
|
||||
<center><h2>New Samba3-User Account</h2></center>
|
||||
|
||||
<?php if( $step == 1 ) { ?>
|
||||
|
||||
<form action="creation_template.php" method="post" id="user_form" name="user_form">
|
||||
<input type="hidden" name="step" value="2" />
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="template" value="<?php echo $_POST['template']; ?>" />
|
||||
|
||||
<center>
|
||||
<table class="confirm">
|
||||
<tr class="spacer"><td colspan="3"></tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">UID Number:</td>
|
||||
<td><input type="text" name="uid_number" value="" onChange="autoFillSambaSID(this.form)" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading"><i>Samba SID:</i></td>
|
||||
<td><input type="text" name="samba_sid" value="" id="samba_sid" readonly=""/></td>
|
||||
</tr>
|
||||
<tr class="spacer"><td colspan="3"></tr>
|
||||
<tr>
|
||||
<td><img src="images/uid.png" /></td>
|
||||
<td class="heading">First name:</td>
|
||||
<td><input type="text" name="first_name" id="first_name" value="" onChange="autoFillUserName(this.form)" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Last name:</td>
|
||||
<td><input type="text" name="last_name" id="last_name" value="" onChange="autoFillUserName(this.form)" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">User name:</td>
|
||||
<td><input type="text" name="user_name" id="user_name" value=""
|
||||
onChange="autoFillHomeDir(this.form)" onExit="autoFillHomeDir(this.form)" /></td>
|
||||
</tr>
|
||||
<tr class="spacer"><td colspan="3"></tr>
|
||||
<tr>
|
||||
<td><img src="images/lock.png" /></td>
|
||||
<td class="heading">Password:</td>
|
||||
<td><input type="password" name="user_pass1" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Password:</td>
|
||||
<td><input type="password" name="user_pass2" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Encryption:</td>
|
||||
<td>
|
||||
<input type="hidden" name="encryption" value="crypt"/>
|
||||
<i>crypt</i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="spacer"><td colspan="3"></tr>
|
||||
<tr>
|
||||
<td><img src="images/nt.png" /></td>
|
||||
<td class="heading">Login Shell:</td>
|
||||
<td>
|
||||
<input type="hidden" name="login_shell" value="/bin/csh"/>
|
||||
<i>/bin/csh</i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Container:</td>
|
||||
<td><input type="text" name="container" size="40"
|
||||
value="<?php if( isset( $container ) )
|
||||
echo htmlspecialchars( $container );
|
||||
else
|
||||
echo htmlspecialchars( $default_container . ',' . $servers[$server_id]['base'] ); ?>" />
|
||||
<?php draw_chooser_link( 'user_form.container' ); ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Unix Group:</td>
|
||||
<td><select name="group">
|
||||
<option value="1000">admins (1000)</option>
|
||||
<option value="2000">users (2000)</option>
|
||||
<option value="3000">staff (3000)</option>
|
||||
<option value="5000">guest (5000)</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Windows Group:</td>
|
||||
<td><select name="sambaPrimaryGroupSID">
|
||||
<option value="S-1-5-32-547">Local Power Users</option>
|
||||
<option value="S-1-5-32-544">Local Administrator</option>
|
||||
<option value="S-1-5-32-545">Local Users</option>
|
||||
<option value="<?php echo $default_samba_sid; ?>-512">Domain Admins</option>
|
||||
<option value="<?php echo $default_samba_sid; ?>-513">Domain Users</option>
|
||||
<option value="<?php echo $default_samba_sid; ?>-514">Domain Guests</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Home Directory:</td>
|
||||
<td><input type="text" name="home_dir" value="<?php echo $default_home ?>" id="home_dir" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"><center><br /><input type="submit" value="Proceed >>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<?php } elseif( $step == 2 ) {
|
||||
|
||||
$user_name = trim( stripslashes( $_POST['user_name'] ) );
|
||||
$first_name = trim( stripslashes( $_POST['first_name'] ) );
|
||||
$last_name = trim( stripslashes( $_POST['last_name'] ) );
|
||||
$password1 = stripslashes( $_POST['user_pass1'] );
|
||||
$password2 = stripslashes( $_POST['user_pass2'] );
|
||||
$encryption = stripslashes( $_POST['encryption'] );
|
||||
$login_shell = trim( stripslashes( $_POST['login_shell'] ) );
|
||||
$uid_number = trim( stripslashes( $_POST['uid_number'] ) );
|
||||
$gid_number = trim( stripslashes( $_POST['group'] ) );
|
||||
$container = trim( stripslashes( $_POST['container'] ) );
|
||||
$home_dir = trim( stripslashes( $_POST['home_dir'] ) );
|
||||
|
||||
$samba_sid = trim( stripslashes( $_POST['samba_sid'] ) );
|
||||
|
||||
/* Critical assertions */
|
||||
$password1 == $password2 or
|
||||
pla_error( "Your passwords don't match. Please go back and try again." );
|
||||
0 != strlen( $uid_number ) or
|
||||
pla_error( "You cannot leave the UID number blank. Please go back and try again." );
|
||||
is_numeric( $uid_number ) or
|
||||
pla_error( "You can only enter numeric values for the UID number field. Please go back and try again." );
|
||||
dn_exists( $server_id, $container ) or
|
||||
pla_error( "The container you specified (" . htmlspecialchars( $container ) . ") does not exist. " .
|
||||
"Please go back and try again." );
|
||||
|
||||
$password = password_hash( $password1, $encryption );
|
||||
|
||||
$sambaPassCommand = $mkntpwdCommand . " " . $password1;
|
||||
$sambaPassCommandOutput = shell_exec($sambaPassCommand);
|
||||
$sambaLMPassword = substr($sambaPassCommandOutput,0,strPos($sambaPassCommandOutput,':'));
|
||||
$sambaNTPassword = substr($sambaPassCommandOutput,strPos($sambaPassCommandOutput,':')+1);
|
||||
?>
|
||||
<center><h3>Confirm account creation:</h3></center>
|
||||
|
||||
<form action="create.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="new_dn" value="<?php echo htmlspecialchars( 'uid=' . $user_name . ',' . $container ); ?>" />
|
||||
|
||||
<!-- ObjectClasses -->
|
||||
<?php $object_classes = rawurlencode( serialize( array( 'top', 'account', 'posixAccount', 'shadowAccount' , 'sambaSamAccount' ) ) ); ?>
|
||||
|
||||
<input type="hidden" name="object_classes" value="<?php echo $object_classes; ?>" />
|
||||
|
||||
<!-- The array of attributes/values -->
|
||||
<input type="hidden" name="attrs[]" value="cn" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($first_name);?>" />
|
||||
<input type="hidden" name="attrs[]" value="displayName" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($first_name . ' ' . $last_name);?>" />
|
||||
<input type="hidden" name="attrs[]" value="gecos" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($first_name . ' ' . $last_name);?>" />
|
||||
<input type="hidden" name="attrs[]" value="gidNumber" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($gid_number);?>" />
|
||||
<input type="hidden" name="attrs[]" value="homeDirectory" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($home_dir);?>" />
|
||||
<input type="hidden" name="attrs[]" value="loginShell" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($login_shell);?>" />
|
||||
<input type="hidden" name="attrs[]" value="sambaAcctFlags" />
|
||||
<input type="hidden" name="vals[]" value="[U ]" />
|
||||
<input type="hidden" name="attrs[]" value="sambaLMPassword" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($sambaLMPassword);?>" />
|
||||
<input type="hidden" name="attrs[]" value="sambaNTPassword" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($sambaNTPassword);?>" />
|
||||
<input type="hidden" name="attrs[]" value="sambaPrimaryGroupSID" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($sambaPrimaryGroupSID);?>" />
|
||||
<input type="hidden" name="attrs[]" value="sambaPwdCanChange" />
|
||||
<input type="hidden" name="vals[]" value="0" />
|
||||
<input type="hidden" name="attrs[]" value="sambaPwdLastSet" />
|
||||
<input type="hidden" name="vals[]" value="0" />
|
||||
<input type="hidden" name="attrs[]" value="sambaPwdMustChange" />
|
||||
<input type="hidden" name="vals[]" value="2147483647" />
|
||||
|
||||
<input type="hidden" name="attrs[]" value="sambaSID" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($samba_sid); ?>" />
|
||||
|
||||
|
||||
<input type="hidden" name="attrs[]" value="shadowLastChange" />
|
||||
<input type="hidden" name="vals[]" value="11778" />
|
||||
<input type="hidden" name="attrs[]" value="uid" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($user_name);?>" />
|
||||
<input type="hidden" name="attrs[]" value="uidNumber" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($uid_number);?>" />
|
||||
<input type="hidden" name="attrs[]" value="userPassword" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($password);?>" />
|
||||
|
||||
<center>
|
||||
<table class="confirm">
|
||||
<tr class="even"><td class="heading">User name:</td><td><b><?php echo htmlspecialchars( $user_name ); ?></b></td></tr>
|
||||
<tr class="odd"><td class="heading">First name:</td><td><b><?php echo htmlspecialchars( $first_name ); ?></b></td></tr>
|
||||
<tr class="even"><td class="heading">Last name:</td><td><b><?php echo htmlspecialchars( $last_name ); ?></b></td></tr>
|
||||
<tr class="odd"><td class="heading">Password:</td><td>[secret]</td></tr>
|
||||
<tr class="even"><td class="heading">Login Shell:</td><td><?php echo htmlspecialchars( $login_shell); ?></td></tr>
|
||||
<tr class="odd"><td class="heading">UID Number:</td><td><?php echo htmlspecialchars( $uid_number ); ?></td></tr>
|
||||
<tr class="even"><td class="heading">GID Number:</td><td><?php echo htmlspecialchars( $gid_number ); ?></td></tr>
|
||||
<tr class="odd"><td class="heading">Container:</td><td><?php echo htmlspecialchars( $container ); ?></td></tr>
|
||||
<tr class="even"><td class="heading">Home dir:</td><td><?php echo htmlspecialchars( $home_dir ); ?></td></tr>
|
||||
</table>
|
||||
<br /><input type="submit" value="Create Account" />
|
||||
</center>
|
||||
|
||||
<?php } ?>
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require 'common.php';
|
||||
|
||||
// customize this to your needs
|
||||
$default_container = "ou=People";
|
||||
|
||||
// Common to all templates
|
||||
$container = stripslashes( $_POST['container'] );
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Unique to this template
|
||||
|
155
tree.php
155
tree.php
@ -11,8 +11,7 @@
|
||||
* tree.php#3_dc%3Dexample%2Cdc%3Dcom
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
// no expire header stuff
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
@ -42,29 +41,26 @@ $tree_icons = $_SESSION['tree_icons'];
|
||||
<body>
|
||||
|
||||
<?php
|
||||
$group_id = "61828";
|
||||
$bug_atid = "498546";
|
||||
$rfe_atid = "498549";
|
||||
$bug_href = "http://sourceforge.net/tracker/?func=add&group_id=$group_id&atid=$bug_atid";
|
||||
$open_bugs_href = "http://sourceforge.net/tracker/?group_id=$group_id&atid=$bug_atid";
|
||||
$feature_href = "http://sourceforge.net/tracker/?func=add&group_id=$group_id&atid=$rfe_atid";
|
||||
$open_features_href = "http://sourceforge.net/tracker/?atid=$rfe_atid&group_id=$group_id&func=browse";
|
||||
$bug_href = get_href( 'add_bug' );
|
||||
$open_bugs_href = get_href( 'open_bugs' );
|
||||
$feature_href = get_href( 'add_rfe' );
|
||||
$open_features_href = get_href( 'open_rfes' );
|
||||
?>
|
||||
|
||||
<h3 class="subtitle" style="margin:0px">phpLDAPAdmin - <?php echo pla_version(); ?></h3>
|
||||
<h3 class="subtitle" style="margin:0px">phpLDAPadmin - <?php echo pla_version(); ?></h3>
|
||||
<table class="edit_dn_menu">
|
||||
<tr>
|
||||
<td><img src="images/light.png" /></td>
|
||||
<td><a href="<?php echo $feature_href; ?>" target="new">Request a new feature</a>
|
||||
(<a href="<?php echo $open_features_href; ?>" target="new">see open requests</a>)</td>
|
||||
<td><nobr><a href="<?php echo $feature_href; ?>" target="new"><?php echo $lang['request_new_feature']; ?></a>
|
||||
(<a href="<?php echo $open_features_href; ?>" target="new"><?php echo $lang['see_open_requests']; ?></a>)</nobr></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images/bug.png" /></td>
|
||||
<td><a href="<?php echo $bug_href; ?>" target="new">Report a bug</a>
|
||||
(<a href="<?php echo $open_bugs_href; ?>" target="new">see open bugs</a>)</td>
|
||||
<td><nobr><a href="<?php echo $bug_href; ?>" target="new"><?php echo $lang['report_bug']; ?></a>
|
||||
(<a href="<?php echo $open_bugs_href; ?>" target="new"><?php echo $lang['see_open_bugs']; ?></a>)</nobr></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
<table class="tree" cellspacing="0">
|
||||
|
||||
<?php
|
||||
@ -76,8 +72,9 @@ foreach( $servers as $server_id => $server_tree ) {
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
echo '<tr class="server">';
|
||||
echo '<td class="icon"><img src="images/server.png" alt="server"/></td>';
|
||||
echo '<td colspan="99"><b><a name="' . $id . '">' . htmlspecialchars( $server_name ) . '</a></b><br />';
|
||||
|
||||
echo '<td colspan="99"><a name="' . $server_id . '"></a>';
|
||||
echo '<nobr>' . htmlspecialchars( $server_name ) . '</nobr></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// do we have what it takes to authenticate here, or do we need to
|
||||
// present the user with a login link (for 'form' auth_types)?
|
||||
@ -90,28 +87,40 @@ foreach( $servers as $server_id => $server_tree ) {
|
||||
rawurlencode( $servers[$server_id]['base'] );
|
||||
$logout_href = 'logout.php?server_id=' . $server_id;
|
||||
$info_href = 'server_info.php?server_id=' . $server_id;
|
||||
$import_href = 'ldif_import_form.php?server_id=' . $server_id;
|
||||
|
||||
if( $servers[$server_id]['auth_type'] == 'form' && have_auth_info( $server_id ) )
|
||||
echo "<small><nobr>Logged in as: " . htmlspecialchars(get_logged_in_dn($server_id)) . "</small></nobr><br />";
|
||||
|
||||
// Draw the quick-links below the server name:
|
||||
// ( schema | search | refresh | create )
|
||||
echo '<small>(';
|
||||
echo '<a title="View schema for ' . $server_name . '"'.
|
||||
' href="' . $schema_href . '">schema</a> | ';
|
||||
echo '<a title="Search ' . $server_name . ' for entries"'.
|
||||
' href="' . $search_href . '">search</a> | ';
|
||||
echo '<a title="Re-query ' . $server_name . ' to refresh all expanded containers"'.
|
||||
' href="' . $refresh_href . '">refresh</a> | ';
|
||||
echo '<a title="Create a new entry on ' . $server_name . '"'.
|
||||
echo '<tr><td colspan="100" class="links">';
|
||||
echo '<nobr>';
|
||||
echo '( ';
|
||||
echo '<a title="' . $lang['view_schema_for'] . ' ' . $server_name . '"'.
|
||||
' href="' . $schema_href . '">' . $lang['schema'] . '</a> | ';
|
||||
echo '<a title="' . $lang['search'] . ' ' . $server_name . '"' .
|
||||
' href="' . $search_href . '">' . $lang['search'] . '</a> | ';
|
||||
echo '<a title="' . $lang['refresh_expanded_containers'] . ' ' . $server_name . '"'.
|
||||
' href="' . $refresh_href . '">' . $lang['refresh'] . '</a> | ';
|
||||
echo '<a title="' . $lang['create_new_entry_on'] . ' ' . $server_name . '"'.
|
||||
' href="' . $create_href . '" target="right_frame">create</a> | ';
|
||||
echo '<a title="View server-supplied information" target="right_frame"'.
|
||||
'href="' . $info_href . '">info</a>';
|
||||
echo '<a title="' . $lang['view_server_info'] . '" target="right_frame"'.
|
||||
'href="' . $info_href . '">' . $lang['info'] . '</a> | ';
|
||||
echo '<a title="' . $lang['import_from_ldif'] . '" target="right_frame"' .
|
||||
'href="' . $import_href .'">' . $lang['import'] . '</a>';
|
||||
if( $servers[ $server_id ][ 'auth_type' ] == 'form' )
|
||||
echo ' | <a title="Logout of this server" href="' . $logout_href . '" target="right_frame">logout</a>';
|
||||
echo ')</small></td></tr>';
|
||||
echo ' | <a title="' . $lang['logout_of_this_server'] . '" href="' . $logout_href .
|
||||
'" target="right_frame">' . $lang['logout'] . '</a>';
|
||||
echo ' )</nobr></td></tr>';
|
||||
|
||||
if( $servers[$server_id]['auth_type'] == 'form' && have_auth_info( $server_id ) )
|
||||
echo "<tr><td class=\"links\" colspan=\"100\"><nobr>" .
|
||||
$lang['logged_in_as'] . htmlspecialchars(get_logged_in_dn($server_id)) .
|
||||
"</nobr></td></tr>";
|
||||
if( is_server_read_only( $server_id ) )
|
||||
echo "<tr><td class=\"links\" colspan=\"100\"><nobr>" .
|
||||
"(" . $lang['read_only'] . ")</nobr></td></tr>";
|
||||
|
||||
$rdn = utf8_decode( $dn );
|
||||
// Fetch and display the base DN for this server
|
||||
//$rdn = utf8_decode( $dn );
|
||||
if( null == $servers[ $server_id ]['base'] ) {
|
||||
$base_dn = try_to_get_root_dn( $server_id );
|
||||
} else {
|
||||
@ -134,26 +143,32 @@ foreach( $servers as $server_id => $server_tree ) {
|
||||
$edit_href = "edit.php?server_id=$server_id&dn=" . rawurlencode( $base_dn );
|
||||
|
||||
$icon = get_icon( $server_id, $base_dn );
|
||||
echo "<tr><td class=\"spacer\"></td>\n";
|
||||
echo "<td class=\"expander\"><a href=\"$expand_href\"><img src=\"$expand_img\" /></td>";
|
||||
echo "<td class=\"icon\"><a href=\"$edit_href\" target=\"right_frame\"><img src=\"images/$icon\" /></a></td>\n";
|
||||
echo "<td class=\"rdn\" colspan=\"99\"><nobr><a href=\"$edit_href\" " .
|
||||
"target=\"right_frame\">$base_dn</nobr></td>\n";
|
||||
echo "<td class=\"expander\" style=\"text-align: right\">";
|
||||
echo "<a href=\"$expand_href\"><img src=\"$expand_img\" /></td>";
|
||||
echo "<td class=\"icon\"><a href=\"$edit_href\" target=\"right_frame\">";
|
||||
echo "<img src=\"images/$icon\" /></a></td>\n";
|
||||
echo "<td class=\"rdn\" colspan=\"98\"><nobr><a href=\"$edit_href\" ";
|
||||
echo " target=\"right_frame\">$base_dn</nobr></td>\n";
|
||||
echo "</tr>\n";
|
||||
} else {
|
||||
if( "" === $base_dn || null === $base_dn ) {
|
||||
// The server refuses to give out the base dn
|
||||
echo "<tr><td class=\"spacer\"></td><td colspan=\"99\"><small>Could not determine ";
|
||||
echo "the root of your LDAP tree.<br />It appears that the LDAP server has ";
|
||||
echo "been <b>configured to not give it out</b>. Please specify it in config.php";
|
||||
echo "</small></td></tr>";
|
||||
echo "<tr><td class=\"spacer\"></td><td colspan=\"98\"><small><nobr>";
|
||||
echo $lang['could_not_determine_root'];
|
||||
echo '<br />';
|
||||
echo $lang['ldap_refuses_to_give_root'];
|
||||
echo '<br />';
|
||||
echo $lang['please_specify_in_config'];
|
||||
echo "</small></nobr></td></tr>";
|
||||
// Proceed to the next server. We cannot draw anything else for this server.
|
||||
continue;
|
||||
} else {
|
||||
// For some unknown reason, we couldn't determine the base dn
|
||||
echo "<tr><td class=\"spacer\"></td><td colspan=\"99\"><small>Could not determine ";
|
||||
echo "the root of your LDAP tree.<br />Please specify it in config.php";
|
||||
echo "</small></td></tr>";
|
||||
echo "<tr><td class=\"spacer\"></td><td colspan=\"99\"><small><nobr>";
|
||||
echo $lang['could_not_determine_root'];
|
||||
echo '<br />';
|
||||
echo $lang['please_specify_in_config'];
|
||||
echo "</small></nobr></td></tr>";
|
||||
// Proceed to the next server. We cannot draw anything else for this server.
|
||||
continue;
|
||||
}
|
||||
@ -164,31 +179,38 @@ foreach( $servers as $server_id => $server_tree ) {
|
||||
// Is the root of the tree expanded already?
|
||||
if( isset( $tree[$server_id][$base_dn] ) ) {
|
||||
foreach( $tree[ $server_id ][ $base_dn ] as $child_dn )
|
||||
draw_tree_html( $child_dn, $server_id, 1 );
|
||||
echo '<td class="spacer"></td>';
|
||||
echo '<td class="spacer"></td>';
|
||||
echo '<td class="icon"><a href="' . $create_href .
|
||||
'" target="right_frame"><img src="images/star.png" /></a></td>';
|
||||
echo '<td class="create" colspan="99"><a href="' . $create_href .
|
||||
'" target="right_frame" title="Create a new object in '. $base_dn.'">Create New</a></td></tr>';
|
||||
draw_tree_html( $child_dn, $server_id, 0 );
|
||||
if( ! is_server_read_only( $server_id ) ) {
|
||||
echo '<td class="spacer"></td>';
|
||||
echo '<td class="icon"><a href="' . $create_href .
|
||||
'" target="right_frame"><img src="images/star.png" /></a></td>';
|
||||
echo '<td class="create" colspan="100"><a href="' . $create_href .
|
||||
'" target="right_frame" title="' . $lang['create_new_entry_in'] . ' ' .
|
||||
$base_dn.'">' . $lang['create_new'] . '</a></td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else // have_auth_info() returned false.
|
||||
{
|
||||
// We don't have enough information to login to this server
|
||||
// Draw the "login..." link
|
||||
$login_href = "login_form.php?server_id=$server_id";
|
||||
echo '<tr class="login"><td colspan="100">';
|
||||
echo ' <a href="' . $login_href . '" target="right_frame">';
|
||||
echo '<img src="images/uid.png" align="top" alt="login"/></a> ';
|
||||
echo '<a href="' . $login_href . '" target="right_frame">login...</a>';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</table>
|
||||
<?php
|
||||
//echo "<pre>"; print_r( $tree );
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -201,7 +223,7 @@ exit;
|
||||
*/
|
||||
function draw_tree_html( $dn, $server_id, $level=0 )
|
||||
{
|
||||
global $servers, $tree, $tree_icons;
|
||||
global $servers, $tree, $tree_icons, $lang;
|
||||
$id = $server_id;
|
||||
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
@ -214,41 +236,41 @@ function draw_tree_html( $dn, $server_id, $level=0 )
|
||||
$tree_icons[ $server_id ][ $dn ] = get_icon( $server_id, $dn );
|
||||
$img_src = 'images/' . $tree_icons[ $server_id ][ $dn ];
|
||||
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = utf8_decode( $rdn[0] );
|
||||
$rdn = pla_explode_dn( $dn );
|
||||
$rdn = $rdn[0];
|
||||
|
||||
echo '<tr>';
|
||||
|
||||
for( $i=0; $i<=$level; $i++ ) {
|
||||
echo '<td class="spacer"></td>';
|
||||
echo '<td class="spacer"></td>' . "\n";
|
||||
}
|
||||
|
||||
// is this node expanded?
|
||||
// is this node expanded? (deciding whether to draw "+" or "-")
|
||||
if( isset( $tree[$server_id][$dn] ) ) { ?>
|
||||
<td class="expander">
|
||||
<nobr>
|
||||
<a href="<?php echo $collapse_href; ?>"><img src="images/minus.png" alt="plus" /></a>
|
||||
</nobr>
|
||||
</td>
|
||||
<?php $object_count = ' <span class="count">(' . count( $tree[$server_id][$dn] ) . ')</span>'; ?>
|
||||
<?php } else { ?>
|
||||
<?php $object_count = ' <span class="count">(' . count( $tree[$server_id][$dn] ) . ')</span>';
|
||||
} else { ?>
|
||||
<td class="expander">
|
||||
<nobr>
|
||||
<a href="<?php echo $expand_href; ?>"><img src="images/plus.png" alt="minus" /></a>
|
||||
</nobr>
|
||||
</td>
|
||||
<?php $object_count = ''; ?>
|
||||
<?php } ?>
|
||||
<?php $object_count = '';
|
||||
} ?>
|
||||
|
||||
<td class="icon">
|
||||
<a href="<?php echo $edit_href; ?>"
|
||||
target="right_frame"
|
||||
name="<?php echo $server_id; ?>_<?php echo $encoded_dn; ?>"><img src="<?php echo $img_src; ?>" /></a>
|
||||
</td>
|
||||
<td class="rdn" colspan="99">
|
||||
<td class="rdn" colspan="<?php echo (97-$level); ?>">
|
||||
<nobr>
|
||||
<a href="<?php echo $edit_href; ?>"
|
||||
target="right_frame"><?php echo htmlspecialchars($rdn); ?></a>
|
||||
target="right_frame"><?php echo htmlspecialchars( utf8_decode( $rdn ) ); ?></a>
|
||||
<?php echo $object_count; ?>
|
||||
</nobr>
|
||||
</td>
|
||||
@ -270,8 +292,9 @@ function draw_tree_html( $dn, $server_id, $level=0 )
|
||||
echo '<td class="spacer"></td>';
|
||||
echo '<td class="icon"><a href="' . $create_href .
|
||||
'" target="right_frame"><img src="images/star.png" /></a></td>';
|
||||
echo '<td class="create" colspan="99"><a href="' . $create_href .
|
||||
'" target="right_frame" title="Create a new object in '. $rdn.'">Create New</a></td></tr>';
|
||||
echo '<td class="create" colspan="' . (97-$level) . '"><a href="' . $create_href .
|
||||
'" target="right_frame" title="' . $lang['create_new_entry_in'] . ' ' . $rdn.'">' .
|
||||
$lang['create_new'] . '</a></td></tr>';
|
||||
}
|
||||
|
||||
echo '</tr>';
|
||||
|
29
update.php
29
update.php
@ -7,30 +7,45 @@
|
||||
* Variables that come in on the query string:
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
* - update_array (an array in the form expected by PHP's ldap_modify)
|
||||
* - update_array (an array in the form expected by PHP's ldap_modify, except for deletions)
|
||||
* (will never be empty: update_confirm.php ensures that)
|
||||
*
|
||||
* Attribute deletions:
|
||||
* To specify that an attribute is to be deleted (whether multi- or single-valued),
|
||||
* enter that attribute in the update array like this: attr => ''. For example, to
|
||||
* delete the 'sn' attribute from an entry, the update array would look like this:
|
||||
* Array (
|
||||
* sn => ''
|
||||
* )
|
||||
*
|
||||
* On success, redirect to edit.php
|
||||
* On failure, echo an error.
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
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 = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$dn = rawurldecode( $_POST['dn'] );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$update_array = $_POST['update_array'];
|
||||
|
||||
//echo "<pre>"; print_r( $update_array ); echo "</pre>";
|
||||
|
||||
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." );
|
||||
is_array( $update_array ) or pla_error( "update_array is malformed. This might be a phpLDAPAdmin bug. Please report it." );
|
||||
is_array( $update_array ) or pla_error( "update_array is malformed. This might be a phpLDAPadmin bug. Please report it." );
|
||||
|
||||
// check for delete attributes (indicated by the attribute entry appearing like this: attr => ''
|
||||
foreach( $update_array as $attr => $val )
|
||||
if( ! is_array( $val ) )
|
||||
if( $val == '' )
|
||||
$update_array[ $attr ] = array();
|
||||
else
|
||||
$update_array[ $attr ] = $val;
|
||||
else
|
||||
foreach( $val as $i => $v )
|
||||
$update_array[ $attr ][ $i ] = $v;
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
$res = @ldap_modify( $ds, $dn, $update_array );
|
||||
|
@ -9,8 +9,8 @@
|
||||
* makes the change.
|
||||
*
|
||||
*/
|
||||
include 'config.php';
|
||||
include 'functions.php';
|
||||
|
||||
require 'common.php';
|
||||
|
||||
include 'header.php';
|
||||
|
||||
@ -21,7 +21,8 @@ $rdn = get_rdn( $dn );
|
||||
$old_values = $_POST['old_values'];
|
||||
$new_values = $_POST['new_values'];
|
||||
$update_array = array();
|
||||
|
||||
if( is_server_read_only( $server_id ) )
|
||||
pla_error( "You cannot perform updates while server is in read-only mode" );
|
||||
?>
|
||||
|
||||
<body>
|
||||
@ -36,17 +37,37 @@ foreach( $new_values as $attr => $new_val )
|
||||
if( $new_val != $old_values[ $attr ] ) {
|
||||
|
||||
// special case for userPassword attributes
|
||||
if( 0 == strcasecmp( $attr, 'userPassword' ) )
|
||||
{
|
||||
$enc_type = $_POST['enc_type'];
|
||||
$new_val = password_hash( $new_val, $enc_type );
|
||||
}
|
||||
if( 0 == strcasecmp( $attr, 'userPassword' ) && $new_val != '' )
|
||||
$new_val = password_hash( $new_val, $_POST['enc_type'] );
|
||||
|
||||
$update_array[ $attr ] = $new_val;
|
||||
}
|
||||
}
|
||||
|
||||
//echo "<pre>"; print_r( $update_array ); echo "</pre>";
|
||||
// special case check for a new enc_type for userPassword (not otherwise detected)
|
||||
if( $_POST['enc_type'] != $_POST['old_enc_type'] && $_POST['new_values']['userpassword'] != '' ) {
|
||||
$new_password = password_hash( $_POST['new_values']['userpassword'], $_POST['enc_type'] );
|
||||
$update_array[ 'userpassword' ] = $new_password;
|
||||
}
|
||||
|
||||
// strip empty vals from update_array and ensure consecutive indices for each attribute
|
||||
foreach( $update_array as $attr => $val ) {
|
||||
if( is_array( $val ) ) {
|
||||
foreach( $val as $i => $v )
|
||||
if( null == $v || 0 == strlen( $v ) )
|
||||
unset( $update_array[$attr][$i] );
|
||||
$update_array[$attr] = array_values( $update_array[$attr] );
|
||||
}
|
||||
}
|
||||
|
||||
// at this point, the update_array should look like this (example):
|
||||
// Array (
|
||||
// cn => Array(
|
||||
// [0] => 'Dave',
|
||||
// [1] => 'Bob' )
|
||||
// sn => 'Smith',
|
||||
// telephoneNumber => '555-1234' )
|
||||
// This array should be ready to be passed to ldap_modify()
|
||||
|
||||
?>
|
||||
<?php if( count( $update_array ) > 0 ) { ?>
|
||||
@ -67,21 +88,36 @@ foreach( $new_values as $attr => $new_val )
|
||||
<?php
|
||||
if( is_array( $old_values[ $attr ] ) )
|
||||
foreach( $old_values[ $attr ] as $v )
|
||||
echo htmlspecialchars( $v ) . "<br />";
|
||||
echo htmlspecialchars( utf8_encode( $v ) ) . "<br />";
|
||||
else
|
||||
echo htmlspecialchars( $old_values[ $attr ] ) . "<br />";
|
||||
echo htmlspecialchars( utf8_encode( $old_values[ $attr ] ) ) . "<br />";
|
||||
echo "</nobr></td><td><nobr>";
|
||||
if( is_array( $new_val ) )
|
||||
foreach( $new_val as $i => $v )
|
||||
|
||||
// is this a multi-valued attribute?
|
||||
if( is_array( $new_val ) ) {
|
||||
foreach( $new_val as $i => $v ) {
|
||||
if( $v == '' ) {
|
||||
// remove it from the update array if it's empty
|
||||
unset( $update_array[ $attr ][ $i ] );
|
||||
$update_array[ $attr ] = array_values( $update_array[ $attr ] );
|
||||
} else
|
||||
echo htmlspecialchars( $v ) . "<br />";
|
||||
} else {
|
||||
echo htmlspecialchars( utf8_encode( $v ) ) . "<br />";
|
||||
}
|
||||
}
|
||||
|
||||
// was this a multi-valued attribute deletion? If so,
|
||||
// fix the $update_array to reflect that per update_confirm.php's
|
||||
// expectations
|
||||
if( $update_array[ $attr ] == array( 0 => '' ) || $update_array[ $attr ] == array() ) {
|
||||
$update_array[ $attr ] = '';
|
||||
echo '<span style="color: red">[attribute deleted]</span>';
|
||||
}
|
||||
}
|
||||
else
|
||||
if( $new_val != '' )
|
||||
echo htmlspecialchars( $new_val ) . "<br />";
|
||||
else
|
||||
echo '<span style="color: red">[attribute deleted]</span>';
|
||||
echo "</nobr></td></tr>\n\n";
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
|
||||
require 'common.php';
|
||||
|
||||
$file = $_GET['file'];
|
||||
|
||||
|
10
welcome.php
Normal file
10
welcome.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php include 'header.php'; ?>
|
||||
|
||||
<center>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<img src="images/logo.jpg" /><br />
|
||||
<br />
|
||||
Use the menu to the left to navigate.
|
||||
</center>
|
Loading…
Reference in New Issue
Block a user