RELEASE 0.9.5
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
require 'common.php';
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/templates/creation/new_user_template.php,v 1.25 2004/12/20 14:12:33 uugdave Exp $
|
||||
|
||||
/*
|
||||
* TODO Add a check: If the server is configured to use auto_uid_numbers AND the
|
||||
@@ -10,14 +9,25 @@ require 'common.php';
|
||||
*/
|
||||
|
||||
// customize this to your needs
|
||||
|
||||
// CHANGES MK
|
||||
// - unlink first name and attribute cn ("common name"), link it to givenname
|
||||
// - add field common name, to be filled from first and last name, link to cn
|
||||
// - to allow givenname, I added the objectClass 'inetOrgPerson'
|
||||
|
||||
$default_container = "ou=People";
|
||||
|
||||
// Common to all templates
|
||||
$container = isset( $_POST['container'] ) ? $_POST['container'] : null;
|
||||
$server_id = isset( $_POST['server_id'] ) ? $_POST['server_id'] : false;
|
||||
$container = isset( $_REQUEST['container'] ) ? $_REQUEST['container'] : null;
|
||||
$server_id = isset( $_REQUEST['server_id'] ) ? $_REQUEST['server_id'] : false;
|
||||
|
||||
// Modify this array and add/remove the corresponding attributes below
|
||||
$object_classes = array( 'top', 'person', 'posixAccount', 'shadowAccount' );
|
||||
// Set $redirect to pass this to create.php to have it redirect when done.
|
||||
$redirect = null;
|
||||
// For example, if you want to redirect back to the user creation form, set $redirect to this:
|
||||
//$redirect = "creation_template.php?server_id=$server_id&template=$template_id&container=" . urlencode( $container );
|
||||
|
||||
// Modify this array and add/remove the corresponding objectClasses below
|
||||
$object_classes = array( 'top', 'person', 'posixAccount', 'shadowAccount', 'inetOrgPerson');
|
||||
|
||||
// A list of default attributes/values to create with this new user
|
||||
$default_attributes = array(
|
||||
@@ -34,9 +44,8 @@ $step = 1;
|
||||
if( isset($_POST['step']) )
|
||||
$step = $_POST['step'];
|
||||
|
||||
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." );
|
||||
|
||||
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] . ": " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
|
||||
?>
|
||||
|
||||
<script language="javascript">
|
||||
@@ -62,6 +71,7 @@ function autoFillUserName( form )
|
||||
|
||||
user_name = first_name.substr( 0,1 ) + last_name;
|
||||
form.user_name.value = user_name;
|
||||
form.common_name.value = form.first_name.value + " " + form.last_name.value;
|
||||
autoFillHomeDir( form );
|
||||
}
|
||||
|
||||
@@ -71,7 +81,7 @@ function autoFillUserName( form )
|
||||
function autoFillHomeDir( form )
|
||||
{
|
||||
var user_name;
|
||||
var hime_dir;
|
||||
var home_dir;
|
||||
|
||||
user_name = form.user_name.value.toLowerCase();
|
||||
|
||||
@@ -86,9 +96,9 @@ function autoFillHomeDir( form )
|
||||
</script>
|
||||
|
||||
<center>
|
||||
<h2 style="margin:0px">New User Account</h2>
|
||||
<h2 style="margin:0px"><?php echo $lang['t_new_user_account']; ?></h2>
|
||||
<?php if( show_hints() ) { ?>
|
||||
<small><img src="images/light.png" />Hint: To customize this template, edit the file templates/creation/new_user_template.php<br />
|
||||
<small><img src="images/light.png" /><?php echo $lang['t_hint_customize']; ?></small><br />
|
||||
<?php } ?>
|
||||
<br />
|
||||
</center>
|
||||
@@ -98,41 +108,46 @@ function autoFillHomeDir( form )
|
||||
<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 htmlspecialchars( $_POST['template'] ); ?>" />
|
||||
<input type="hidden" name="template" value="<?php echo htmlspecialchars( $_REQUEST['template'] ); ?>" />
|
||||
|
||||
<center>
|
||||
<table class="confirm">
|
||||
<tr class="spacer"><td colspan="3"></tr>
|
||||
<tr class="spacer"><td colspan="3"></td></tr>
|
||||
<tr>
|
||||
<td><img src="images/uid.png" /></td>
|
||||
<td class="heading">First name:</td>
|
||||
<td class="heading"><?php echo $lang['t_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 class="heading"><?php echo $lang['t_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 class="heading"><?php echo $lang['t_common_name']; ?>:</td>
|
||||
<td><input type="text" name="common_name" id="common_name" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading"><?php echo $lang['t_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 class="spacer"><td colspan="3"></td></tr>
|
||||
<tr>
|
||||
<td><img src="images/lock.png" /></td>
|
||||
<td class="heading">Password:</td>
|
||||
<td class="heading"><?php echo $lang['t_password']; ?>:</td>
|
||||
<td><input type="password" name="user_pass1" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Password:</td>
|
||||
<td class="heading"><?php echo $lang['t_password']; ?>:</td>
|
||||
<td><input type="password" name="user_pass2" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Encryption:</td>
|
||||
<td class="heading"><?php echo $lang['t_encryption']; ?>:</td>
|
||||
<td><select name="encryption">
|
||||
<option>clear</option>
|
||||
<option>md5</option>
|
||||
@@ -142,10 +157,10 @@ function autoFillHomeDir( form )
|
||||
<option>ssha</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr class="spacer"><td colspan="3"></tr>
|
||||
<tr class="spacer"><td colspan="3"></td></tr>
|
||||
<tr>
|
||||
<td><img src="images/terminal.png" /></td>
|
||||
<td class="heading">Login Shell:</td>
|
||||
<td class="heading"><?php echo $lang['t_login_shell']; ?>:</td>
|
||||
<!--<td><input type="text" name="login_shell" value="/bin/bash" /></td>-->
|
||||
<td>
|
||||
<select name="login_shell">
|
||||
@@ -155,23 +170,25 @@ function autoFillHomeDir( form )
|
||||
<option>/bin/tcsh</option>
|
||||
<option>/bin/zsh</option>
|
||||
<option>/bin/sh</option>
|
||||
<option>/bin/rssh</option>
|
||||
<option value="/bin/false">/bin/false (no login)</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Container:</td>
|
||||
<td class="heading"><?php echo $lang['t_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>
|
||||
<?php draw_chooser_link( 'user_form.container' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">Home Directory:</td>
|
||||
<td class="heading"><?php echo $lang['t_home_dir']; ?>:</td>
|
||||
<td><input type="text" name="home_dir" value="/home/" id="home_dir" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
@@ -181,59 +198,84 @@ function autoFillHomeDir( form )
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="heading">UID Number:</td>
|
||||
<?php $next_uid_number = get_next_uid_number( $server_id ); ?>
|
||||
<td class="heading"><?php echo $lang['t_uid_number']; ?>:</td>
|
||||
<?php $next_uid_number = ( auto_uid_numbers_enabled( $server_id ) ? get_next_uid_number( $server_id ) : false ); ?>
|
||||
<td><input type="text" name="uid_number" value="<?php echo $next_uid_number ?>" />
|
||||
<?php if( false !== $next_uid_number ) echo "<small>(automatically determined)</small>"; ?>
|
||||
<?php if( false !== $next_uid_number ) echo "<small>" . $lang['t_auto_det'] . "</small>"; ?>
|
||||
</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>
|
||||
<?php
|
||||
$base_dn = null;
|
||||
if( isset( $base_posix_groups ) )
|
||||
$base_dn = $base_posix_groups;
|
||||
$posix_groups = get_posix_groups( $server_id, $base_dn );
|
||||
$posix_groups_found = ( count( $posix_groups ) ? true : false ); ?>
|
||||
<td class="heading"><?php echo $posix_groups_found ? $lang['t_group'] : $lang['t_gid_number'] ?>:</td>
|
||||
<td>
|
||||
<?php if( $posix_groups_found ){?>
|
||||
<select name="gid_number">
|
||||
<?php foreach ( $posix_groups as $dn => $attrs ){
|
||||
$group_name = ereg_replace('^.*=',"",get_rdn($dn));
|
||||
$gid_number = $attrs['gidNumber'];
|
||||
?>
|
||||
<option value="<?php echo $gid_number; ?>">
|
||||
<?php echo htmlspecialchars($group_name) . " ($gid_number)"; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<?php } else { ?><input type="text" name="gid_number" /><?php } ?>
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"><center><br /><input type="submit" value="Proceed" /></td>
|
||||
<td colspan="3"><center><br /><input type="submit" value="<?php echo $lang['proceed_gt']; ?>" /></center></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</form>
|
||||
|
||||
|
||||
<?php } elseif( $step == 2 ) {
|
||||
|
||||
$user_name = trim( $_POST['user_name'] );
|
||||
$first_name = trim( $_POST['first_name'] );
|
||||
$common_name = trim( $_POST['common_name'] );
|
||||
$last_name = trim( $_POST['last_name'] );
|
||||
$password1 = $_POST['user_pass1'];
|
||||
$password2 = $_POST['user_pass2'];
|
||||
$encryption = $_POST['encryption'];
|
||||
$login_shell = trim( $_POST['login_shell'] );
|
||||
$uid_number = trim( $_POST['uid_number'] );
|
||||
$gid_number = trim( $_POST['group'] );
|
||||
$gid_number = trim( $_POST['gid_number'] );
|
||||
$container = trim( $_POST['container'] );
|
||||
$home_dir = trim( $_POST['home_dir'] );
|
||||
|
||||
/* Critical assertions */
|
||||
if( ! trim( $user_name ) )
|
||||
pla_error( sprintf( $lang['t_err_field_blank'], $lang['t_user_name'] ) );
|
||||
$password1 == $password2 or
|
||||
pla_error( "Your passwords don't match. Please go back and try again." );
|
||||
pla_error( $lang['t_err_passwords'] );
|
||||
0 != strlen( $uid_number ) or
|
||||
pla_error( "You cannot leave the UID number blank. Please go back and try again." );
|
||||
pla_error( sprintf( $lang['t_err_field_blank'], $lang['t_uid_number'] ) );
|
||||
is_numeric( $uid_number ) or
|
||||
pla_error( "You can only enter numeric values for the UID number field. Please go back and try again." );
|
||||
pla_error( sprintf( $lang['t_err_field_num'], $lang['t_uid_number'] ) );
|
||||
is_numeric( $gid_number ) or
|
||||
pla_error( sprintf( $lang['t_err_field_num'], $lang['t_gid_number'] ) );
|
||||
dn_exists( $server_id, $container ) or
|
||||
pla_error( "The container you specified (" . htmlspecialchars( $container ) . ") does not exist. " .
|
||||
"Please go back and try again." );
|
||||
pla_error( sprintf( $lang['t_err_bad_container'], htmlspecialchars( $container ) ) );
|
||||
|
||||
$password = password_hash( $password1, $encryption );
|
||||
|
||||
|
||||
?>
|
||||
<center><h3>Confirm account creation:</h3></center>
|
||||
<center><h3><?php echo $lang['t_confirm_account_creation']; ?>:</h3></center>
|
||||
|
||||
<form action="create.php" method="post">
|
||||
<?php if( $redirect ) { ?>
|
||||
<input type="hidden" name="redirect" value="<?php echo htmlspecialchars($redirect); ?>" />
|
||||
<?php } ?>
|
||||
<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 ); ?>" />
|
||||
|
||||
@@ -245,10 +287,12 @@ function autoFillHomeDir( form )
|
||||
<!-- 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="attrs[]" value="gn" />
|
||||
<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="cn" />
|
||||
<input type="hidden" name="vals[]" value="<?php echo htmlspecialchars($common_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" />
|
||||
@@ -270,17 +314,19 @@ function autoFillHomeDir( form )
|
||||
|
||||
<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>
|
||||
<tr class="even"><td class="heading"><?php echo $lang['t_user_name']; ?></td><td><b><?php echo htmlspecialchars( $user_name ); ?></b></td></tr>
|
||||
<tr class="odd"><td class="heading"><?php echo $lang['t_first_name']; ?>:</td><td><b><?php echo htmlspecialchars( $first_name ); ?></b></td></tr>
|
||||
<tr class="even"><td class="heading"><?php echo $lang['t_last_name']; ?>:</td><td><b><?php echo htmlspecialchars( $last_name ); ?></b></td></tr>
|
||||
<tr class="even"><td class="heading"><?php echo $lang['t_common_name']; ?>:</td><td><b><?php echo htmlspecialchars( $common_name ); ?></b></td></tr>
|
||||
<tr class="odd"><td class="heading"><?php echo $lang['t_password']; ?>:</td><td><?php echo $lang['t_secret']; ?></td></tr>
|
||||
<tr class="even"><td class="heading"><?php echo $lang['t_login_shell']; ?>:</td><td><?php echo htmlspecialchars( $login_shell); ?></td></tr>
|
||||
<tr class="odd"><td class="heading"><?php echo $lang['t_uid_number']; ?>:</td><td><?php echo htmlspecialchars( $uid_number ); ?></td></tr>
|
||||
<tr class="even"><td class="heading"><?php echo $lang['t_gid_number']; ?>:</td><td><?php echo htmlspecialchars( $gid_number ); ?></td></tr>
|
||||
<tr class="odd"><td class="heading"><?php echo $lang['t_container']; ?>:</td><td><?php echo htmlspecialchars( $container ); ?></td></tr>
|
||||
<tr class="even"><td class="heading"><?php echo $lang['t_home_dir']; ?>:</td><td><?php echo htmlspecialchars( $home_dir ); ?></td></tr>
|
||||
</table>
|
||||
<br /><input type="submit" value="Create Account" />
|
||||
<br /><input type="submit" value="<?php echo $lang['t_create_account']; ?>" />
|
||||
</center>
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
||||
|
Reference in New Issue
Block a user