Skip to content

Commit

Permalink
RELEASE 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Deon George committed Jun 30, 2009
0 parents commit 763843c
Show file tree
Hide file tree
Showing 77 changed files with 6,757 additions and 0 deletions.
40 changes: 40 additions & 0 deletions INSTALL
@@ -0,0 +1,40 @@
These instructions assume that you have a working install of:
a. A web server (Apache, IIS, etc).
b. PHP (with LDAP support)

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.

Browsers

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!)

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
Nathan Rotschafer
- Steve Rigler Password hash patch
- Chric Jackson Blowfish and md5crypt passwords

Bug reporters:

- Colin Tinker (short_open_tags bug report)
- Greg Felix (multi-value update bug report)
- Moritz Mertinkat (creation bug report)

341 changes: 341 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
0.9.0
55 changes: 55 additions & 0 deletions add_oclass.php
@@ -0,0 +1,55 @@
<?php
/*
* add_oclass.php
* Adds an objectClass to the specified dn.
* Variables that come in as POST vars:
*
* Note, this does not do any schema violation checking. That is
* performed in add_oclass_form.php.
*
* Vars that come in as POST:
* - dn (rawurlencoded)
* - server_id
* - new_oclass
* - new_attrs (array, if any)
*/

require 'config.php';
require 'functions.php';

$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
$encoded_dn = rawurlencode( $dn );
$new_oclass = stripslashes( $_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." );

$new_entry = array();
$new_entry['objectClass'] = $new_oclass;

$new_attrs_entry = array();
$new_oclass_entry = array( 'objectClass' => $new_oclass );

if( is_array( $new_attrs ) && count( $new_attrs ) > 0 )
foreach( $new_attrs as $attr => $val )
$new_entry[ $attr ] = $val;

//echo "<pre>";
//print_r( $new_entry );
//exit;

$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server." );
$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 ) );
}
else
{
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn" );
}

?>
108 changes: 108 additions & 0 deletions add_oclass_form.php
@@ -0,0 +1,108 @@
<?php

/*
* add_oclass_form.php
* This page may simply add the objectClass and take you back to the edit page,
* but, in one condition it may prompt the user for input. That condition is this:
*
* If the user has requested to add an objectClass that requires a set of
* attributes with 1 or more not defined by the object. In that case, we will
* present a form for the user to add those attributes to the object.
*
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - server_id
* - new_oclass
*/

require 'config.php';
require_once 'functions.php';

$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
$encoded_dn = rawurlencode( $dn );
$new_oclass = stripslashes( $_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." );

/* Ensure that the object has defined all MUST attrs for this objectClass.
* If it hasn't, present a form to have the user enter values for all the
* newly required attrs. */

$entry = get_object_attrs( $server_id, $dn, true );
$current_attrs = array();
foreach( $entry as $attr => $junk )
$current_attrs[] = strtolower($attr);
// grab the required attributes for the new objectClass
$must_attrs = get_schema_objectclasses( $server_id );
$must_attrs = $must_attrs[ strtolower($new_oclass) ]['must_attrs'];
sort( $must_attrs );
// build a list of the attributes that this new objectClass requires,
// but that the object does not currently contain
$needed_attrs = array();
foreach( $must_attrs as $attr )
if( ! in_array( strtolower($attr), $current_attrs ) )
$needed_attrs[] = $attr;

if( count( $needed_attrs ) > 0 )
{
?>


<?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>

<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>

<br />
<br />

<form action="add_oclass.php" method="post">
<input type="hidden" name="new_oclass" value="<?php echo htmlspecialchars( $new_oclass ); ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />

<table class="edit_dn" cellspacing="0">
<tr><th colspan="2">New Required Attributes</th></tr>

<?php foreach( $needed_attrs as $count => $attr ) { ?>
<?php if( $count % 2 == 0 ) { ?>
<tr class="row1">
<?php } else { ?>
<tr class="row2">
<?php } ?>
<td class="attr"><b><?php echo htmlspecialchars($attr); ?></b></td>
<td class="val"><input type="text" name="new_attrs[<?php echo htmlspecialchars($attr); ?>]" value="" size="40" />
</tr>
<?php } ?>

</table>
<br />
<br />
<center><input type="submit" value="Add ObjectClass and Attributes" /></center>
</form>

</body>
</html>

<?php
}
else
{
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server." );
$add_res = @ldap_mod_add( $ds, $dn, array( 'objectClass' => $new_oclass ) );
if( ! $add_res )
pla_error( "Could not perform ldap_mod_add operation.", ldap_error( $ds ), ldap_errno( $ds ) );
else
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn" );

}

?>
52 changes: 52 additions & 0 deletions add_value.php
@@ -0,0 +1,52 @@
<?php

/*
* add_value.php
* Adds a value to an attribute for a given dn.
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
* - server_id
* - new_value (form element)
*
* On success, redirect to the edit_dn page.
* On failure, echo an error.
*/

require 'config.php';
require_once 'functions.php';

$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
$encoded_dn = rawurlencode( $dn );
$attr = stripslashes( $_POST['attr'] );
$encoded_attr = rawurlencode( $attr );
$server_id = $_POST['server_id'];
$new_value = stripslashes( $_POST['new_value'] );
$new_value = utf8_encode($new_value);

check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );

$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );

// 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'];
$f = fopen( $file, 'r' );
$jpeg_data = fread( $f, filesize( $file ) );
fclose( $f );
$new_value = $jpeg_data;
}

$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 ) );

header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&updated_attr=$encoded_attr" );

?>
133 changes: 133 additions & 0 deletions add_value_form.php
@@ -0,0 +1,133 @@
<?php

/*
* add_value_form.php
* Displays a form to allow the user to enter a new value to add
* to the existing list of values for a multi-valued attribute.
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
* - server_id
*
*/

require 'config.php';
require_once 'functions.php';

$dn = stripslashes( $_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'];
$attr = stripslashes( $_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_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 );
}

?>

<?php include 'header.php'; ?>

<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> &nbsp;&nbsp;&nbsp; Distinguished Name: <b><?php echo $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 if( $is_jpeg_photo ) { ?>

<table><td>
<?php draw_jpeg_photos( $server_id, $dn ); ?>
</td></table>

<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
<p><small>
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.
</small></p>
<!-- End of temporary warning -->

<?php } else { ?>

<ul class="current_values">
<?php if( is_array( $current_values ) ) /*$num_current_values > 1 )*/ {
foreach( $current_values as $val ) { ?>

<li><nobr><?php echo htmlspecialchars(utf8_decode($val)); ?></nobr></li>

<?php } ?>
<?php } else { ?>

<li><nobr><?php echo htmlspecialchars(utf8_decode($current_values)); ?></nobr></li>

<?php } ?>
</ul>

<?php } ?>

Enter the value you would like to add:<br />
<br />

<?php if( $is_object_class ) { ?>

<form action="add_oclass_form.php" method="post" class="new_value">
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<select name="new_oclass">

<?php foreach( $schema_oclasses as $oclass => $desc ) { ?>

<option value="<?php echo $desc['name']; ?>"><?php echo $desc['name']; ?></option>

<?php } ?>

</select> <input type="submit" value="Add new objectClass" />

<br /><small>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 &gt;&gt;" />

<?php } else { ?>

<form action="add_value.php" method="post" class="new_value">
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
<input type="hidden" name="attr" value="<?php echo $encoded_attr; ?>" />
<input type="text" name="new_value" size="40" value="" />
<input type="submit" name="submit" value="Add New Value" />
<br />
<small>Syntax: <?php echo $schema_attrs[ strtolower($attr) ]['type']; ?></small>
</form>

<?php } ?>

</body>
</html>

0 comments on commit 763843c

Please sign in to comment.