RELEASE 0.9.0

This commit is contained in:
Deon George
2009-06-30 18:05:37 +10:00
commit 763843c16a
77 changed files with 6757 additions and 0 deletions

View File

@@ -0,0 +1,186 @@
<?php
require 'config.php';
// Common to all templates
$rdn = stripslashes( $_POST['rdn'] );
$container = stripslashes( $_POST['container'] );
$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." );
if( $step == 1 )
{
$oclasses = get_schema_objectClasses( $server_id );
?>
<h4>Step 1 of 2: Name and ObjectClass(es)</h4>
<form action="creation_template.php" method="post" name="creation_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']; ?>" />
<table class="create">
<tr>
<td class="heading"><acronym title="Relative Distinguished Name">RDN</acronym>:</td>
<td><input type="text" name="rdn" value="" size="20" /> (example: cn=MyNewObject)</td>
</tr>
<tr>
<td class="heading">Container:</td>
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars($container); ?>" />
<?php draw_chooser_link( 'creation_form.container' ); ?></td>
</tr>
<tr>
<td class="heading">ObjectClass(es):</td>
<td>
<select name="object_classes[]" multiple size="15">
<?php foreach( $oclasses as $oclass => $attrs ) { ?>
<option value="<?php echo htmlspecialchars($oclass); ?>">
<?php echo htmlspecialchars($attrs['name']); ?>
</option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Proceed >>" /></td>
</tr>
</table>
</form>
<?php
}
if( $step == 2 )
{
strlen( trim( $rdn ) ) != 0 or
pla_error( "You left the RDN field blank" );
strlen( $container ) == 0 or dn_exists( $server_id, $container ) or
pla_error( "The container you specified (" . htmlspecialchars( $container ) . ") does not exist. " .
"Please go back and try again." );
$friendly_attrs = process_friendly_attr_table();
$oclasses = $_POST['object_classes'];
if( count( $oclasses ) == 0 )
pla_error( "You did not select any ObjectClasses for this object. Please go back and do so." );
// build a list of required attributes:
$dn = $rdn . ',' . $container;
$schema = get_schema( $server_id );
$attrs = $schema['attrs'];
$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_unique( $required_attrs );
$all_attrs = array_unique( $all_attrs );
sort( $required_attrs );
sort( $all_attrs );
$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) . ")";
} else {
$attr_display = htmlspecialchars( $a );
}
echo $attr_display;
$attr_select_html .= "<option>$attr_display</option>\n";
}
// add the required attribute based on the RDN provided by the user
// (ie, if the user specifies "cn=Bob" for their RDN, make sure "cn" is
// 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 ) )
$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>
<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">
<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 ); ?>" />
<input type="hidden" name="container" value="<?php echo htmlspecialchars( $container ); ?>" />
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
<input type="hidden" name="object_classes" value="<?php echo rawurlencode(serialize($oclasses)); ?>" />
<table class="edit_dn" cellspacing="0">
<tr><th colspan="2">Required Attributes</th></tr>
<?php foreach( $required_attrs as $count => $attr ) { ?>
<?php if( $count % 2 == 0 ) { ?>
<tr class="row1">
<?php } else { ?>
<tr class="row2">
<?php } ?>
<td class="attr"><b><?php
// 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>";
} else {
$attr_display = htmlspecialchars( $attr );
}
echo $attr_display;
?></b></td>
<td class="val"><input type="text"
name="required_attrs[<?php echo htmlspecialchars($attr); ?>]"
value="<?php echo $attr == $rdn_attr ? $rdn_value : '' ?>" size="40" />
</tr>
<?php } ?>
<tr><th colspan="2">Optional Attributes</th></tr>
<?php for($i=0; $i<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 } ?>
</table>
<center>
<input type="submit" name="submit" value="Create Object" />
</center>
<?php } ?>

View File

@@ -0,0 +1,210 @@
<?php
require 'config.php';
// customize this to your needs
$default_container = "ou=Addresses";
// Common to all templates
$container = stripslashes( $_POST['container'] );
$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">
<!--
/*
* Populates the common name field based on the last
* name concatenated with the first name, separated
* by a blank
*/
function autoFillCommonName( form )
{
var first_name;
var last_name;
var common_name;
first_name = form.first_name.value;
last_name = form.last_name.value;
if( last_name == '' ) {
return false;
}
common_name = last_name + ' ' + first_name;
form.common_name.value = common_name;
}
-->
</script>
<center><h2>New Address Book Entry<br />
<small>(InetOrgPerson)</small></h2>
</center>
<?php if( $step == 1 ) { ?>
<form action="creation_template.php" method="post" id="address_form" name="address_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><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)" />
</td>
</tr>
<tr>
<td></td>
<td class="heading">Common name:</td>
<td><input type="text" name="common_name" id="common_name" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">Organization:</td>
<td><input type="text" name="organization" id="organization" value="" /></td>
</tr>
<tr class="spacer"><td colspan="3"></tr>
<tr>
<td><img src="images/mail.png" /></td>
<td class="heading">Address:</td>
<td><input type="text" name="street" id="street" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">City:</td>
<td><input type="text" name="city" id="city" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">Postal code:</td>
<td><input type="text" name="postal_code" id="postal_code" value="" /></td>
</tr>
<tr class="spacer"><td colspan="3"></tr>
<tr>
<td><img src="images/phone.png" /></td>
<td class="heading">Work phone:</td>
<td><input type="text" name="telephone_number" id="telephone_number" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">Fax:</td>
<td><input type="text" name="fax_number" id="fax_number" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">Mobile:</td>
<td><input type="text" name="mobile_number" id="mobile_number" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">Email:</td>
<td><input type="text" name="email_address" id="email_address" value="" /></td>
</tr>
<tr class="spacer"><td colspan="3"></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( 'address_form.container' ); ?></td>
</td>
</tr>
<tr>
<td colspan="3"><center><br /><input type="submit" value="Proceed &gt;&gt;" /></td>
</tr>
</table>
</center>
<?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'] ) );
/* Critical assertions */
0 != strlen( $common_name ) or
pla_error( "You cannot leave the Common Name blank. Please go back and try again." );
?>
<center><h3>Confirm entry 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( 'cn=' . $common_name . ',' . $container ); ?>" />
<!-- ObjectClasses -->
<?php $object_classes = rawurlencode( serialize( array( 'top', 'inetOrgPerson' ) ) ); ?>
<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($common_name);?>" />
<input type="hidden" name="attrs[]" value="givenName" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($first_name);?>" />
<input type="hidden" name="attrs[]" value="sn" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($last_name);?>" />
<input type="hidden" name="attrs[]" value="o" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($organization);?>" />
<input type="hidden" name="attrs[]" value="l" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($city);?>" />
<input type="hidden" name="attrs[]" value="postalCode" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($postal_code);?>" />
<input type="hidden" name="attrs[]" value="street" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($street);?>" />
<input type="hidden" name="attrs[]" value="telephoneNumber" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($telephone_number);?>" />
<input type="hidden" name="attrs[]" value="facsimileTelephoneNumber" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($fax_number);?>" />
<input type="hidden" name="attrs[]" value="mobile" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($mobile_number);?>" />
<input type="hidden" name="attrs[]" value="mail" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($email_address);?>" />
<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>
</table>
<br /><input type="submit" value="Create Address" />
</center>
<?php } ?>

View File

@@ -0,0 +1,91 @@
<?php
require 'config.php';
// Common to all templates
$container = stripslashes( $_POST['container'] );
$server_id = $_POST['server_id'];
// Unique to this template
$step = $_POST['step'];
if( ! $step )
$step = 1;
check_server_id( $server_id ) or die( "Bad server_id: " . htmlspecialchars( $server_id ) );
have_auth_info( $server_id ) or die( "Not enough information to login to server. Please check your configuration." );
?>
<center><h2>New DNS Entry</h2></center>
<?php if( $step == 1 ) { ?>
<form action="creation_template.php" method="post" name="dns_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>
<td></td>
<td class="heading"><acronym title="Domain Component">DC</acronym> Name:</td>
<td><input type="text" name="dc_name" value="" /> <small>(hint: don't include "dc=")</small></td>
</tr>
<tr>
<td></td>
<td class="heading">Associated Domain:</td>
<td><input type="text" name="associateddomain" value="" /></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( utf8_decode( $container ) ); ?>" />
<?php draw_chooser_link( 'dns_form.container' ); ?></td>
</td>
</tr>
<tr>
<td colspan="3"><center><br /><input type="submit" value="Proceed &gt;&gt;" /></td>
</tr>
</table>
</center>
<?php } elseif( $step == 2 ) {
$dc_name = trim( stripslashes( $_POST['dc_name'] ) );
$container = trim( stripslashes( $_POST['container'] ) );
$associateddomain = trim( stripslashes( $_POST['associateddomain'] ) );
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( 'dc=' . $dc_name . ',' . $container ); ?>" />
<!-- ObjectClasses -->
<?php $object_classes = rawurlencode( serialize( array( 'top', 'dnsdomain', 'domainRelatedObject') ) ); ?>
<input type="hidden" name="object_classes" value="<?php echo $object_classes; ?>" />
<input type="hidden" name="attrs[]" value="associatedDomain" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($associateddomain);?>" />
<input type="hidden" name="attrs[]" value="objectClass" />
<input type="hidden" name="vals[]" value="top" />
<input type="hidden" name="attrs[]" value="domainComponent" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($dc_name);?>" />
<center>
Really create this new <acronym title="Domain Component">DC</acronym> entry?<br />
<br />
<table class="confirm">
<tr class="even"><td>Name</td><td><b><?php echo htmlspecialchars($dc_name); ?></b></td></tr>
<tr class="odd"><td>Domain</td><td><b><?php echo htmlspecialchars($associateddomain); ?></b></td></tr>
<tr class="even"><td>Container</td><td><b><?php echo htmlspecialchars( $container ); ?></b></td></tr>
</table>
<br /><input type="submit" value="Create Entry" />
</center>
<?php } ?>

View File

@@ -0,0 +1,128 @@
<?php
require 'config.php';
// Common to all templates
$container = stripslashes( $_POST['container'] );
$server_id = $_POST['server_id'];
// Unique to this template
$step = $_POST['step'];
if( ! $step )
$step = 1;
// A little config for this template
$default_gid_number = 30000;
$default_acct_flags = '[W ]';
$default_cn = 'Root User';
$default_home_dir = '/dev/null';
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 Samba NT Machine</h2></center>
<?php if( $step == 1 ) { ?>
<form action="creation_template.php" method="post" name="machine_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"></td></tr>
<tr>
<td><img src="images/server.png" /></td>
<td class="heading">Machine Name:</td>
<td><input type="text" name="machine_name" value="" /> <small>(hint: don't include "$" at the end)</small></td>
</tr>
<tr>
<td></td>
<td class="heading">UID Number:</td>
<td><input type="text" name="uid_number" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">Container:</td>
<td><input type="text" size="40" name="container" value="<?php echo htmlspecialchars( utf8_decode( $container ) ); ?>" />
<?php draw_chooser_link( 'machine_form.container' ); ?></td>
</td>
</tr>
<tr>
<td colspan="3"><center><br /><input type="submit" value="Proceed &gt;&gt;" />
<br /><br /><br /><br /><br /><br /></td>
</tr>
<tr class="spacer"><td colspan="3"></td></tr>
<tr>
<td colspan="3">
This will create a new NT machine with:<br />
<small>
<ul>
<li>gidNumber <b><?php echo htmlspecialchars( $default_gid_number ); ?></b></li>
<li>acctFlags <b><?php echo str_replace(' ', "&nbsp;", 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>
</ul>
To change these values, edit the template file:
<code>templates/creation/new_nt_machine.php</code><br />
Note: You must have the samba schema installed on your LDAP server.
</small>
</td>
</tr>
</table>
</center>
<?php } elseif( $step == 2 ) {
$machine_name = trim( stripslashes( $_POST['machine_name'] ) );
$uid_number = trim( stripslashes( $_POST['uid_number'] ) );
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( 'uid=' . $machine_name . '$,' . $container ); ?>" />
<!-- ObjectClasses -->
<?php $object_classes = rawurlencode( serialize( array( 'top', 'sambaAccount', 'posixAccount' ) ) ); ?>
<input type="hidden" name="object_classes" value="<?php echo $object_classes; ?>" />
<!-- The array of attributes/values -->
<input type="hidden" name="attrs[]" value="gidNumber" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($default_gid_number);?>" />
<input type="hidden" name="attrs[]" value="uidNumber" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($uid_number);?>" />
<input type="hidden" name="attrs[]" value="uid" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($machine_name . '$');?>" />
<input type="hidden" name="attrs[]" value="rid" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars( decoct($uid_number));?>" />
<input type="hidden" name="attrs[]" value="acctFlags" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($default_acct_flags);?>" />
<input type="hidden" name="attrs[]" value="cn" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($default_cn);?>" />
<input type="hidden" name="attrs[]" value="homeDirectory" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($default_home_dir);?>" />
<center>
Realy create this new Samba machine?<br />
<br />
<table class="confirm">
<tr class="even"><td>Name</td><td><b><?php echo htmlspecialchars($machine_name); ?></b></td></tr>
<tr class="odd"><td>UID</td><td><b><?php echo htmlspecialchars($uid_number); ?></b></td></tr>
<tr class="even"><td>Container</td><td><b><?php echo htmlspecialchars( $container ); ?></b></td></tr>
</table>
<br /><input type="submit" value="Create Machine" />
</center>
<?php } ?>

View File

@@ -0,0 +1,84 @@
<?php
require 'config.php';
// Common to all templates
$container = stripslashes( $_POST['container'] );
$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." );
?>
<center><h2>New Organizational Unit</h2></center>
<?php if( $step == 1 ) { ?>
<form action="creation_template.php" method="post" name="ou_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>
<td></td>
<td class="heading"><acronym title="Organizational Unit">OU</acronym> Name:</td>
<td><input type="text" name="ou_name" value="" /> <small>(hint: don't include "ou=")</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( utf8_decode( $container ) ); ?>" />
<?php draw_chooser_link( 'ou_form.container' ); ?></td>
</td>
</tr>
<tr>
<td colspan="3"><center><br /><input type="submit" value="Proceed &gt;&gt;" /></td>
</tr>
</table>
</center>
<?php } elseif( $step == 2 ) {
$ou_name = trim( stripslashes( $_POST['ou_name'] ) );
$container = trim( stripslashes( $_POST['container'] ) );
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( 'ou=' . $ou_name . ',' . $container ); ?>" />
<!-- ObjectClasses -->
<?php $object_classes = rawurlencode( serialize( array( 'top', 'organizationalUnit' ) ) ); ?>
<input type="hidden" name="object_classes" value="<?php echo $object_classes; ?>" />
<!-- The array of attributes/values -->
<input type="hidden" name="attrs[]" value="ou" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($ou_name);?>" />
<input type="hidden" name="attrs[]" value="cn" />
<center>
Really create this new <acronym title="Organizational Unit">OU</acronym>?<br />
<br />
<table class="confirm">
<tr class="even"><td>Name</td><td><b><?php echo htmlspecialchars($ou_name); ?></b></td></tr>
<tr class="odd"><td>Container</td><td><b><?php echo htmlspecialchars( $container ); ?></b></td></tr>
</table>
<br /><input type="submit" value="Create OU" />
</center>
<?php } ?>

View File

@@ -0,0 +1,242 @@
<?php
require 'config.php';
// customize this to your needs
$default_container = "ou=People";
// Common to all templates
$container = stripslashes( $_POST['container'] );
$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">
<!--
/*
* Pipulates the user name field based on the first letter
* of the firsr name concatenated with the last name
* all in lower case.
*/
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;
form.user_name.value = user_name;
autoFillHomeDir( form );
}
/*
* Pipulates the home directory field based on the username provided
*/
function autoFillHomeDir( form )
{
var user_name;
var hime_dir;
user_name = form.user_name.value.toLowerCase();
home_dir = '/home/';
home_dir += user_name;
form.home_dir.value = home_dir;
}
-->
</script>
<center><h2>New 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><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><select name="encryption">
<option>clear</option>
<option>md5</option>
<option>crypt</option>
<option>sha</option>
</select></td>
</tr>
<tr class="spacer"><td colspan="3"></tr>
<tr>
<td><img src="images/terminal.png" /></td>
<td class="heading">Login Shell:</td>
<!--<td><input type="text" name="login_shell" value="/bin/bash" /></td>-->
<td>
<select name="login_shell">
<option>/bin/bash</option>
<option>/bin/csh</option>
<option>/bin/ksh</option>
<option>/bin/tcsh</option>
<option>/bin/zsh</option>
<option>/bin/sh</option>
</select>
</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">UID Number:</td>
<td><input type="text" name="uid_number" value="" /></td>
</tr>
<tr>
<td></td>
<td class="heading">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">Home Directory:</td>
<td><input type="text" name="home_dir" value="/home/" id="home_dir" /></td>
</tr>
<tr>
<td colspan="3"><center><br /><input type="submit" value="Proceed &gt;&gt;" /></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'] ) );
/* 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 );
?>
<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', 'person', 'posixAccount' ) ) ); ?>
<input type="hidden" name="object_classes" value="<?php echo $object_classes; ?>" />
<!-- The array of attributes/values -->
<input type="hidden" name="attrs[]" value="uid" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($user_name);?>" />
<input type="hidden" name="attrs[]" value="cn" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($first_name);?>" />
<input type="hidden" name="attrs[]" value="sn" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($last_name);?>" />
<input type="hidden" name="attrs[]" value="userPassword" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($password);?>" />
<input type="hidden" name="attrs[]" value="loginShell" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($login_shell);?>" />
<input type="hidden" name="attrs[]" value="uidNumber" />
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($uid_number);?>" />
<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);?>" />
<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 } ?>