fixed password handling in sambaAccount module
changed error code handling
This commit is contained in:
parent
b96fa3e32f
commit
d8b02d37aa
|
@ -663,6 +663,11 @@ returns an array the array contains status<br>
|
|||
messages. First Index is the attribute which has triggered a message.
|
||||
Second index is an array containing<br>
|
||||
status message arrays.<br>
|
||||
This function must reset $this->triggered_messages when it wants to
|
||||
display
|
||||
status messages. This can be done with $this->triggered_messages =
|
||||
array();<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<h3>2.2.15. proccess_*<br>
|
||||
|
|
|
@ -57,8 +57,8 @@ class baseModule {
|
|||
/** contains all ldap attributes which are loaded from ldap */
|
||||
var $orig;
|
||||
|
||||
/** contains all error messages wich were triggered*/
|
||||
var $errors;
|
||||
/** contains all messages wich were triggered*/
|
||||
var $triggered_messages;
|
||||
|
||||
/** contains all error messages of a module */
|
||||
var $messages;
|
||||
|
|
|
@ -77,14 +77,6 @@ class account extends baseModule {
|
|||
return array('attributes');
|
||||
}
|
||||
|
||||
/* This function returns all ldap attributes
|
||||
* which are part of account and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
|
@ -114,7 +106,7 @@ class account extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
// Load attributes
|
||||
$this->attributes['description'][0] = $post['description'];
|
||||
return 0;
|
||||
|
@ -124,7 +116,7 @@ class account extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $this->attributes['description'][0] ),
|
||||
|
@ -133,7 +125,7 @@ class account extends baseModule {
|
|||
return $return;
|
||||
}
|
||||
|
||||
function display_html_delete($post, $profile=false) {
|
||||
function display_html_delete($post) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -258,14 +258,6 @@ class inetOrgPerson extends baseModule {
|
|||
return array('attributes');
|
||||
}
|
||||
|
||||
/* This function returns all ldap attributes
|
||||
* which are part of inetOrgPerson and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
|
@ -301,7 +293,7 @@ class inetOrgPerson extends baseModule {
|
|||
return 0;
|
||||
}
|
||||
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
// Load attributes
|
||||
$this->attributes['description'][0] = $post['description'];
|
||||
$this->attributes['sn'][0] = $post['sn'];
|
||||
|
@ -320,7 +312,7 @@ class inetOrgPerson extends baseModule {
|
|||
if (isset($this->attributes['host'])) {
|
||||
$host = $post['host'];
|
||||
if (!get_preg($host,'unixhost'))
|
||||
$errors['host'][] = $this->messages['host'][0];
|
||||
$triggered_messages['host'][] = $this->messages['host'][0];
|
||||
$hosts = explode(" ", $host);
|
||||
$this->attributes['host'] = array();
|
||||
foreach ($hosts as $host)
|
||||
|
@ -328,21 +320,19 @@ class inetOrgPerson extends baseModule {
|
|||
}
|
||||
|
||||
// Do some regex-checks and return error if attributes are set to wrong values
|
||||
if (!$profile) {
|
||||
if ( !get_preg($this->attributes['givenName'][0], 'realname')) $errors['givenName'][] = $this->messages['givenName'][0];
|
||||
if ( !get_preg($this->attributes['sn'][0], 'realname')) $errors['sn'][] = $this->messages['surname'][0];
|
||||
if ( !get_preg($this->attributes['telephoneNumber'][0], 'telephone')) $errors['telephoneNumber'][] = $this->messages['telephoneNumber'][0];
|
||||
if ( !get_preg($this->attributes['mobileTelephoneNumber'][0], 'telephone')) $errors['mobileTelephoneNumber'][] = $this->messages['mobileTelephone'][0];
|
||||
if ( !get_preg($this->attributes['facsimileTelephoneNumber'][0], 'telephone')) $errors['facsimileTelephoneNumber'][] = $this->messages['facsimileNumber'][0];
|
||||
if ( !get_preg($this->attributes['mail'][0], 'email')) $errors['mail'][] = $this->messages['email'][0];
|
||||
if ( !get_preg($this->attributes['street'][0], 'street')) $errors['street'][] = $this->messages['street'][0];
|
||||
if ( !get_preg($this->attributes['postalAddress'][0], 'postalAddress')) $errors['postalAdress'][] = $this->messages['postalAddress'][0];
|
||||
if ( !get_preg($this->attributes['personal_postalCode'][0], 'postalCode')) $errors['personal_postalCode'][] = $this->messages['postalCode'][0];
|
||||
}
|
||||
if ( !get_preg($this->attributes['title'][0], 'title')) $errors['title'][] = $this->messages['title'][0];
|
||||
if ( !get_preg($this->attributes['employeeType'][0], 'employeeType')) $errors['employeeType'][] = $this->messages['employeeType'][0];
|
||||
if ( !get_preg($this->attributes['givenName'][0], 'realname')) $triggered_messages['givenName'][] = $this->messages['givenName'][0];
|
||||
if ( !get_preg($this->attributes['sn'][0], 'realname')) $triggered_messages['sn'][] = $this->messages['surname'][0];
|
||||
if ( !get_preg($this->attributes['telephoneNumber'][0], 'telephone')) $triggered_messages['telephoneNumber'][] = $this->messages['telephoneNumber'][0];
|
||||
if ( !get_preg($this->attributes['mobileTelephoneNumber'][0], 'telephone')) $triggered_messages['mobileTelephoneNumber'][] = $this->messages['mobileTelephone'][0];
|
||||
if ( !get_preg($this->attributes['facsimileTelephoneNumber'][0], 'telephone')) $triggered_messages['facsimileTelephoneNumber'][] = $this->messages['facsimileNumber'][0];
|
||||
if ( !get_preg($this->attributes['mail'][0], 'email')) $triggered_messages['mail'][] = $this->messages['email'][0];
|
||||
if ( !get_preg($this->attributes['street'][0], 'street')) $triggered_messages['street'][] = $this->messages['street'][0];
|
||||
if ( !get_preg($this->attributes['postalAddress'][0], 'postalAddress')) $triggered_messages['postalAdress'][] = $this->messages['postalAddress'][0];
|
||||
if ( !get_preg($this->attributes['personal_postalCode'][0], 'postalCode')) $triggered_messages['personal_postalCode'][] = $this->messages['postalCode'][0];
|
||||
if ( !get_preg($this->attributes['title'][0], 'title')) $triggered_messages['title'][] = $this->messages['title'][0];
|
||||
if ( !get_preg($this->attributes['employeeType'][0], 'employeeType')) $triggered_messages['employeeType'][] = $this->messages['employeeType'][0];
|
||||
// Return error-messages
|
||||
if (is_array($errors)) return $errors;
|
||||
if (is_array($triggered_messages)) return $triggered_messages;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -350,7 +340,7 @@ class inetOrgPerson extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $this->attributes['description'][0] ),
|
||||
|
@ -367,7 +357,6 @@ class inetOrgPerson extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'name' => 'title', 'type' => 'text', 'size' => '10',
|
||||
'value' => $this->attributes['title'][0] ),
|
||||
2 => array ('kind' => 'help', 'value' => 'title'));
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('First name').'*' ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'givenName', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $this->attributes['givenName'][0] ),
|
||||
|
@ -376,12 +365,10 @@ class inetOrgPerson extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'name' => 'sn', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $this->attributes['sn'][0] ),
|
||||
2 => array ('kind' => 'help', 'value' => 'sn'));
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Employee type') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'employeeType', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $this->attributes['employeeType'][0] ),
|
||||
2 => array ('kind' => 'help', 'value' => 'employeeType'));
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Street') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'street', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $this->attributes['street'][0] ),
|
||||
|
@ -410,11 +397,10 @@ class inetOrgPerson extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'name' => 'mail', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $this->attributes['mail'][0] ),
|
||||
2 => array ('kind' => 'help', 'value' => 'mail'));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function display_html_delete($post, $profile=false) {
|
||||
function display_html_delete($post) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -447,7 +433,7 @@ class inetOrgPerson extends baseModule {
|
|||
* @return array list of error messages if any
|
||||
*/
|
||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
||||
$errors = array();
|
||||
$triggered_messages = array();
|
||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson";
|
||||
// last name
|
||||
|
@ -457,7 +443,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['surname'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// first name
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_firstName']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_firstName']], 'realname')) {
|
||||
|
@ -466,7 +452,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['givenName'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// description
|
||||
if ($rawAccounts[$i][$ids['inetOrgPerson_description']] != "") {
|
||||
|
@ -487,7 +473,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['title'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// employee type
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_type']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_type']], 'employeeType')) {
|
||||
|
@ -496,7 +482,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['employeeType'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// street
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_street']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_street']], 'street')) {
|
||||
|
@ -505,7 +491,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['street'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// postal code
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_postalCode']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_postalCode']], 'postalCode')) {
|
||||
|
@ -514,7 +500,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['postalCode'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// postal address
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_address']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_address']], 'postalAddress')) {
|
||||
|
@ -523,7 +509,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['postalAddress'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// telephone
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_telephone']], 'telephone')) {
|
||||
|
@ -532,7 +518,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['telephone'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// mobile
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_mobile']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_mobile']], 'telephone')) {
|
||||
|
@ -541,7 +527,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['mobileTelephone'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// facsimile
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_fax']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_fax']], 'telephone')) {
|
||||
|
@ -550,7 +536,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['facsimileNumber'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// eMail
|
||||
if (($rawAccounts[$i][$ids['inetOrgPerson_email']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_email']], 'email')) {
|
||||
|
@ -559,7 +545,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['email'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// cn
|
||||
if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") {
|
||||
|
@ -569,7 +555,7 @@ class inetOrgPerson extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['email'][1];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -581,7 +567,7 @@ class inetOrgPerson extends baseModule {
|
|||
}
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
return $triggered_messages;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -398,16 +398,6 @@ class posixAccount extends baseModule {
|
|||
return array('attributes', 'group');
|
||||
}
|
||||
|
||||
/* This function returns all ldap attributes
|
||||
* which are part of posixAccount and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
$return = $this->attributes;
|
||||
$return['userPassword'] = $this->userPassword();
|
||||
return $return;
|
||||
}
|
||||
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
|
@ -552,22 +542,20 @@ class posixAccount extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
$this->attributes['homeDirectory'][0] = $post['homeDirectory'];
|
||||
$this->attributes['loginShell'][0] = $post['loginShell'];
|
||||
$this->attributes['gecos'][0] = $post['gecos'];
|
||||
if ($post['createhomedir']) $this->createhomedir = true;
|
||||
else $this->createhomedir = false;
|
||||
|
||||
if (!$profile) {
|
||||
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
|
||||
$errors['uid'][] = $this->messages['uid'][0];
|
||||
$triggered_messages['uid'][] = $this->messages['uid'][0];
|
||||
if ($this->orig['gidNumber'][0]!='' && $_SESSION['cache']->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0])
|
||||
$errors['gidNumber'][] = $this->dynamic_Message('gidNumber',0);
|
||||
$triggered_messages['gidNumber'][] = $this->dynamic_Message('gidNumber',0);
|
||||
if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0])
|
||||
$errors['uidNumber'][] = $this->dynamic_Message('uidNumber',0);
|
||||
$triggered_messages['uidNumber'][] = $this->dynamic_Message('uidNumber',0);
|
||||
if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0])
|
||||
$errors['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0);
|
||||
$triggered_messages['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0);
|
||||
// Load attributes
|
||||
$this->attributes['uid'][0] = $post['uid'];
|
||||
$this->attributes['cn'][0] = $this->attributes['uid'][0];
|
||||
|
@ -607,10 +595,10 @@ class posixAccount extends baseModule {
|
|||
$i = intval($minID);
|
||||
while (in_array($i, $uids)) $i++;
|
||||
if ($i>$maxID)
|
||||
$errors['uidNumber'][] = $this->messages['uidNumber'][1];
|
||||
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][1];
|
||||
else {
|
||||
$this->attributes['uidNumber'][0] = $i;
|
||||
$errors['uidNumber'][] = $this->messages['uidNumber'][2];
|
||||
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][2];
|
||||
}
|
||||
}
|
||||
else $this->attributes['uidNumber'][0] = $minID;
|
||||
|
@ -622,28 +610,27 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
// Check manual ID
|
||||
// id-number is out of valid range
|
||||
if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $errors['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
|
||||
if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $triggered_messages['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
|
||||
// $uids is allways an array but not if no entries were found
|
||||
if (is_array($uids)) {
|
||||
// id-number is in use and account is a new account
|
||||
if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
||||
if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $triggered_messages['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
||||
// id-number is in use, account is existing account and id-number is not used by itself
|
||||
if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) {
|
||||
$errors['uidNumber'][] = $this->messages['uidNumber'][3];
|
||||
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][3];
|
||||
$this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_SESSION[$this->base]->type=='user') {
|
||||
if (($this->attributes['uid'][0] != $post['uid']) && !get_preg($post['uid'], '!upper'))
|
||||
$errors['uid'][] = $this->messages['uid'][1];
|
||||
$triggered_messages['uid'][] = $this->messages['uid'][1];
|
||||
if ( !get_preg($this->attributes['homeDirectory'][0], 'homeDirectory' ))
|
||||
$errors['homeDirecotry'][] = $this->messages['homeDirectory'][0];
|
||||
$triggered_messages['homeDirecotry'][] = $this->messages['homeDirectory'][0];
|
||||
}
|
||||
|
||||
if (($post['userPassword_lock'] && $post['userPassword_invalid']) || ($post['userPassword_nopassword'] && $post['userPassword_invalid'])) {
|
||||
// found invalid password parameter combination
|
||||
$errors['userPassword'][] = $this->messages['userPassword'][3];
|
||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][3];
|
||||
}
|
||||
else {
|
||||
if ($post['userPassword_nopassword']) {
|
||||
|
@ -668,29 +655,28 @@ class posixAccount extends baseModule {
|
|||
if ($post['genpass']) $this->userPassword(genpasswd());
|
||||
else {
|
||||
if ($post['userPassword'] != $post['userPassword2'])
|
||||
$errors['userPassword'][] = $this->messages['userPassword'][0];
|
||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][0];
|
||||
else $this->userPassword($post['userPassword']);
|
||||
if (!get_preg($this->userPassword(), 'password'))
|
||||
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
||||
}
|
||||
if ($post['userPassword_lock']) $this->userPassword_lock=true;
|
||||
else $this->userPassword_lock=false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SESSION[$this->base]->type=='user') {
|
||||
$this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]);
|
||||
if ($this->attributes['uid'][0] != '')
|
||||
$this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]);
|
||||
if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $errors['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.'));
|
||||
if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $triggered_messages['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.'));
|
||||
// Check if Username contains only valid characters
|
||||
if ( !get_preg($this->attributes['uid'][0], 'username') && !$profile)
|
||||
$errors['uid'][] = $this->messages['uid'][2];
|
||||
$triggered_messages['uid'][] = $this->messages['uid'][2];
|
||||
}
|
||||
if ($_SESSION[$this->base]->type=='host') {
|
||||
// Check if Hostname contains only valid characters
|
||||
if ( !get_preg($this->attributes['uid'][0], 'hostname'))
|
||||
$errors['uid'][] = $this->messages['uid'][4];
|
||||
$triggered_messages['uid'][] = $this->messages['uid'][4];
|
||||
}
|
||||
// Create automatic useraccount with number if original user already exists
|
||||
// Reset name to original name if new name is in use
|
||||
|
@ -734,20 +720,19 @@ class posixAccount extends baseModule {
|
|||
// Show warning if lam has changed username
|
||||
if ($this->attributes['uid'][0] != $post['uid']) {
|
||||
if ($_SESSION[$this->base]->type=='user')
|
||||
$errors['uid'][] = $this->messages['uid'][5];
|
||||
$triggered_messages['uid'][] = $this->messages['uid'][5];
|
||||
if ($_SESSION[$this->base]->type=='host')
|
||||
$errors['uid'][] = $this->messages['uid'][6];
|
||||
$triggered_messages['uid'][] = $this->messages['uid'][6];
|
||||
}
|
||||
if (!get_preg($this->userPassword(), 'password'))
|
||||
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
||||
}
|
||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
||||
}
|
||||
// Return error-messages
|
||||
if (count($errors)!=0) {
|
||||
$this->errors = $errors;
|
||||
return $errors;
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->errors = array();
|
||||
else $this->triggered_messages = array();
|
||||
// Go to additional group page when no error did ocour and button was pressed
|
||||
if ($post['addgroup']) return 'group';
|
||||
return 0;
|
||||
|
@ -755,7 +740,7 @@ class posixAccount extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_group($post, $profile=false) {
|
||||
function proccess_group($post) {
|
||||
do { // X-Or, only one if() can be true
|
||||
if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
|
||||
// Add new group
|
||||
|
@ -778,18 +763,16 @@ class posixAccount extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
$groups = $_SESSION['cache']->findgroups(); // list of all groupnames
|
||||
$shelllist = getshells(); // list of all valid shells
|
||||
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Username").'*' ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['uid'][0]),
|
||||
2 => array ('kind' => 'help', 'value' => 'uid'));
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('UID number').'*' ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'uidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['uidNumber'][0]),
|
||||
2 => array ('kind' => 'help', 'value' => 'uidNumber'));
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Gecos') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'gecos', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['gecos'][0]),
|
||||
2 => array ('kind' => 'help', 'value' => 'gecos'));
|
||||
|
@ -799,15 +782,12 @@ class posixAccount extends baseModule {
|
|||
2 => array ('kind' => 'help', 'value' => 'gidNumber'));
|
||||
|
||||
if ($_SESSION[$this->base]->type=='user') {
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Additional groups') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'addgroup', 'type' => 'submit', 'value' => _('Edit groups')),
|
||||
2 => array ('kind' => 'help', 'value' => 'addgroup'));
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home directory').'*' ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'homeDirectory', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['homeDirectory'][0]),
|
||||
2 => array ('kind' => 'help', 'value' => 'homeDirectory'));
|
||||
if (!$profile) {
|
||||
if ($this->orig['homeDirectory']=='' && isset($_SESSION['config']->scriptPath)) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Create home directory') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'createhomedir', 'type' => 'checkbox', 'checked' => $this->createhomedir),
|
||||
|
@ -821,7 +801,6 @@ class posixAccount extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||
2 => array ('kind' => 'help', 'value' => 'userPassword'));
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Set no password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword_nopassword', 'type' => 'checkbox', 'checked' => $this->userPassword_nopassword),
|
||||
2 => array ('kind' => 'help', 'value' => 'userPassword_nopassword'));
|
||||
|
@ -837,7 +816,6 @@ class posixAccount extends baseModule {
|
|||
array ($this->attributes['loginShell'][0])),
|
||||
2 => array ('kind' => 'help', 'value' => 'loginShell'));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function display_html_delete($post) {
|
||||
|
@ -849,7 +827,7 @@ class posixAccount extends baseModule {
|
|||
return $return;
|
||||
}
|
||||
|
||||
function display_html_group($post, $profile=false) {
|
||||
function display_html_group($post) {
|
||||
// load list with all groups
|
||||
$dn_groups = $_SESSION['cache']->get_cache('gidNumber', 'posixGroup', 'group');
|
||||
$DNs = array_keys($dn_groups);
|
||||
|
@ -1012,7 +990,7 @@ class posixAccount extends baseModule {
|
|||
* @return array list of error messages if any
|
||||
*/
|
||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
||||
$errors = array();
|
||||
$triggered_messages = array();
|
||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||
if (!in_array("posixAccount", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixAccount";
|
||||
// UID
|
||||
|
@ -1026,7 +1004,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['uidNumber'][8]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// GID number
|
||||
if (get_preg($rawAccounts[$i][$ids['posixAccount_group']], 'digit')) {
|
||||
|
@ -1040,7 +1018,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['gidNumber'][8]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// GECOS // TODO fill default values
|
||||
if (($rawAccounts[$i][$ids['posixAccount_gecos']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_gecos']], 'gecos'))) {
|
||||
|
@ -1049,7 +1027,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['gecos'][1]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// user specific attributes
|
||||
if ($this->scope == 'user') {
|
||||
|
@ -1060,7 +1038,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['username'][1]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// home directory
|
||||
if ($rawAccounts[$i][$ids['posixAccount_homedir']] == "") {
|
||||
|
@ -1072,7 +1050,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['homedir'][8]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// login shell
|
||||
if ($rawAccounts[$i][$ids['posixAccount_shell']] == "") {
|
||||
|
@ -1084,7 +1062,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['loginshell'][8]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
$pwd_enabled = true;
|
||||
// password enabled/disabled
|
||||
|
@ -1098,7 +1076,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['passwordDisabled'][8]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// password
|
||||
if (($rawAccounts[$i][$ids['posixAccount_password']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_password']], 'password'))) {
|
||||
|
@ -1107,7 +1085,7 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['password'][8]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
}
|
||||
// host specific attributes
|
||||
|
@ -1119,13 +1097,13 @@ class posixAccount extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['hostname'][1]; // TODO
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
$partialAccounts[$i]['homeDirectory'] = '/dev/null';
|
||||
$partialAccounts[$i]['loginShell'] = '/bin/false';
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
return $triggered_messages;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class posixGroup extends baseModule {
|
|||
* @return array list of error messages if any
|
||||
*/
|
||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
||||
$errors = array();
|
||||
$triggered_messages = array();
|
||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||
if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
|
||||
// group name
|
||||
|
@ -63,7 +63,7 @@ class posixGroup extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['cn'][3];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// GID
|
||||
if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") {
|
||||
|
@ -76,7 +76,7 @@ class posixGroup extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['gidNumber'][8];
|
||||
array_push($errMsg, array($i));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
// description (UTF-8, no regex check needed)
|
||||
if ($rawAccounts[$i][$ids['posixGroup_description']] == "") {
|
||||
|
@ -93,7 +93,7 @@ class posixGroup extends baseModule {
|
|||
else {
|
||||
$errMsg = $this->messages['memberUID'][0];
|
||||
array_push($errMsg, $i);
|
||||
$errors[] =$errMsg;
|
||||
$triggered_messages[] =$errMsg;
|
||||
}
|
||||
}
|
||||
// password
|
||||
|
@ -102,11 +102,11 @@ class posixGroup extends baseModule {
|
|||
$partialAccounts[$i]['userPassword'] = pwd_hash($rawAccounts[$i][$ids['posixGroup_password']], true, $this->moduleSettings['posixAccount_pwdHash'][0]);
|
||||
}
|
||||
else {
|
||||
$errors[] = $this->messages['userPassword'][1];
|
||||
$triggered_messages[] = $this->messages['userPassword'][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
return $triggered_messages;
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,18 +122,15 @@ class posixGroup extends baseModule {
|
|||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post) {
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Groupname").'*' ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['cn'][0]),
|
||||
2 => array ('kind' => 'help', 'value' => 'cn'));
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('GID number').'*' ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['gidNumber'][0]),
|
||||
2 => array ('kind' => 'help', 'value' => 'gidNumber'));
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]),
|
||||
2 => array ('kind' => 'help', 'value' => 'description'));
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Group members").'*' ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'adduser', 'type' => 'submit', 'value' => _('Edit groups')),
|
||||
2 => array ('kind' => 'help', 'value' => 'adduser'));
|
||||
|
@ -145,7 +142,6 @@ class posixGroup extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||
2 => array ('kind' => 'help', 'value' => 'userPassword'));
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Set no password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword_nopassword', 'type' => 'checkbox', 'checked' => $this->userPassword_nopassword),
|
||||
2 => array ('kind' => 'help', 'value' => 'userPassword_nopassword'));
|
||||
|
@ -155,11 +151,10 @@ class posixGroup extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Lock password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword_lock', 'type' => 'checkbox', 'checked' => $this->userPassword_lock),
|
||||
2 => array ('kind' => 'help', 'value' => 'userPassword_lock'));
|
||||
if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='' && !$profile) {
|
||||
if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='')
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Change GID number of users and hosts') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'changegids', 'type' => 'checkbox', 'checked' => $this->changegids, 'value' => true),
|
||||
2 => array ('kind' => 'help', 'value' => 'changegids'));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -170,7 +165,7 @@ class posixGroup extends baseModule {
|
|||
}
|
||||
|
||||
|
||||
function display_html_user($post, $profile=false) {
|
||||
function display_html_user($post) {
|
||||
// load list with all groups
|
||||
$dn_users = $_SESSION['cache']->get_cache('uid', 'posixAccount', 'user');
|
||||
if (is_array($dn_users)) {
|
||||
|
@ -212,17 +207,6 @@ class posixGroup extends baseModule {
|
|||
}
|
||||
|
||||
|
||||
/** This function returns all ldap attributes
|
||||
* which are part of posixGroup and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
$return = $this->attributes;
|
||||
$return['userPassword'] = $this->userPassword();
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns meta data that is interpreted by parent class
|
||||
*
|
||||
|
@ -457,13 +441,12 @@ class posixGroup extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
$this->attributes['description'][0] = $post['description'];
|
||||
|
||||
If (!$profile) {
|
||||
if (($post['userPassword_lock'] && $post['userPassword_invalid']) || ($post['userPassword_nopassword'] && $post['userPassword_invalid'])) {
|
||||
// found invalid password parameter combination
|
||||
$errors['userPassword'][] = $this->messages['userPassword'][3];
|
||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][3];
|
||||
}
|
||||
else {
|
||||
if ($post['userPassword_nopassword']) {
|
||||
|
@ -488,10 +471,10 @@ class posixGroup extends baseModule {
|
|||
if ($post['genpass']) $this->userPassword(genpasswd());
|
||||
else {
|
||||
if ($post['userPassword'] != $post['userPassword2'])
|
||||
$errors['userPassword'][] = $this->messages['userPassword'][0];
|
||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][0];
|
||||
else $this->userPassword($post['userPassword']);
|
||||
if (!get_preg($this->userPassword(), 'password'))
|
||||
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
||||
}
|
||||
if ($post['userPassword_lock']) $this->userPassword_lock=true;
|
||||
else $this->userPassword_lock=false;
|
||||
|
@ -499,7 +482,7 @@ class posixGroup extends baseModule {
|
|||
}
|
||||
if ($post['changegids']) $this->changegids=true;
|
||||
else $this->changegids=false;
|
||||
if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->errors['gidNumber'][0]='ERROR')) {
|
||||
if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->triggered_messages['gidNumber'][0]='ERROR')) {
|
||||
// Check if GID is valid. If none value was entered, the next useable value will be inserted
|
||||
// load min and may uidNumber
|
||||
$minID = intval($this->moduleSettings['posixGroup_minGID'][0]);
|
||||
|
@ -529,10 +512,10 @@ class posixGroup extends baseModule {
|
|||
$i = intval($minID);
|
||||
while (in_array($i, $gids)) $i++;
|
||||
if ($i>$maxID)
|
||||
$errors['gidNumber'][] = $this->messages['gidNumber'][3];
|
||||
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][3];
|
||||
else {
|
||||
$this->attributes['gidNumber'][0] = $i;
|
||||
$errors['gidNumber'][] = $this->messages['gidNumber'][2];
|
||||
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][2];
|
||||
}
|
||||
}
|
||||
else $this->attributes['gidNumber'][0] = $minID;
|
||||
|
@ -544,26 +527,26 @@ class posixGroup extends baseModule {
|
|||
else {
|
||||
// Check manual ID
|
||||
// id-number is out of valid range
|
||||
if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $errors['gidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
|
||||
if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $triggered_messages['gidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
|
||||
// $uids is allways an array but not if no entries were found
|
||||
if (is_array($gids)) {
|
||||
// id-number is in use and account is a new account
|
||||
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
||||
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $triggered_messages['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
||||
// id-number is in use, account is existing account and id-number is not used by itself
|
||||
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) {
|
||||
$errors['gidNumber'][] = $this->messages['gidNumber'][4];
|
||||
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][4];
|
||||
$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->attributes['cn'][0]!=$post['cn'] || ($this->errors['cn'][0]='ERROR')) {
|
||||
if ($this->attributes['cn'][0]!=$post['cn'] || ($this->triggered_messages['cn'][0]='ERROR')) {
|
||||
$this->attributes['cn'][0] = $post['cn'];
|
||||
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
|
||||
$errors['cn'][] = $this->messages['cn'][0];
|
||||
$triggered_messages['cn'][] = $this->messages['cn'][0];
|
||||
// Check if Groupname contains only valid characters
|
||||
if ( !get_preg($this->attributes['cn'][0],'groupname'))
|
||||
$errors['cn'][] = $this->messages['cn'][2];
|
||||
$triggered_messages['cn'][] = $this->messages['cn'][2];
|
||||
// Create automatic useraccount with number if original user already exists
|
||||
// Reset name to original name if new name is in use
|
||||
// Set username back to original name if new username is in use
|
||||
|
@ -603,20 +586,19 @@ class posixGroup extends baseModule {
|
|||
}
|
||||
// Show warning if lam has changed username
|
||||
if ($this->attributes['cn'][0] != $post['cn']) {
|
||||
$errors['cn'][] = $this->messages['cn'][0];
|
||||
$triggered_messages['cn'][] = $this->messages['cn'][0];
|
||||
}
|
||||
// show info when gidnumber has changed
|
||||
if (($this->orig['gidNumber'][0]!=$this->attributes['gidNumber'][0]) && $this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0])
|
||||
$errors['gidNumber'][] = $this->messages['gidNumber'][0];
|
||||
}
|
||||
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][0];
|
||||
}
|
||||
}
|
||||
// Return error-messages
|
||||
if (count($errors)!=0) {
|
||||
$this->errors = $errors;
|
||||
return $errors;
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->errors = array();
|
||||
else $this->triggered_messages = array();
|
||||
// Go to additional group page when no error did ocour and button was pressed
|
||||
if ($post['adduser']) return 'user';
|
||||
return 0;
|
||||
|
@ -625,7 +607,7 @@ class posixGroup extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_user($post, $profile=false) {
|
||||
function proccess_user($post) {
|
||||
do { // X-Or, only one if() can be true
|
||||
if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add groups to list
|
||||
// Add new user
|
||||
|
@ -783,6 +765,7 @@ class posixGroup extends baseModule {
|
|||
else return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -252,7 +252,7 @@ class quota extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
// Write all general values into $account_new
|
||||
$i=0;
|
||||
// loop for every mointpoint with quotas
|
||||
|
@ -263,22 +263,25 @@ class quota extends baseModule {
|
|||
$this->quota[$i][7] = $post[$i . '_7'];
|
||||
// Check if values are OK and set automatic values. if not error-variable will be set
|
||||
if (!get_preg($this->quota[$i][2], 'digit'))
|
||||
$errors[$this->quota[$i][2]][] = $this->messages['softblock'][0];
|
||||
$triggered_messages[$this->quota[$i][2]][] = $this->messages['softblock'][0];
|
||||
if (!get_preg($this->quota[$i][3], 'digit'))
|
||||
$errors[$this->quota[$i][3]][] = $this->messages['hardblock'][0];
|
||||
$triggered_messages[$this->quota[$i][3]][] = $this->messages['hardblock'][0];
|
||||
if (!get_preg($this->quota[$i][6], 'digit'))
|
||||
$errors[$this->quota[$i][6]][] = $this->messages['softinode'][0];
|
||||
$triggered_messages[$this->quota[$i][6]][] = $this->messages['softinode'][0];
|
||||
if (!get_preg($this->quota[$i][7], 'digit'))
|
||||
$errors[$this->quota[$i][7]][] = $this->messages['hardinode'][0];
|
||||
$triggered_messages[$this->quota[$i][7]][] = $this->messages['hardinode'][0];
|
||||
if (intval($this->quota[$i][2]) > intval($this->quota[$i][3]))
|
||||
$errors[$this->quota[$i][2]][] = $this->messages['block_cmp'][0];
|
||||
$triggered_messages[$this->quota[$i][2]][] = $this->messages['block_cmp'][0];
|
||||
if (intval($this->quota[$i][6]) > intval($this->quota[$i][7]))
|
||||
$errors[$this->quota[$i][6]][] = $this->messages['inode_cmp'][0];
|
||||
$triggered_messages[$this->quota[$i][6]][] = $this->messages['inode_cmp'][0];
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Return error-messages
|
||||
if (is_array($errors)) return $errors;
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->triggered_messages = array();
|
||||
// Go to additional group page when no error did ocour and button was pressed
|
||||
return 0;
|
||||
}
|
||||
|
@ -287,7 +290,7 @@ class quota extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Mountpoint') ),
|
||||
1 => array ( 'kind' => 'text', 'text' => _('Used blocks') ),
|
||||
|
|
|
@ -175,8 +175,8 @@ class sambaAccount extends baseModule {
|
|||
// Array of well known rids
|
||||
var $rids;
|
||||
|
||||
/* $attribute['lmPassword'] and ntPassword can't accessed directly because it's enrcypted
|
||||
* To read / write password function userPassword is needed
|
||||
/* $attribute['lmPassword'] and $attribute['ntPassword'] can't accessed directly because it's enrcypted
|
||||
* To read / write password function lmPassword is needed
|
||||
* This function will return the unencrypted password when
|
||||
* called without a variable
|
||||
* If it's called with a new password, the
|
||||
|
@ -185,7 +185,9 @@ class sambaAccount extends baseModule {
|
|||
function lmPassword($newpassword=false) {
|
||||
if (is_string($newpassword)) {
|
||||
// Write new password
|
||||
$this->attributes['lmPassword'][0] = base64_encode($_SESSION['ldap']->encrypt($newpassword));
|
||||
if ($newpassword=='')
|
||||
$this->attributes['lmPassword'][0] = '';
|
||||
else $this->attributes['lmPassword'][0] = base64_encode($_SESSION['ldap']->encrypt($newpassword));
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
@ -303,7 +305,7 @@ class sambaAccount extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
$this->attributes['domain'][0] = $post['domain'];
|
||||
// Start character
|
||||
$flag = "[";
|
||||
|
@ -320,7 +322,7 @@ class sambaAccount extends baseModule {
|
|||
$flag = $flag. "]";
|
||||
$this->attributes['acctFlags'][0] = $flag;
|
||||
|
||||
if ($_SESSION[$this->base]->type=='host' && !$profile) {
|
||||
if ($_SESSION[$this->base]->type=='host') {
|
||||
$this->attributes['primaryGroupID'][0] = $this->rids[_('Domain Computers')];
|
||||
if ($post['ResetSambaPassword']) {
|
||||
// *** fixme. What is the default password?
|
||||
|
@ -339,7 +341,6 @@ class sambaAccount extends baseModule {
|
|||
$this->attributes['homeDrive'][0] = $post['homeDrive'];
|
||||
$this->attributes['scriptPath'][0] = stripslashes($post['scriptPath']);
|
||||
$this->attributes['profilePath'][0] = stripslashes($post['profilePath']);
|
||||
if (!$profile) {
|
||||
$rids = array_keys($this->rids);
|
||||
$wrid = false;
|
||||
for ($i=0; $i<count($rids); $i++) {
|
||||
|
@ -349,42 +350,45 @@ class sambaAccount extends baseModule {
|
|||
}
|
||||
}
|
||||
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
|
||||
|
||||
if ($post['useunixpwd']) $this->useunixpwd = true;
|
||||
else $this->useunixpwd = false;
|
||||
if (isset($post['lmPassword'])) {
|
||||
if ($post['lmPassword'] != $post['lmPassword2']) {
|
||||
$errors['lmPassword'][] = $this->messages['lmPassword'][0];
|
||||
$triggered_messages['lmPassword'][] = $this->messages['lmPassword'][0];
|
||||
unset ($post['lmPassword2']);
|
||||
}
|
||||
else {
|
||||
if ( !get_preg($this->lmPassword(), 'password')) $triggered_messages['lmPassword'][] = $this->messages['lmPassword'][1];
|
||||
else $this->lmPassword($post['lmPassword']);
|
||||
}
|
||||
}
|
||||
if ($post['rid']== _('Administrator')) {
|
||||
$this->attributes['rid'][0] = "500";
|
||||
// Do a check if an administrator already exists
|
||||
if ($_SESSION['cache']->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
|
||||
$errors['rid'][] = $this->messages['rid'][0];
|
||||
$triggered_messages['rid'][] = $this->messages['rid'][0];
|
||||
}
|
||||
if ($post['rid']== _('Guest')) {
|
||||
$this->attributes['rid'][0] = "501";
|
||||
// Do a check if an administrator already exists
|
||||
if ($_SESSION['cache']->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
|
||||
$errors['rid'][] = $this->messages['rid'][1];
|
||||
$triggered_messages['rid'][] = $this->messages['rid'][1];
|
||||
}
|
||||
$this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]);
|
||||
$this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]);
|
||||
if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $errors['smbHome'][] = $this->messages['homePath'][1];
|
||||
if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $triggered_messages['smbHome'][] = $this->messages['homePath'][1];
|
||||
$this->attributes['scriptPath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['scriptPath'][0]);
|
||||
$this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['scriptPath'][0]);
|
||||
if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $errors['scriptPath'][] = $this->messages['logonScript'][1];
|
||||
if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $triggered_messages['scriptPath'][] = $this->messages['logonScript'][1];
|
||||
$this->attributes['profilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['profilePath'][0]);
|
||||
$this->attributes['profilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['profilePath'][0]);
|
||||
if ($this->attributes['profiletPath'][0] != stripslashes($post['profilePath'])) $errors['profilePath'][] = $this->messages['profilePath'][1];
|
||||
if ( !get_preg($this->lmPassword(), 'passord')) $errors['lmPassword'][] = $this->messages['lmPassword'][1];
|
||||
if ($this->attributes['profiletPath'][0] != stripslashes($post['profilePath'])) $triggered_messages['profilePath'][] = $this->messages['profilePath'][1];
|
||||
if ( (!$this->attributes['smbHome'][0]=='') && (!get_preg($this->attributes['smbHome'][0], 'UNC')))
|
||||
$errors['smbHome'][] = $this->messages['homedir'][0];
|
||||
$triggered_messages['smbHome'][] = $this->messages['homedir'][0];
|
||||
if ( (!$this->attributes['scriptPath'][0]=='') && (!get_preg($this->attributes['scriptPath'][0], 'logonscript')))
|
||||
$errors['scriptPath'][] = $this->messages['logonScript'][0];
|
||||
$triggered_messages['scriptPath'][] = $this->messages['logonScript'][0];
|
||||
if ( (!$this->attributes['profilePath'][0]=='') && (!get_preg($this->attributes['profilePath'][0], 'UNC')))
|
||||
$errors['profilePath'][] = $this->messages['profilePath'][0];
|
||||
$triggered_messages['profilePath'][] = $this->messages['profilePath'][0];
|
||||
}
|
||||
else {
|
||||
$smbHome = str_replace('$user', 'user', $this->attributes['smbHome'][0]);
|
||||
|
@ -394,29 +398,29 @@ class sambaAccount extends baseModule {
|
|||
$profilePath = str_replace('$user', 'user', $this->attributes['profilePath'][0]);
|
||||
$profilePath = str_replace('$group', 'group', $profilePath);
|
||||
if ( (!$smbHome=='') && (!get_preg($smbHome, 'UNC')))
|
||||
$errors['smbHome'][] = $this->messages['homePath'][0];
|
||||
$triggered_messages['smbHome'][] = $this->messages['homePath'][0];
|
||||
if ( (!$scriptPath=='') && (!get_preg($scriptPath, 'logonscript')))
|
||||
$errors['scriptPath'][] = $this->messages['logonScript'][0];
|
||||
$triggered_messages['scriptPath'][] = $this->messages['logonScript'][0];
|
||||
if ( (!$profilePath=='') && (!get_preg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $profilePath))
|
||||
&& (!get_preg($profilePath, 'UNC')))
|
||||
$errors['profilePath'][] = $this->messages['profilePath'][0];
|
||||
}
|
||||
|
||||
if ($post['useunixpwd']) $this->useunixpwd = true;
|
||||
else $this->useunixpwd = false;
|
||||
$triggered_messages['profilePath'][] = $this->messages['profilePath'][0];
|
||||
}
|
||||
|
||||
if ((!$this->attributes['domain'][0]=='') && !get_preg($this->attributes['domain'][0], 'domainname'))
|
||||
$errors['domain'][] = $this->messages['domain'][0];
|
||||
$triggered_messages['domain'][] = $this->messages['domain'][0];
|
||||
|
||||
if (is_array($errors)) return $errors;
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->triggered_messages = array();
|
||||
if ($post['userWorkstations']) return 'userWorkstations';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_userWorkstations($post, $profile=false) {
|
||||
function proccess_userWorkstations($post) {
|
||||
// Load attributes
|
||||
if ($_SESSION[$this->base]->type=='user') {
|
||||
do { // X-Or, only one if() can be true
|
||||
|
@ -467,7 +471,7 @@ class sambaAccount extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
if ($_SESSION[$this->base]->type=='user') {
|
||||
$canchangedate = getdate($this->attributes['pwdCanChange'][0]);
|
||||
$mustchangedate = getdate($this->attributes['pwdMustChange'][0]);
|
||||
|
@ -479,17 +483,13 @@ class sambaAccount extends baseModule {
|
|||
5 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
|
||||
6 => array ( 'kind' => 'input', 'name' => 'acctFlagsU', 'type' => 'hidden', 'value' => 'true'));
|
||||
|
||||
if (!$profile) {
|
||||
if ($this->attributes['lmPassword'][0] != $this->orig['lmPassword'][0]) $password=$this->lmPassword();
|
||||
else if ($this->attributes['lmPassword'][0] != '') $password=$post['lmPassword'];
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password));
|
||||
if ($post['lmPassword2']!='') $password2 = $post['lmPassword2'];
|
||||
else $password2 = $this->lmPassword();
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->lmPassword()));
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'lmPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||
2 => array ('kind' => 'help', 'value' => 'lmPassword'));
|
||||
}
|
||||
|
||||
if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use unix password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd, 'value' => true),
|
||||
|
@ -546,7 +546,6 @@ class sambaAccount extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations', 'value' => _('Edit workstations')),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'userWorkstations' ));
|
||||
|
||||
if (!$profile) {
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
|
@ -582,11 +581,8 @@ class sambaAccount extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||
1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'domain' ));
|
||||
}
|
||||
|
||||
if ($_SESSION[$this->base]->type=='host') {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'acctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
|
||||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
|
||||
|
@ -594,8 +590,6 @@ class sambaAccount extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||
1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'domain' ));
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class sambaGroupMapping extends baseModule {
|
|||
for ($i = 0; $i < sizeof($domains); $i++) {
|
||||
$nameToRIDBase[$domains[$i]->name] = $domains[$i]->RIDbase;
|
||||
}
|
||||
$errors = array();
|
||||
$triggered_messages = array();
|
||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||
// group type
|
||||
if ($rawAccounts[$i][$ids['sambaGroupMapping_groupType']] != "") {
|
||||
|
@ -94,7 +94,7 @@ class sambaGroupMapping extends baseModule {
|
|||
else { // invalid type
|
||||
$errMsg = $this->messages['groupType'][0];
|
||||
array_push($errMsg, array($i, implode(", ", array_keys($this->sambaGroupTypes) + $this->sambaGroupTypes)));
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -107,7 +107,7 @@ class sambaGroupMapping extends baseModule {
|
|||
$errMsg = $this->messages['sambaSID'][1];
|
||||
array_push($errMsg, $rawAccounts[$i][$ids['sambaGroupMapping_domain']]);
|
||||
array_push($errMsg, $i);
|
||||
$errors[] = $errMsg;
|
||||
$triggered_messages[] = $errMsg;
|
||||
}
|
||||
else {
|
||||
// RID
|
||||
|
@ -130,7 +130,7 @@ class sambaGroupMapping extends baseModule {
|
|||
$partialAccounts[$i]['displayName'] = $rawAccounts[$i][$ids['sambaGroupMapping_name']];
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
return $triggered_messages;
|
||||
}
|
||||
|
||||
function delete_attributes($post) {
|
||||
|
@ -142,7 +142,7 @@ class sambaGroupMapping extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
// Get Domain SID from name
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
// Get Domain-SID from group SID
|
||||
|
@ -160,7 +160,6 @@ class sambaGroupMapping extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $this->attributes['displayName'][0]),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'displayName' ));
|
||||
|
||||
if (!$profile) {
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
|
@ -175,7 +174,6 @@ class sambaGroupMapping extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
|
||||
}
|
||||
|
||||
$names = array_keys($this->sambaGroupTypes);
|
||||
$selected = array( _('Domain Group') );
|
||||
|
@ -371,12 +369,11 @@ class sambaGroupMapping extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
// Save attributes
|
||||
$this->attributes['displayName'][0] = $post['displayName'];
|
||||
$this->attributes['sambaGroupType'][0] = $this->sambaGroupTypes[$post['sambaGroupType']];
|
||||
|
||||
if (!$profile) {
|
||||
// Get Domain SID from name
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
for ($i=0; $i<count($sambaDomains); $i++ )
|
||||
|
@ -384,10 +381,8 @@ class sambaGroupMapping extends baseModule {
|
|||
$SID = $sambaDomains[$i]->SID;
|
||||
$RIDbase = $sambaDomain[$i]->RIDbase;
|
||||
}
|
||||
|
||||
// Load attributes
|
||||
$this->attributes['displayName'][0] = $post['displayName'];
|
||||
|
||||
$rids = array_keys($this->rids);
|
||||
$wrid = false;
|
||||
for ($i=0; $i<count($rids); $i++) {
|
||||
|
@ -397,14 +392,17 @@ class sambaGroupMapping extends baseModule {
|
|||
$this->attributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]];
|
||||
// Do a check if special grou pis unique
|
||||
if ($_SESSION['cache']->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group'))
|
||||
$errors[] = $this->messages['sambaSID'][0];
|
||||
$triggered_messages[] = $this->messages['sambaSID'][0];
|
||||
}
|
||||
}
|
||||
if (!$wrid) $this->attributes['sambaSID'][0] = $SID . "-" . ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+$RIDbase+1);
|
||||
}
|
||||
|
||||
// Return error-messages
|
||||
if (is_array($errors)) return $errors;
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->triggered_messages = array();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,8 +116,8 @@ class sambaSamAccount extends baseModule {
|
|||
var $rids;
|
||||
|
||||
|
||||
/* $attribute['sambaLMPassword'] and sambaNTPassword can't accessed directly because it's enrcypted
|
||||
* To read / write password function userPassword is needed
|
||||
/* $attribute['sambaLMPassword'] and $attribute['sambaNTPassword'] can't accessed directly because it's enrcypted
|
||||
* To read / write password function sambaLMPassword is needed
|
||||
* This function will return the unencrypted password when
|
||||
* called without a variable
|
||||
* If it's called with a new password, the
|
||||
|
@ -127,7 +127,7 @@ class sambaSamAccount extends baseModule {
|
|||
if (is_string($newpassword)) {
|
||||
// Write new password
|
||||
if ($newpassword=='')
|
||||
$this->attributes['userPassword'][0] = '';
|
||||
$this->attributes['sambaLMPassword'][0] = '';
|
||||
else $this->attributes['sambaLMPassword'][0] = base64_encode($_SESSION['ldap']->encrypt($newpassword));
|
||||
return 0;
|
||||
}
|
||||
|
@ -178,17 +178,6 @@ class sambaSamAccount extends baseModule {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* This function returns all ldap attributes
|
||||
* which are part of posixAccount and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
$return = $this->attributes;
|
||||
$return['sambaLMPassword'] = $this->sambaLMPassword();
|
||||
$return['sambaNTPassword'] = $this->sambaLMPassword();
|
||||
return $return;
|
||||
}
|
||||
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
|
@ -267,7 +256,7 @@ class sambaSamAccount extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
// Save attributes
|
||||
$this->attributes['sambaDomainName'][0] = $post['sambaDomainName'];
|
||||
// Get Domain SID from name
|
||||
|
@ -321,28 +310,27 @@ class sambaSamAccount extends baseModule {
|
|||
|
||||
if ($post['useunixpwd']) $this->useunixpwd = true;
|
||||
else $this->useunixpwd = false;
|
||||
if (isset($post['sambaLMPassword']) && !$profile) {
|
||||
if (isset($post['sambaLMPassword'])) {
|
||||
if ($post['sambaLMPassword'] != $post['sambaLMPassword2']) {
|
||||
$errors['sambaLMPassword'][] = $this->messages['sambaLMPassword'][0];
|
||||
$triggered_messages['sambaLMPassword'][] = $this->messages['sambaLMPassword'][0];
|
||||
unset ($post['sambaLMPassword2']);
|
||||
}
|
||||
else {
|
||||
if ( !get_preg($this->sambaLMPassword(), 'password')) $errors['sambaLMPassword'][] = $this->messages['sambaLMPassword'][1];
|
||||
if ( !get_preg($this->sambaLMPassword(), 'password')) $triggered_messages['sambaLMPassword'][] = $this->messages['sambaLMPassword'][1];
|
||||
else $this->sambaLMPassword($post['sambaLMPassword']);
|
||||
}
|
||||
}
|
||||
if (!$profile) {
|
||||
if ($post['sambaSID']== _('Administrator')) {
|
||||
$this->attributes['sambaSID'][0] = $SID."-500";
|
||||
// Do a check if an administrator already exists
|
||||
if ($_SESSION['cache']->in_cache($SID."-500", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
|
||||
$errors['sambaSID'][] = $this->messages['rid'][0];
|
||||
$triggered_messages['sambaSID'][] = $this->messages['rid'][0];
|
||||
}
|
||||
else if ($post['sambaSID']== _('Guest')) {
|
||||
$this->attributes['sambaSID'][0] = $SID."-501";
|
||||
// Do a check if an guest already exists
|
||||
if ($_SESSION['cache']->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
|
||||
$errors['sambaSID'][] = $this->messages['rid'][1];
|
||||
$triggered_messages['sambaSID'][] = $this->messages['rid'][1];
|
||||
}
|
||||
else if ($post['sambaSID']== _('Ordinary user')) {
|
||||
$this->attributes['sambaSID'][0] = $SID."-". (($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2)+$RIDbase);
|
||||
|
@ -350,20 +338,20 @@ class sambaSamAccount extends baseModule {
|
|||
// Check values
|
||||
$this->attributes['sambaHomePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaHomePath'][0]);
|
||||
$this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaHomePath'][0]);
|
||||
if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $errors['sambaHomePath'][] = $this->messages['homePath'][1];
|
||||
if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $triggered_messages['sambaHomePath'][] = $this->messages['homePath'][1];
|
||||
$this->attributes['sambaLogonScript'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]);
|
||||
$this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaLogonScript'][0]);
|
||||
if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $errors['sambaLogonScript'][] = $this->messages['logonScript'][1];
|
||||
if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $triggered_messages['sambaLogonScript'][] = $this->messages['logonScript'][1];
|
||||
$this->attributes['sambaProfilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaProfilePath'][0]);
|
||||
$this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaProfilePath'][0]);
|
||||
if ($this->attributes['sambaProfilePath'][0] != stripslashes($post['sambaProfilePath'])) $errors['sambaProfilePath'][] = $this->messages['profilePath'][1];
|
||||
if ($this->attributes['sambaProfilePath'][0] != stripslashes($post['sambaProfilePath'])) $triggered_messages['sambaProfilePath'][] = $this->messages['profilePath'][1];
|
||||
if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC')))
|
||||
$errors['sambaHomePath'][] = $this->messages['homePath'][0];
|
||||
$triggered_messages['sambaHomePath'][] = $this->messages['homePath'][0];
|
||||
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
|
||||
$errors['sambaScriptPath'][] = $this->messages['logonScript'][0];
|
||||
$triggered_messages['sambaScriptPath'][] = $this->messages['logonScript'][0];
|
||||
if (!($this->attributes['sambaProfilePath'][0] == '') &&
|
||||
!(get_preg($this->attributes['sambaProfilePath'][0], 'UNC') xor get_preg($this->attributes['sambaProfilePath'][0], 'homeDirectory')))
|
||||
$errors['sambaProfilePath'][] = $this->messages['profilePath'][0];
|
||||
$triggered_messages['sambaProfilePath'][] = $this->messages['profilePath'][0];
|
||||
}
|
||||
else {
|
||||
$sambaHomePath = str_replace('$user', 'user', $this->attributes['sambaHomePath'][0]);
|
||||
|
@ -373,22 +361,25 @@ class sambaSamAccount extends baseModule {
|
|||
$sambaProfilePath = str_replace('$user', 'user', $this->attributes['sambaProfilePath'][0]);
|
||||
$sambaProfilePath = str_replace('$group', 'group', $sambaProfilePath);
|
||||
if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC')))
|
||||
$errors[] = $this->messages['homePath'][0];
|
||||
$triggered_messages[] = $this->messages['homePath'][0];
|
||||
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
|
||||
$errors[] = $this->messages['logonScript'][0];
|
||||
$triggered_messages[] = $this->messages['logonScript'][0];
|
||||
if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!get_preg($this->attributes['sambaProfilePath'][0], 'UNC'))
|
||||
&& (!get_preg($this->attributes['sambaProfilePath'][0], 'UNC')))
|
||||
$errors[] = $this->messages['profilePath'][0];
|
||||
$triggered_messages[] = $this->messages['profilePath'][0];
|
||||
}
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
if (is_array($errors)) return $errors;
|
||||
else $this->triggered_messages = array();
|
||||
if ($post['sambaUserWorkstations']) return 'sambaUserWorkstations';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_sambaUserWorkstations($post, $profile=false) {
|
||||
function proccess_sambaUserWorkstations($post) {
|
||||
// Load attributes
|
||||
if ($_SESSION[$this->base]->type=='user') {
|
||||
do { // X-Or, only one if() can be true
|
||||
|
@ -439,7 +430,7 @@ class sambaSamAccount extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
// Get Domain SID from name
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
||||
|
@ -458,7 +449,6 @@ class sambaSamAccount extends baseModule {
|
|||
4 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']),
|
||||
5 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
|
||||
6 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsU', 'type' => 'hidden', 'value' => 'true'));
|
||||
if (!$profile) {
|
||||
if ($post['sambaLMPassword2']!='') $password2 = $post['sambaLMPassword2'];
|
||||
else $password2 = $this->sambaLMPassword();
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
|
||||
|
@ -466,7 +456,6 @@ class sambaSamAccount extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||
2 => array ('kind' => 'help', 'value' => 'sambaLMPassword'));
|
||||
}
|
||||
if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use unix password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd),
|
||||
|
@ -523,7 +512,6 @@ class sambaSamAccount extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations', 'value' => _('Edit workstations')),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaUserWorkstations' ));
|
||||
|
||||
if (!$profile) {
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
|
@ -561,14 +549,11 @@ class sambaSamAccount extends baseModule {
|
|||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array($this->attributes['sambaDomainName'][0])),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
}
|
||||
if ($_SESSION[$this->base]->type=='host') {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
|
||||
if (!$profile) {
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
|
||||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $this->attributes['sambaDomainName'][0]),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
|
@ -584,7 +569,7 @@ class sambaSamAccount extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_sambaUserWorkstations($post, $profile=false) {
|
||||
function display_html_sambaUserWorkstations($post) {
|
||||
if ($_SESSION[$this->base]->type=='user') {
|
||||
// Get list of all hosts.
|
||||
$result = $_SESSION['cache']->get_cache('uid', 'sambaSamAccount', 'host');
|
||||
|
|
|
@ -164,14 +164,6 @@ class shadowAccount extends baseModule {
|
|||
return array('attributes');
|
||||
}
|
||||
|
||||
/* This function returns all ldap attributes
|
||||
* which are part of shadowAccount and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
|
@ -213,7 +205,7 @@ class shadowAccount extends baseModule {
|
|||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
function proccess_attributes($post, $profile=false) {
|
||||
function proccess_attributes($post) {
|
||||
// Load attributes
|
||||
$this->attributes['shadowMin'][0] = $post['shadowMin'];
|
||||
$this->attributes['shadowMax'][0] = $post['shadowMax'];
|
||||
|
@ -222,12 +214,16 @@ class shadowAccount extends baseModule {
|
|||
$this->attributes['shadowExpire'][0] = intval(mktime(10, 0, 0, $post['shadowExpire_mon'],
|
||||
$post['shadowExpire_day'], $post['shadowExpire_yea'])/3600/24);
|
||||
|
||||
if ( !get_preg($this->attributes['shadowMin'][0], 'digit')) $errors['shadowMin'][] = $this->messages['shadowMin'][0];
|
||||
if ( !get_preg($this->attributes['shadowMax'][0], 'digit')) $errors['shadowMax'][] = $this->messages['shadowMax'][0];
|
||||
if ( $this->attributes['shadowMin'][0] > $this->attributes['shadowMax'][0]) $errors['shadowMin'][] = $this->messages['shadow_cmp'][0];
|
||||
if ( !get_preg($this->attributes['shadowInactive'][0], 'digit2')) $errors['shadowInactive'][] = $this->messages['inactive'][0];
|
||||
if ( !get_preg($this->attributes['shadowWarning'][0], 'digit')) $errors['shadowWarning'][] = $this->messages['shadowWarning'][0];
|
||||
if (is_array($errors)) return $errors;
|
||||
if ( !get_preg($this->attributes['shadowMin'][0], 'digit')) $triggered_messages['shadowMin'][] = $this->messages['shadowMin'][0];
|
||||
if ( !get_preg($this->attributes['shadowMax'][0], 'digit')) $triggered_messages['shadowMax'][] = $this->messages['shadowMax'][0];
|
||||
if ( $this->attributes['shadowMin'][0] > $this->attributes['shadowMax'][0]) $triggered_messages['shadowMin'][] = $this->messages['shadow_cmp'][0];
|
||||
if ( !get_preg($this->attributes['shadowInactive'][0], 'digit2')) $triggered_messages['shadowInactive'][] = $this->messages['inactive'][0];
|
||||
if ( !get_preg($this->attributes['shadowWarning'][0], 'digit')) $triggered_messages['shadowWarning'][] = $this->messages['shadowWarning'][0];
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->triggered_messages = array();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -235,7 +231,7 @@ class shadowAccount extends baseModule {
|
|||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function display_html_attributes($post) {
|
||||
// Use dd-mm-yyyy format of date because it's easier to read for humans
|
||||
$date = getdate ($this->attributes['shadowExpire'][0]*3600*24);
|
||||
|
||||
|
|
Loading…
Reference in New Issue