Fixed several smaller bugs with quotas, missing argument

Removed invalid value from samba.pru
Modify should work again
Masscreation should work also.
This commit is contained in:
katagia 2003-06-03 14:01:39 +00:00
parent 146304494f
commit 14b341db4c
4 changed files with 42 additions and 27 deletions

View File

@ -8,4 +8,3 @@ unix_pwdmaxage: 180
smb_useunixpwd: 1 smb_useunixpwd: 1
smb_pwdcanchange: 1 smb_pwdcanchange: 1
smb_homedrive: U: smb_homedrive: U:
smb_smbuserworkstations: *

View File

@ -439,8 +439,10 @@ function getgid($groupname) { // Will return the the gid to an existing Groupnam
// Check if group already exists // Check if group already exists
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), 'cn=' . $groupname, array('gidNumber'), 0); $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), 'cn=' . $groupname, array('gidNumber'), 0);
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
if ($entry) {
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
if ($attr['gidNumber'][0]) return $attr['gidNumber'][0]; if ($attr['gidNumber'][0]) return $attr['gidNumber'][0];
}
else return -1; else return -1;
} }
@ -527,6 +529,7 @@ function loaduser($dn) { // Will load all needed values from an existing account
$return = new account(); $return = new account();
$result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixAccount"); $result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixAccount");
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
$return->general_dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
if ($attr['uid'][0]) { if ($attr['uid'][0]) {
$return->general_username = $attr['uid'][0]; $return->general_username = $attr['uid'][0];
@ -598,6 +601,7 @@ function loadhost($dn) { // Will load all needed values from an existing account
$return = new account(); $return = new account();
$result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixAccount"); $result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixAccount");
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
$return->general_dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
if ($attr['uid'][0]) $return->general_username = $attr['uid'][0]; if ($attr['uid'][0]) $return->general_username = $attr['uid'][0];
if ($attr['uidNumber'][0]) $return->general_uidNumber = $attr['uidNumber'][0]; if ($attr['uidNumber'][0]) $return->general_uidNumber = $attr['uidNumber'][0];
@ -649,6 +653,7 @@ function loadgroup($dn) { // Will load all needed values from an existing group
$return = new account(); $return = new account();
$result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixGroup"); $result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixGroup");
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
$return->general_dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
if ($attr['gidNumber'][0]) { if ($attr['gidNumber'][0]) {
$return->general_uidNumber = $attr['gidNumber'][0]; $return->general_uidNumber = $attr['gidNumber'][0];
@ -938,7 +943,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account
} }
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);
} }
if ($_SESSION['config']->scriptServer) setquotas($values->general_username); if ($_SESSION['config']->scriptServer) setquotas($values->general_username,'user',$values_old->general_username);
return 3; return 3;
} }
@ -1167,7 +1172,7 @@ function creategroup($values) { // Will create the LDAP-Group
$attr['description'] = $values->general_gecos; $attr['description'] = $values->general_gecos;
if ($values->general_memeberUid) $attr['memberUid'] = $values->general_memberUid; if ($values->general_memeberUid) $attr['memberUid'] = $values->general_memberUid;
$success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr); $success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr);
if ($_SESSION['config']->scriptServer) setquotas($attr['uid'][0]); if ($_SESSION['config']->scriptServer) setquotas($attr['uid'][0],'group');
if ($success) return 1; if ($success) return 1;
else return 4; else return 4;
} }
@ -1201,7 +1206,7 @@ function modifygroup($values,$values_old) { // Will modify the LDAP-Group
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);
} }
} }
if ($_SESSION['config']->scriptServer) setquotas($attr['uid'][0]); if ($_SESSION['config']->scriptServer) setquotas($attr['uid'][0],'group');
return 3; return 3;
} }

View File

@ -272,7 +272,6 @@ if ($_POST['load']) $select_local='load';
if ($_POST['save']) $select_local='save'; if ($_POST['save']) $select_local='save';
switch ($select_local) { switch ($select_local) {
case 'general': case 'general':
// General Account Settings // General Account Settings

View File

@ -33,7 +33,6 @@ include_once('../lib/pdf.inc'); // Return a pdf-file
session_save_path('../sess'); session_save_path('../sess');
@session_start(); @session_start();
print_r($_FILES['userfile']);
if ($_POST['tolist'] && ($_FILES['userfile']['size']>0)) $select = 'list'; if ($_POST['tolist'] && ($_FILES['userfile']['size']>0)) $select = 'list';
if ($_POST['back']) $select = 'main'; if ($_POST['back']) $select = 'main';
if ($_POST['cancel']) $select = 'cancel'; if ($_POST['cancel']) $select = 'cancel';
@ -56,7 +55,8 @@ echo '</title>
switch ($select) { switch ($select) {
case 'main': case 'main':
// if session was started previos, the existing session will be continued if ( session_is_registered("accounts")) session_unregister("accounts");
session_register("accounts");
$profilelist = getUserProfiles(); $profilelist = getUserProfiles();
echo '<input name="select" type="hidden" value="main">'; echo '<input name="select" type="hidden" value="main">';
echo '<tr><td>'; echo '<tr><td>';
@ -84,15 +84,14 @@ switch ($select) {
echo '</td></tr>'; echo '</td></tr>';
break; break;
case 'list': case 'list':
if ( session_is_registered("accounts")) session_unregister("accounts");
session_register("accounts");
if (!is_array($accounts)) $accounts = array(); if (!is_array($accounts)) $accounts = array();
$handle = fopen($_FILES['userfile']['tmp_name'], 'r'); $handle = fopen($_FILES['userfile']['tmp_name'], 'r');
$error=false; $error=false;
$groups = array();
echo '<tr><td>'; echo '<tr><td>';
echo _('Confirm List'); echo _('Confirm List');
echo '</td></tr>'; echo '</td></tr>';
for ($row=0; $line_array=fgetcsv($handle,2048); ++$row) { // loops for every row for ($row=0; $line_array=fgetcsv($handle,2048); $row++) { // loops for every row
$_SESSION['accounts'][$row] = loadUserProfile($_POST['f_selectprofile']) ; $_SESSION['accounts'][$row] = loadUserProfile($_POST['f_selectprofile']) ;
if ($line_array[0]) $_SESSION['accounts'][$row]->general_surname = $line_array[0]; if ($line_array[0]) $_SESSION['accounts'][$row]->general_surname = $line_array[0];
if ($line_array[1]) $_SESSION['accounts'][$row]->general_givenname = $line_array[1]; if ($line_array[1]) $_SESSION['accounts'][$row]->general_givenname = $line_array[1];
@ -125,24 +124,35 @@ switch ($select) {
} }
if (!$error) { if (!$error) {
$values = checksamba($_SESSION['accounts'][$row], 'user'); // account.inc $values = checksamba($_SESSION['accounts'][$row], 'user'); // account.inc
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values)) // Set only defined values
if ($val) $_SESSION['accounts'][$row]->$key = $val; if ($val) $_SESSION['accounts'][$row]->$key = $val;
}
else $error = $values;
$values = checkquota($_SESSION['accounts'][$row], 'user'); // account.inc $values = checkquota($_SESSION['accounts'][$row], 'user'); // account.inc
}
if (!$error) {
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values)) // Set only defined values
if ($val) $_SESSION['accounts'][$row]->$key = $val; if ($val) $_SESSION['accounts'][$row]->$key = $val;
} }
else $error = $values;
}
if ($error) StatusMessage('ERROR', _('Invalid Value in row ').$row.'!', $error); if ($error) StatusMessage('ERROR', _('Invalid Value in row ').$row.'!', $error);
if (getgid($_SESSION['accounts'][$row]->general_group)==-1) StatusMessage('INFO', _('Group '). if ((getgid($_SESSION['accounts'][$row]->general_group)==-1) && (!in_array($_SESSION['accounts'][$row]->general_group, $groups))) $groups[] = $_SESSION['accounts'][$row]->general_group;
$_SESSION['accounts'][$row]->general_group._(' not found in row ').$row.'!', _('It will be created.'));
} }
for ($i=0; $i<sizeof($groups); $i++)
StatusMessage('INFO', _('Group ').
$_SESSION['accounts'][$i]->general_group._(' not found!'), _('It will be created.'));
fclose($handle); fclose($handle);
unlink($_FILES['userfile']['tmp_name']); unlink($_FILES['userfile']['tmp_name']);
echo '<tr><td>'. _('Surname'). '</td><td>'. _('Givenname'). '</td><td>'. _('Username'). '</td><td>'. _('Primary Group'). '</td><td>'. echo '<tr><td>'._('row').'</td><td>'. _('Surname'). '</td><td>'. _('Givenname'). '</td><td>'. _('Username'). '</td><td>'. _('Primary Group'). '</td><td>'.
_('Title'). '</td><td>'. _('Mail Address'). '</td><td>'. _('Telephonenumber'). '</td><td>'. _('Mobiletelephonenumber') _('Title'). '</td><td>'. _('Mail Address'). '</td><td>'. _('Telephonenumber'). '</td><td>'. _('Mobiletelephonenumber')
. '</td><td>'. _('Facsimiletelephonenumber'). '</td><td>'. _('Street'). '</td><td>'. _('Postal Code') . '</td><td>'. _('Facsimiletelephonenumber'). '</td><td>'. _('Street'). '</td><td>'. _('Postal Code')
. '</td><td>'. _('Postal Address'). '</td><td>'. _('Employee Type') .'</td></tr>'; . '</td><td>'. _('Postal Address'). '</td><td>'. _('Employee Type') .'</td></tr>';
for ($row=0; sizeof($_SESSION['accounts']); $row++) { // loops for every row for ($row=0; $row<sizeof($_SESSION['accounts']); $row++) { // loops for every row
echo '<tr><td>'.$_SESSION['accounts'][$row]->general_surname.'</td><td>'. echo '<tr><td>'.$row.'</td><td>'.
$_SESSION['accounts'][$row]->general_surname.'</td><td>'.
$_SESSION['accounts'][$row]->general_givenname.'</td><td>'. $_SESSION['accounts'][$row]->general_givenname.'</td><td>'.
$_SESSION['accounts'][$row]->general_username.'</td><td>'. $_SESSION['accounts'][$row]->general_username.'</td><td>'.
$_SESSION['accounts'][$row]->general_group.'</td><td>'. $_SESSION['accounts'][$row]->general_group.'</td><td>'.
@ -161,32 +171,34 @@ switch ($select) {
echo '</td><td><input name="create" type="submit" value="'; echo _('Create'); echo '">'; echo '</td><td><input name="create" type="submit" value="'; echo _('Create'); echo '">';
break; break;
case 'cancel': case 'cancel':
if ( session_is_registered("accounts")) session_unregister("accounts");
echo '<meta http-equiv="refresh" content="0; URL=lists/listusers.php">'; echo '<meta http-equiv="refresh" content="0; URL=lists/listusers.php">';
break; break;
case 'create': case 'create':
$row=0; $row=0;
while ($row < sizeof($_SESSION['accounts']) || $row!=-1) { $stay=true;
while (($row < sizeof($_SESSION['accounts'])) && $stay) {
if (getgid($_SESSION['accounts'][$row]->general_group)==-1) { if (getgid($_SESSION['accounts'][$row]->general_group)==-1) {
$group = new account(); $group = new account();
$group->general_username=$_SESSION['accounts'][$row]->general_group; $group->general_username=$_SESSION['accounts'][$row]->general_group;
$group->general_uidNumber=checkid($_SESSION['accounts'][$row], 'group'); $group->general_uidNumber=checkid($_SESSION['accounts'][$row], 'group');
$group->general_gecos=$_SESSION['accounts'][$row]->general_group; $group->general_gecos=$_SESSION['accounts'][$row]->general_group;
creategroup($_SESSION['accounts'][$row]); creategroup($group);
} }
$error = createuser($_SESSION['accounts'][$row]); $error = createuser($_SESSION['accounts'][$row]);
if ($error==1) $row++; if ($error==1) $row++;
else { else {
$row = -1; $stay = false;
StatusMessage('ERROR', _('Could not create user'), _('Was unable to create ').$_SESSION['accounts'][$row]->general_username); StatusMessage('ERROR', _('Could not create user'), _('Was unable to create ').$_SESSION['accounts'][$row]->general_username);
} }
} }
if ($row=-1) { echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Cancel'); echo '">'; } if (!$stay) { echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Cancel'); echo '">'; }
else { else {
echo '<tr><td>'; echo '<tr><td>';
echo _('All Users have been created'); echo _('All Users have been created');
echo '</td></tr><tr><td>'; echo '</td></tr><tr><td>';
echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Mainmenu'); echo '">'; echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Mainmenu'); echo '">';
echo '<tr><td><input name="pdf" type="submit" value="'; echo _('Create PDF-File'); echo '">'; echo '</td><td></td><td><input name="pdf" type="submit" value="'; echo _('Create PDF-File'); echo '">';
} }
break; break;
} }