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.
|
messages. First Index is the attribute which has triggered a message.
|
||||||
Second index is an array containing<br>
|
Second index is an array containing<br>
|
||||||
status message arrays.<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>
|
||||||
<br>
|
<br>
|
||||||
<h3>2.2.15. proccess_*<br>
|
<h3>2.2.15. proccess_*<br>
|
||||||
|
|
|
@ -57,8 +57,8 @@ class baseModule {
|
||||||
/** contains all ldap attributes which are loaded from ldap */
|
/** contains all ldap attributes which are loaded from ldap */
|
||||||
var $orig;
|
var $orig;
|
||||||
|
|
||||||
/** contains all error messages wich were triggered*/
|
/** contains all messages wich were triggered*/
|
||||||
var $errors;
|
var $triggered_messages;
|
||||||
|
|
||||||
/** contains all error messages of a module */
|
/** contains all error messages of a module */
|
||||||
var $messages;
|
var $messages;
|
||||||
|
|
|
@ -77,14 +77,6 @@ class account extends baseModule {
|
||||||
return array('attributes');
|
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
|
/* This function loads all attributes into the object
|
||||||
* $attr is an array as it's retured from ldap_get_attributes
|
* $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
|
/* Write variables into object and do some regexp checks
|
||||||
*/
|
*/
|
||||||
function proccess_attributes($post, $profile=false) {
|
function proccess_attributes($post) {
|
||||||
// Load attributes
|
// Load attributes
|
||||||
$this->attributes['description'][0] = $post['description'];
|
$this->attributes['description'][0] = $post['description'];
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -124,7 +116,7 @@ class account extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* 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') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
|
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
|
||||||
'maxlength' => '255', 'value' => $this->attributes['description'][0] ),
|
'maxlength' => '255', 'value' => $this->attributes['description'][0] ),
|
||||||
|
@ -133,7 +125,7 @@ class account extends baseModule {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_html_delete($post, $profile=false) {
|
function display_html_delete($post) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,14 +258,6 @@ class inetOrgPerson extends baseModule {
|
||||||
return array('attributes');
|
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
|
/* This function loads all attributes into the object
|
||||||
* $attr is an array as it's retured from ldap_get_attributes
|
* $attr is an array as it's retured from ldap_get_attributes
|
||||||
*/
|
*/
|
||||||
|
@ -301,7 +293,7 @@ class inetOrgPerson extends baseModule {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function proccess_attributes($post, $profile=false) {
|
function proccess_attributes($post) {
|
||||||
// Load attributes
|
// Load attributes
|
||||||
$this->attributes['description'][0] = $post['description'];
|
$this->attributes['description'][0] = $post['description'];
|
||||||
$this->attributes['sn'][0] = $post['sn'];
|
$this->attributes['sn'][0] = $post['sn'];
|
||||||
|
@ -320,7 +312,7 @@ class inetOrgPerson extends baseModule {
|
||||||
if (isset($this->attributes['host'])) {
|
if (isset($this->attributes['host'])) {
|
||||||
$host = $post['host'];
|
$host = $post['host'];
|
||||||
if (!get_preg($host,'unixhost'))
|
if (!get_preg($host,'unixhost'))
|
||||||
$errors['host'][] = $this->messages['host'][0];
|
$triggered_messages['host'][] = $this->messages['host'][0];
|
||||||
$hosts = explode(" ", $host);
|
$hosts = explode(" ", $host);
|
||||||
$this->attributes['host'] = array();
|
$this->attributes['host'] = array();
|
||||||
foreach ($hosts as $host)
|
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
|
// Do some regex-checks and return error if attributes are set to wrong values
|
||||||
if (!$profile) {
|
if ( !get_preg($this->attributes['givenName'][0], 'realname')) $triggered_messages['givenName'][] = $this->messages['givenName'][0];
|
||||||
if ( !get_preg($this->attributes['givenName'][0], 'realname')) $errors['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['sn'][0], 'realname')) $errors['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['telephoneNumber'][0], 'telephone')) $errors['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['mobileTelephoneNumber'][0], 'telephone')) $errors['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['facsimileTelephoneNumber'][0], 'telephone')) $errors['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['mail'][0], 'email')) $errors['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['street'][0], 'street')) $errors['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['postalAddress'][0], 'postalAddress')) $errors['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['personal_postalCode'][0], 'postalCode')) $errors['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];
|
||||||
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];
|
|
||||||
// Return error-messages
|
// Return error-messages
|
||||||
if (is_array($errors)) return $errors;
|
if (is_array($triggered_messages)) return $triggered_messages;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +340,7 @@ class inetOrgPerson extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* 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') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
|
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
|
||||||
'maxlength' => '255', 'value' => $this->attributes['description'][0] ),
|
'maxlength' => '255', 'value' => $this->attributes['description'][0] ),
|
||||||
|
@ -367,54 +357,50 @@ class inetOrgPerson extends baseModule {
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'title', 'type' => 'text', 'size' => '10',
|
1 => array ( 'kind' => 'input', 'name' => 'title', 'type' => 'text', 'size' => '10',
|
||||||
'value' => $this->attributes['title'][0] ),
|
'value' => $this->attributes['title'][0] ),
|
||||||
2 => array ('kind' => 'help', 'value' => 'title'));
|
2 => array ('kind' => 'help', 'value' => 'title'));
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('First name').'*' ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('First name').'*' ),
|
1 => array ( 'kind' => 'input', 'name' => 'givenName', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'givenName', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['givenName'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['givenName'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'givenName'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'givenName'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Last name').'*' ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Last name').'*' ),
|
1 => array ( 'kind' => 'input', 'name' => 'sn', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'sn', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['sn'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['sn'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'sn'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'sn'));
|
|
||||||
}
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Employee type') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Employee type') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'employeeType', 'type' => 'text', 'size' => '30',
|
1 => array ( 'kind' => 'input', 'name' => 'employeeType', 'type' => 'text', 'size' => '30',
|
||||||
'maxlength' => '255', 'value' => $this->attributes['employeeType'][0] ),
|
'maxlength' => '255', 'value' => $this->attributes['employeeType'][0] ),
|
||||||
2 => array ('kind' => 'help', 'value' => 'employeeType'));
|
2 => array ('kind' => 'help', 'value' => 'employeeType'));
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Street') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Street') ),
|
1 => array ( 'kind' => 'input', 'name' => 'street', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'street', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['street'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['street'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'street'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'street'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Postal code') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Postal code') ),
|
1 => array ( 'kind' => 'input', 'name' => 'postalCode', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'postalCode', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['postalCode'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['postalCode'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'postalCode'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'postalCode'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Postal address') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Postal address') ),
|
1 => array ( 'kind' => 'input', 'name' => 'postalAddress', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'postalAddress', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['postalAddress'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['postalAddress'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'postalAddress'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'postalAddress'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Telephone number') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Telephone number') ),
|
1 => array ( 'kind' => 'input', 'name' => 'telephoneNumber', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'telephoneNumber', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['telephoneNumber'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['telephoneNumber'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'telephoneNumber'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'telephoneNumber'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Mobile number') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Mobile number') ),
|
1 => array ( 'kind' => 'input', 'name' => 'mobileTelephoneNumber', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'mobileTelephoneNumber', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['mobileTelephoneNumber'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['mobileTelephoneNumber'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'mobileTelephoneNumber'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'mobileTelephoneNumber'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Fax number') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Fax number') ),
|
1 => array ( 'kind' => 'input', 'name' => 'facsimileTelephoneNumber', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'facsimileTelephoneNumber', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['facsimileTelephoneNumber'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['facsimileTelephoneNumber'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'facsimileTelephoneNumber'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'facsimileTelephoneNumber'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('eMail address') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('eMail address') ),
|
1 => array ( 'kind' => 'input', 'name' => 'mail', 'type' => 'text', 'size' => '30',
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'mail', 'type' => 'text', 'size' => '30',
|
'maxlength' => '255', 'value' => $this->attributes['mail'][0] ),
|
||||||
'maxlength' => '255', 'value' => $this->attributes['mail'][0] ),
|
2 => array ('kind' => 'help', 'value' => 'mail'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'mail'));
|
|
||||||
}
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_html_delete($post, $profile=false) {
|
function display_html_delete($post) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +433,7 @@ class inetOrgPerson extends baseModule {
|
||||||
* @return array list of error messages if any
|
* @return array list of error messages if any
|
||||||
*/
|
*/
|
||||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
||||||
$errors = array();
|
$triggered_messages = array();
|
||||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||||
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson";
|
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson";
|
||||||
// last name
|
// last name
|
||||||
|
@ -457,7 +443,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['surname'][1];
|
$errMsg = $this->messages['surname'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// first name
|
// first name
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_firstName']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_firstName']], 'realname')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_firstName']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_firstName']], 'realname')) {
|
||||||
|
@ -466,7 +452,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['givenName'][1];
|
$errMsg = $this->messages['givenName'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// description
|
// description
|
||||||
if ($rawAccounts[$i][$ids['inetOrgPerson_description']] != "") {
|
if ($rawAccounts[$i][$ids['inetOrgPerson_description']] != "") {
|
||||||
|
@ -487,7 +473,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['title'][1];
|
$errMsg = $this->messages['title'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// employee type
|
// employee type
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_type']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_type']], 'employeeType')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_type']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_type']], 'employeeType')) {
|
||||||
|
@ -496,7 +482,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['employeeType'][1];
|
$errMsg = $this->messages['employeeType'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// street
|
// street
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_street']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_street']], 'street')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_street']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_street']], 'street')) {
|
||||||
|
@ -505,7 +491,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['street'][1];
|
$errMsg = $this->messages['street'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// postal code
|
// postal code
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_postalCode']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_postalCode']], 'postalCode')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_postalCode']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_postalCode']], 'postalCode')) {
|
||||||
|
@ -514,7 +500,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['postalCode'][1];
|
$errMsg = $this->messages['postalCode'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// postal address
|
// postal address
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_address']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_address']], 'postalAddress')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_address']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_address']], 'postalAddress')) {
|
||||||
|
@ -523,7 +509,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['postalAddress'][1];
|
$errMsg = $this->messages['postalAddress'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// telephone
|
// telephone
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_telephone']], 'telephone')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_telephone']], 'telephone')) {
|
||||||
|
@ -532,7 +518,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['telephone'][1];
|
$errMsg = $this->messages['telephone'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// mobile
|
// mobile
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_mobile']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_mobile']], 'telephone')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_mobile']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_mobile']], 'telephone')) {
|
||||||
|
@ -541,7 +527,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['mobileTelephone'][1];
|
$errMsg = $this->messages['mobileTelephone'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// facsimile
|
// facsimile
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_fax']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_fax']], 'telephone')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_fax']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_fax']], 'telephone')) {
|
||||||
|
@ -550,7 +536,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['facsimileNumber'][1];
|
$errMsg = $this->messages['facsimileNumber'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// eMail
|
// eMail
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_email']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_email']], 'email')) {
|
if (($rawAccounts[$i][$ids['inetOrgPerson_email']] != "") && get_preg($rawAccounts[$i][$ids['inetOrgPerson_email']], 'email')) {
|
||||||
|
@ -559,7 +545,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['email'][1];
|
$errMsg = $this->messages['email'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// cn
|
// cn
|
||||||
if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") {
|
if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") {
|
||||||
|
@ -569,7 +555,7 @@ class inetOrgPerson extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['email'][1];
|
$errMsg = $this->messages['email'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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');
|
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
|
/* This function loads all attributes into the object
|
||||||
* $attr is an array as it's retured from ldap_get_attributes
|
* $attr is an array as it's retured from ldap_get_attributes
|
||||||
*/
|
*/
|
||||||
|
@ -552,210 +542,205 @@ class posixAccount extends baseModule {
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* 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['homeDirectory'][0] = $post['homeDirectory'];
|
||||||
$this->attributes['loginShell'][0] = $post['loginShell'];
|
$this->attributes['loginShell'][0] = $post['loginShell'];
|
||||||
$this->attributes['gecos'][0] = $post['gecos'];
|
$this->attributes['gecos'][0] = $post['gecos'];
|
||||||
if ($post['createhomedir']) $this->createhomedir = true;
|
if ($post['createhomedir']) $this->createhomedir = true;
|
||||||
else $this->createhomedir = false;
|
else $this->createhomedir = false;
|
||||||
|
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
|
||||||
if (!$profile) {
|
$triggered_messages['uid'][] = $this->messages['uid'][0];
|
||||||
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
|
if ($this->orig['gidNumber'][0]!='' && $_SESSION['cache']->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0])
|
||||||
$errors['uid'][] = $this->messages['uid'][0];
|
$triggered_messages['gidNumber'][] = $this->dynamic_Message('gidNumber',0);
|
||||||
if ($this->orig['gidNumber'][0]!='' && $_SESSION['cache']->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0])
|
if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0])
|
||||||
$errors['gidNumber'][] = $this->dynamic_Message('gidNumber',0);
|
$triggered_messages['uidNumber'][] = $this->dynamic_Message('uidNumber',0);
|
||||||
if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0])
|
if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0])
|
||||||
$errors['uidNumber'][] = $this->dynamic_Message('uidNumber',0);
|
$triggered_messages['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0);
|
||||||
if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0])
|
// Load attributes
|
||||||
$errors['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0);
|
$this->attributes['uid'][0] = $post['uid'];
|
||||||
// Load attributes
|
$this->attributes['cn'][0] = $this->attributes['uid'][0];
|
||||||
$this->attributes['uid'][0] = $post['uid'];
|
$this->attributes['uidNumber'][0] = $post['uidNumber'];
|
||||||
$this->attributes['cn'][0] = $this->attributes['uid'][0];
|
$this->attributes['gidNumber'][0] = $_SESSION['cache']->getgid($post['gidNumber']);
|
||||||
$this->attributes['uidNumber'][0] = $post['uidNumber'];
|
// Check if UID is valid. If none value was entered, the next useable value will be inserted
|
||||||
$this->attributes['gidNumber'][0] = $_SESSION['cache']->getgid($post['gidNumber']);
|
// load min and may uidNumber
|
||||||
// Check if UID is valid. If none value was entered, the next useable value will be inserted
|
if ($_SESSION[$this->base]->type=='user') {
|
||||||
// load min and may uidNumber
|
$minID = intval($this->moduleSettings['posixAccount_minUID'][0]);
|
||||||
if ($_SESSION[$this->base]->type=='user') {
|
$maxID = intval($this->moduleSettings['posixAccount_maxUID'][0]);
|
||||||
$minID = intval($this->moduleSettings['posixAccount_minUID'][0]);
|
}
|
||||||
$maxID = intval($this->moduleSettings['posixAccount_maxUID'][0]);
|
if ($_SESSION[$this->base]->type=='host') {
|
||||||
}
|
$minID = intval($this->moduleSettings['posixAccount_minMachine'][0]);
|
||||||
if ($_SESSION[$this->base]->type=='host') {
|
$maxID = intval($this->moduleSettings['posixAccount_maxMachine'][0]);
|
||||||
$minID = intval($this->moduleSettings['posixAccount_minMachine'][0]);
|
}
|
||||||
$maxID = intval($this->moduleSettings['posixAccount_maxMachine'][0]);
|
$dn_uids = $_SESSION['cache']->get_cache('uidNumber', 'posixAccount', '*');
|
||||||
}
|
// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
|
||||||
$dn_uids = $_SESSION['cache']->get_cache('uidNumber', 'posixAccount', '*');
|
if(is_array($dn_uids)) {
|
||||||
// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
|
foreach ($dn_uids as $uid) $uids[] = $uid[0];
|
||||||
if(is_array($dn_uids)) {
|
sort ($uids, SORT_NUMERIC);
|
||||||
foreach ($dn_uids as $uid) $uids[] = $uid[0];
|
}
|
||||||
sort ($uids, SORT_NUMERIC);
|
if ($this->attributes['uidNumber'][0]=='') {
|
||||||
}
|
// No id-number given
|
||||||
if ($this->attributes['uidNumber'][0]=='') {
|
if ($this->orig['uidNumber'][0]=='') {
|
||||||
// No id-number given
|
// new account -> we have to find a free id-number
|
||||||
if ($this->orig['uidNumber'][0]=='') {
|
if (count($uids)!=0) {
|
||||||
// new account -> we have to find a free id-number
|
// There are some uids
|
||||||
if (count($uids)!=0) {
|
// Store highest id-number
|
||||||
// There are some uids
|
$id = $uids[count($uids)-1];
|
||||||
// Store highest id-number
|
// Return minimum allowed id-number if all found id-numbers are too low
|
||||||
$id = $uids[count($uids)-1];
|
if ($id < $minID) $this->attributes['uidNumber'][0] = $minID;
|
||||||
// Return minimum allowed id-number if all found id-numbers are too low
|
// Return higesht used id-number + 1 if it's still in valid range
|
||||||
if ($id < $minID) $this->attributes['uidNumber'][0] = $minID;
|
if ($id < $maxID) $this->attributes['uidNumber'][0] = $id+1;
|
||||||
// Return higesht used id-number + 1 if it's still in valid range
|
/* If this function is still running we have to fid a free id-number between
|
||||||
if ($id < $maxID) $this->attributes['uidNumber'][0] = $id+1;
|
* the used id-numbers
|
||||||
/* If this function is still running we have to fid a free id-number between
|
*/
|
||||||
* the used id-numbers
|
$i = intval($minID);
|
||||||
*/
|
while (in_array($i, $uids)) $i++;
|
||||||
$i = intval($minID);
|
if ($i>$maxID)
|
||||||
while (in_array($i, $uids)) $i++;
|
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][1];
|
||||||
if ($i>$maxID)
|
else {
|
||||||
$errors['uidNumber'][] = $this->messages['uidNumber'][1];
|
$this->attributes['uidNumber'][0] = $i;
|
||||||
else {
|
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][2];
|
||||||
$this->attributes['uidNumber'][0] = $i;
|
|
||||||
$errors['uidNumber'][] = $this->messages['uidNumber'][2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else $this->attributes['uidNumber'][0] = $minID;
|
|
||||||
// return minimum allowed id-number if no id-numbers are found
|
|
||||||
}
|
|
||||||
else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
|
||||||
// old account -> return id-number which has been used
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
// $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'));
|
|
||||||
// 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];
|
|
||||||
$this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else $this->attributes['uidNumber'][0] = $minID;
|
||||||
|
// return minimum allowed id-number if no id-numbers are found
|
||||||
}
|
}
|
||||||
if ($_SESSION[$this->base]->type=='user') {
|
else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
||||||
if (($this->attributes['uid'][0] != $post['uid']) && !get_preg($post['uid'], '!upper'))
|
// old account -> return id-number which has been used
|
||||||
$errors['uid'][] = $this->messages['uid'][1];
|
}
|
||||||
if ( !get_preg($this->attributes['homeDirectory'][0], 'homeDirectory' ))
|
else {
|
||||||
$errors['homeDirecotry'][] = $this->messages['homeDirectory'][0];
|
// 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)) $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]=='') $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]) ) {
|
||||||
|
$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'))
|
||||||
|
$triggered_messages['uid'][] = $this->messages['uid'][1];
|
||||||
|
if ( !get_preg($this->attributes['homeDirectory'][0], 'homeDirectory' ))
|
||||||
|
$triggered_messages['homeDirecotry'][] = $this->messages['homeDirectory'][0];
|
||||||
|
}
|
||||||
if (($post['userPassword_lock'] && $post['userPassword_invalid']) || ($post['userPassword_nopassword'] && $post['userPassword_invalid'])) {
|
if (($post['userPassword_lock'] && $post['userPassword_invalid']) || ($post['userPassword_nopassword'] && $post['userPassword_invalid'])) {
|
||||||
// found invalid password parameter combination
|
// found invalid password parameter combination
|
||||||
$errors['userPassword'][] = $this->messages['userPassword'][3];
|
$triggered_messages['userPassword'][] = $this->messages['userPassword'][3];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($post['userPassword_nopassword']) {
|
||||||
|
$this->userPassword_nopassword=true;
|
||||||
|
$this->userPassword_invalid=false;
|
||||||
|
$this->userPassword('');
|
||||||
|
$post['userPassword2'] = '';
|
||||||
|
if ($post['userPassword_lock'])
|
||||||
|
$this->userPassword_lock=true;
|
||||||
|
else $this->userPassword_lock=false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($post['userPassword_nopassword']) {
|
$this->userPassword_nopassword=false;
|
||||||
$this->userPassword_nopassword=true;
|
if ($post['userPassword_invalid']) {
|
||||||
$this->userPassword_invalid=false;
|
$this->userPassword_invalid=true;
|
||||||
|
$this->userPassword_lock=false;
|
||||||
$this->userPassword('');
|
$this->userPassword('');
|
||||||
$post['userPassword2'] = '';
|
$post['userPassword2'] = '';
|
||||||
if ($post['userPassword_lock'])
|
|
||||||
$this->userPassword_lock=true;
|
|
||||||
else $this->userPassword_lock=false;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->userPassword_nopassword=false;
|
$this->userPassword_invalid=false;
|
||||||
if ($post['userPassword_invalid']) {
|
if ($post['genpass']) $this->userPassword(genpasswd());
|
||||||
$this->userPassword_invalid=true;
|
|
||||||
$this->userPassword_lock=false;
|
|
||||||
$this->userPassword('');
|
|
||||||
$post['userPassword2'] = '';
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
$this->userPassword_invalid=false;
|
if ($post['userPassword'] != $post['userPassword2'])
|
||||||
if ($post['genpass']) $this->userPassword(genpasswd());
|
$triggered_messages['userPassword'][] = $this->messages['userPassword'][0];
|
||||||
else {
|
else $this->userPassword($post['userPassword']);
|
||||||
if ($post['userPassword'] != $post['userPassword2'])
|
if (!get_preg($this->userPassword(), 'password'))
|
||||||
$errors['userPassword'][] = $this->messages['userPassword'][0];
|
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
||||||
else $this->userPassword($post['userPassword']);
|
|
||||||
if (!get_preg($this->userPassword(), 'password'))
|
|
||||||
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
|
||||||
}
|
|
||||||
if ($post['userPassword_lock']) $this->userPassword_lock=true;
|
|
||||||
else $this->userPassword_lock=false;
|
|
||||||
}
|
}
|
||||||
|
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.'));
|
|
||||||
// Check if Username contains only valid characters
|
|
||||||
if ( !get_preg($this->attributes['uid'][0], 'username') && !$profile)
|
|
||||||
$errors['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];
|
|
||||||
}
|
|
||||||
// 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
|
|
||||||
if ($_SESSION['cache']->in_cache($this->attributes['uid'][0],'uid', '*') && ($this->orig['uid'][0]!=''))
|
|
||||||
$this->attributes['uid'][0] = $this->orig['uid'][0];
|
|
||||||
// Change uid to a new uid until a free uid is found
|
|
||||||
else
|
|
||||||
while ($_SESSION['cache']->in_cache($this->attributes['uid'][0], 'uid', '*')) {
|
|
||||||
if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1);
|
|
||||||
// get last character of username
|
|
||||||
$lastchar = substr($this->attributes['uid'][0], strlen($this->attributes['uid'][0])-1, 1);
|
|
||||||
// Last character is no number
|
|
||||||
if ( !ereg('^([0-9])+$', $lastchar))
|
|
||||||
/* Last character is no number. Therefore we only have to
|
|
||||||
* add "2" to it.
|
|
||||||
*/
|
|
||||||
if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2$';
|
|
||||||
else $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2';
|
|
||||||
else {
|
|
||||||
/* Last character is a number -> we have to increase the number until we've
|
|
||||||
* found a groupname with trailing number which is not in use.
|
|
||||||
*
|
|
||||||
* $i will show us were we have to split groupname so we get a part
|
|
||||||
* with the groupname and a part with the trailing number
|
|
||||||
*/
|
|
||||||
$i=strlen($this->attributes['uid'][0])-1;
|
|
||||||
$mark = false;
|
|
||||||
// Set $i to the last character which is a number in $account_new->general_username
|
|
||||||
while (!$mark)
|
|
||||||
if (ereg('^([0-9])+$',substr($this->attributes['uid'][0], $i, strlen($this->attributes['uid'][0])-$i))) $i--;
|
|
||||||
else $mark=true;
|
|
||||||
// increase last number with one
|
|
||||||
$firstchars = substr($this->attributes['uid'][0], 0, $i+1);
|
|
||||||
$lastchars = substr($this->attributes['uid'][0], $i+1, strlen($this->attributes['uid'][0])-$i);
|
|
||||||
// Put username together
|
|
||||||
if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1)."$";
|
|
||||||
else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 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];
|
|
||||||
if ($_SESSION[$this->base]->type=='host')
|
|
||||||
$errors['uid'][] = $this->messages['uid'][6];
|
|
||||||
}
|
|
||||||
if (!get_preg($this->userPassword(), 'password'))
|
|
||||||
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
|
||||||
}
|
}
|
||||||
|
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']) $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)
|
||||||
|
$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'))
|
||||||
|
$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
|
||||||
|
// Set username back to original name if new username is in use
|
||||||
|
if ($_SESSION['cache']->in_cache($this->attributes['uid'][0],'uid', '*') && ($this->orig['uid'][0]!=''))
|
||||||
|
$this->attributes['uid'][0] = $this->orig['uid'][0];
|
||||||
|
// Change uid to a new uid until a free uid is found
|
||||||
|
else
|
||||||
|
while ($_SESSION['cache']->in_cache($this->attributes['uid'][0], 'uid', '*')) {
|
||||||
|
if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1);
|
||||||
|
// get last character of username
|
||||||
|
$lastchar = substr($this->attributes['uid'][0], strlen($this->attributes['uid'][0])-1, 1);
|
||||||
|
// Last character is no number
|
||||||
|
if ( !ereg('^([0-9])+$', $lastchar))
|
||||||
|
/* Last character is no number. Therefore we only have to
|
||||||
|
* add "2" to it.
|
||||||
|
*/
|
||||||
|
if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2$';
|
||||||
|
else $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2';
|
||||||
|
else {
|
||||||
|
/* Last character is a number -> we have to increase the number until we've
|
||||||
|
* found a groupname with trailing number which is not in use.
|
||||||
|
*
|
||||||
|
* $i will show us were we have to split groupname so we get a part
|
||||||
|
* with the groupname and a part with the trailing number
|
||||||
|
*/
|
||||||
|
$i=strlen($this->attributes['uid'][0])-1;
|
||||||
|
$mark = false;
|
||||||
|
// Set $i to the last character which is a number in $account_new->general_username
|
||||||
|
while (!$mark)
|
||||||
|
if (ereg('^([0-9])+$',substr($this->attributes['uid'][0], $i, strlen($this->attributes['uid'][0])-$i))) $i--;
|
||||||
|
else $mark=true;
|
||||||
|
// increase last number with one
|
||||||
|
$firstchars = substr($this->attributes['uid'][0], 0, $i+1);
|
||||||
|
$lastchars = substr($this->attributes['uid'][0], $i+1, strlen($this->attributes['uid'][0])-$i);
|
||||||
|
// Put username together
|
||||||
|
if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1)."$";
|
||||||
|
else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Show warning if lam has changed username
|
||||||
|
if ($this->attributes['uid'][0] != $post['uid']) {
|
||||||
|
if ($_SESSION[$this->base]->type=='user')
|
||||||
|
$triggered_messages['uid'][] = $this->messages['uid'][5];
|
||||||
|
if ($_SESSION[$this->base]->type=='host')
|
||||||
|
$triggered_messages['uid'][] = $this->messages['uid'][6];
|
||||||
|
}
|
||||||
|
if (!get_preg($this->userPassword(), 'password'))
|
||||||
|
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
||||||
}
|
}
|
||||||
// Return error-messages
|
// Return error-messages
|
||||||
if (count($errors)!=0) {
|
if (count($triggered_messages)!=0) {
|
||||||
$this->errors = $errors;
|
$this->triggered_messages = $triggered_messages;
|
||||||
return $errors;
|
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
|
// Go to additional group page when no error did ocour and button was pressed
|
||||||
if ($post['addgroup']) return 'group';
|
if ($post['addgroup']) return 'group';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* 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
|
do { // X-Or, only one if() can be true
|
||||||
if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
|
if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
|
||||||
// Add new group
|
// Add new group
|
||||||
|
@ -769,27 +754,25 @@ class posixAccount extends baseModule {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while(0);
|
} while(0);
|
||||||
if (isset($post['addgroups_button']) || isset($post['removegroups_button'])) return 'group';
|
if (isset($post['addgroups_button']) || isset($post['removegroups_button'])) return 'group';
|
||||||
if ($post['back']) return 'attributes';
|
if ($post['back']) return 'attributes';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function will create the html-page
|
/* This function will create the html-page
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* 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
|
$groups = $_SESSION['cache']->findgroups(); // list of all groupnames
|
||||||
$shelllist = getshells(); // list of all valid shells
|
$shelllist = getshells(); // list of all valid shells
|
||||||
|
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Username").'*' ),
|
||||||
$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]),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['uid'][0]),
|
2 => array ('kind' => 'help', 'value' => 'uid'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'uid'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('UID number').'*' ),
|
||||||
$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]),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'uidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['uidNumber'][0]),
|
2 => array ('kind' => 'help', 'value' => 'uidNumber'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'uidNumber'));
|
|
||||||
}
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Gecos') ),
|
$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]),
|
1 => array ( 'kind' => 'input', 'name' => 'gecos', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['gecos'][0]),
|
||||||
2 => array ('kind' => 'help', 'value' => 'gecos'));
|
2 => array ('kind' => 'help', 'value' => 'gecos'));
|
||||||
|
@ -799,29 +782,25 @@ class posixAccount extends baseModule {
|
||||||
2 => array ('kind' => 'help', 'value' => 'gidNumber'));
|
2 => array ('kind' => 'help', 'value' => 'gidNumber'));
|
||||||
|
|
||||||
if ($_SESSION[$this->base]->type=='user') {
|
if ($_SESSION[$this->base]->type=='user') {
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Additional groups') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Additional groups') ),
|
1 => array ( 'kind' => 'input', 'name' => 'addgroup', 'type' => 'submit', 'value' => _('Edit groups')),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'addgroup', 'type' => 'submit', 'value' => _('Edit groups')),
|
2 => array ('kind' => 'help', 'value' => 'addgroup'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'addgroup'));
|
|
||||||
}
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home directory').'*' ),
|
$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]),
|
1 => array ( 'kind' => 'input', 'name' => 'homeDirectory', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['homeDirectory'][0]),
|
||||||
2 => array ('kind' => 'help', 'value' => 'homeDirectory'));
|
2 => array ('kind' => 'help', 'value' => 'homeDirectory'));
|
||||||
if (!$profile) {
|
if ($this->orig['homeDirectory']=='' && isset($_SESSION['config']->scriptPath)) {
|
||||||
if ($this->orig['homeDirectory']=='' && isset($_SESSION['config']->scriptPath)) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Create home directory') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Create home directory') ),
|
1 => array ( 'kind' => 'input', 'name' => 'createhomedir', 'type' => 'checkbox', 'checked' => $this->createhomedir),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'createhomedir', 'type' => 'checkbox', 'checked' => $this->createhomedir),
|
2 => array ('kind' => 'help', 'value' => 'createhomedir'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'createhomedir'));
|
|
||||||
}
|
}
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->userPassword()),
|
1 => array ( 'kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->userPassword()),
|
||||||
2 => array ( 'kind' => 'input', 'name' => 'genpass', 'type' => 'submit', 'value' => _('Generate password')));
|
2 => array ( 'kind' => 'input', 'name' => 'genpass', 'type' => 'submit', 'value' => _('Generate password')));
|
||||||
if ($post['userPassword2']!='') $password2 = $post['userPassword2'];
|
if ($post['userPassword2']!='') $password2 = $post['userPassword2'];
|
||||||
else $password2 = $this->userPassword();
|
else $password2 = $this->userPassword();
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||||
2 => array ('kind' => 'help', 'value' => 'userPassword'));
|
2 => array ('kind' => 'help', 'value' => 'userPassword'));
|
||||||
}
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Set no password') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Set no password') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword_nopassword', 'type' => 'checkbox', 'checked' => $this->userPassword_nopassword),
|
1 => array ( 'kind' => 'input', 'name' => 'userPassword_nopassword', 'type' => 'checkbox', 'checked' => $this->userPassword_nopassword),
|
||||||
2 => array ('kind' => 'help', 'value' => 'userPassword_nopassword'));
|
2 => array ('kind' => 'help', 'value' => 'userPassword_nopassword'));
|
||||||
|
@ -837,7 +816,6 @@ class posixAccount extends baseModule {
|
||||||
array ($this->attributes['loginShell'][0])),
|
array ($this->attributes['loginShell'][0])),
|
||||||
2 => array ('kind' => 'help', 'value' => 'loginShell'));
|
2 => array ('kind' => 'help', 'value' => 'loginShell'));
|
||||||
}
|
}
|
||||||
return $return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_html_delete($post) {
|
function display_html_delete($post) {
|
||||||
|
@ -849,7 +827,7 @@ class posixAccount extends baseModule {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_html_group($post, $profile=false) {
|
function display_html_group($post) {
|
||||||
// load list with all groups
|
// load list with all groups
|
||||||
$dn_groups = $_SESSION['cache']->get_cache('gidNumber', 'posixGroup', 'group');
|
$dn_groups = $_SESSION['cache']->get_cache('gidNumber', 'posixGroup', 'group');
|
||||||
$DNs = array_keys($dn_groups);
|
$DNs = array_keys($dn_groups);
|
||||||
|
@ -1012,7 +990,7 @@ class posixAccount extends baseModule {
|
||||||
* @return array list of error messages if any
|
* @return array list of error messages if any
|
||||||
*/
|
*/
|
||||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
||||||
$errors = array();
|
$triggered_messages = array();
|
||||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||||
if (!in_array("posixAccount", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixAccount";
|
if (!in_array("posixAccount", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixAccount";
|
||||||
// UID
|
// UID
|
||||||
|
@ -1026,7 +1004,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uidNumber'][8]; // TODO
|
$errMsg = $this->messages['uidNumber'][8]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// GID number
|
// GID number
|
||||||
if (get_preg($rawAccounts[$i][$ids['posixAccount_group']], 'digit')) {
|
if (get_preg($rawAccounts[$i][$ids['posixAccount_group']], 'digit')) {
|
||||||
|
@ -1040,7 +1018,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['gidNumber'][8]; // TODO
|
$errMsg = $this->messages['gidNumber'][8]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// GECOS // TODO fill default values
|
// GECOS // TODO fill default values
|
||||||
if (($rawAccounts[$i][$ids['posixAccount_gecos']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_gecos']], 'gecos'))) {
|
if (($rawAccounts[$i][$ids['posixAccount_gecos']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_gecos']], 'gecos'))) {
|
||||||
|
@ -1049,7 +1027,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['gecos'][1]; // TODO
|
$errMsg = $this->messages['gecos'][1]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// user specific attributes
|
// user specific attributes
|
||||||
if ($this->scope == 'user') {
|
if ($this->scope == 'user') {
|
||||||
|
@ -1060,7 +1038,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['username'][1]; // TODO
|
$errMsg = $this->messages['username'][1]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// home directory
|
// home directory
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_homedir']] == "") {
|
if ($rawAccounts[$i][$ids['posixAccount_homedir']] == "") {
|
||||||
|
@ -1072,7 +1050,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['homedir'][8]; // TODO
|
$errMsg = $this->messages['homedir'][8]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// login shell
|
// login shell
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_shell']] == "") {
|
if ($rawAccounts[$i][$ids['posixAccount_shell']] == "") {
|
||||||
|
@ -1084,7 +1062,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['loginshell'][8]; // TODO
|
$errMsg = $this->messages['loginshell'][8]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
$pwd_enabled = true;
|
$pwd_enabled = true;
|
||||||
// password enabled/disabled
|
// password enabled/disabled
|
||||||
|
@ -1098,7 +1076,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['passwordDisabled'][8]; // TODO
|
$errMsg = $this->messages['passwordDisabled'][8]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// password
|
// password
|
||||||
if (($rawAccounts[$i][$ids['posixAccount_password']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_password']], 'password'))) {
|
if (($rawAccounts[$i][$ids['posixAccount_password']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_password']], 'password'))) {
|
||||||
|
@ -1107,7 +1085,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['password'][8]; // TODO
|
$errMsg = $this->messages['password'][8]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// host specific attributes
|
// host specific attributes
|
||||||
|
@ -1119,13 +1097,13 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['hostname'][1]; // TODO
|
$errMsg = $this->messages['hostname'][1]; // TODO
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
$partialAccounts[$i]['homeDirectory'] = '/dev/null';
|
$partialAccounts[$i]['homeDirectory'] = '/dev/null';
|
||||||
$partialAccounts[$i]['loginShell'] = '/bin/false';
|
$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
|
* @return array list of error messages if any
|
||||||
*/
|
*/
|
||||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
||||||
$errors = array();
|
$triggered_messages = array();
|
||||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||||
if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
|
if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
|
||||||
// group name
|
// group name
|
||||||
|
@ -63,7 +63,7 @@ class posixGroup extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['cn'][3];
|
$errMsg = $this->messages['cn'][3];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// GID
|
// GID
|
||||||
if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") {
|
if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") {
|
||||||
|
@ -76,7 +76,7 @@ class posixGroup extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['gidNumber'][8];
|
$errMsg = $this->messages['gidNumber'][8];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
// description (UTF-8, no regex check needed)
|
// description (UTF-8, no regex check needed)
|
||||||
if ($rawAccounts[$i][$ids['posixGroup_description']] == "") {
|
if ($rawAccounts[$i][$ids['posixGroup_description']] == "") {
|
||||||
|
@ -93,7 +93,7 @@ class posixGroup extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['memberUID'][0];
|
$errMsg = $this->messages['memberUID'][0];
|
||||||
array_push($errMsg, $i);
|
array_push($errMsg, $i);
|
||||||
$errors[] =$errMsg;
|
$triggered_messages[] =$errMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// password
|
// 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]);
|
$partialAccounts[$i]['userPassword'] = pwd_hash($rawAccounts[$i][$ids['posixGroup_password']], true, $this->moduleSettings['posixAccount_pwdHash'][0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errors[] = $this->messages['userPassword'][1];
|
$triggered_messages[] = $this->messages['userPassword'][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $errors;
|
return $triggered_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,44 +122,39 @@ class posixGroup extends baseModule {
|
||||||
* It will output a complete html-table
|
* It will output a complete html-table
|
||||||
*/
|
*/
|
||||||
function display_html_attributes($post) {
|
function display_html_attributes($post) {
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Groupname").'*' ),
|
||||||
$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]),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['cn'][0]),
|
2 => array ('kind' => 'help', 'value' => 'cn'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'cn'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('GID number').'*' ),
|
||||||
$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]),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['gidNumber'][0]),
|
2 => array ('kind' => 'help', 'value' => 'gidNumber'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'gidNumber'));
|
|
||||||
}
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
|
$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]),
|
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]),
|
||||||
2 => array ('kind' => 'help', 'value' => 'description'));
|
2 => array ('kind' => 'help', 'value' => 'description'));
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Group members").'*' ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Group members").'*' ),
|
1 => array ( 'kind' => 'input', 'name' => 'adduser', 'type' => 'submit', 'value' => _('Edit groups')),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'adduser', 'type' => 'submit', 'value' => _('Edit groups')),
|
2 => array ('kind' => 'help', 'value' => 'adduser'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'adduser'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password') ),
|
1 => array ( 'kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->userPassword()),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->userPassword()),
|
2 => array ( 'kind' => 'input', 'name' => 'genpass', 'type' => 'submit', 'value' => _('Generate password')));
|
||||||
2 => array ( 'kind' => 'input', 'name' => 'genpass', 'type' => 'submit', 'value' => _('Generate password')));
|
if ($post['userPassword2']!='') $password2 = $post['userPassword2'];
|
||||||
if ($post['userPassword2']!='') $password2 = $post['userPassword2'];
|
else $password2 = $this->userPassword();
|
||||||
else $password2 = $this->userPassword();
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
2 => array ('kind' => 'help', 'value' => 'userPassword'));
|
||||||
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),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Set no password') ),
|
2 => array ('kind' => 'help', 'value' => 'userPassword_nopassword'));
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword_nopassword', 'type' => 'checkbox', 'checked' => $this->userPassword_nopassword),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Invalid password') ),
|
||||||
2 => array ('kind' => 'help', 'value' => 'userPassword_nopassword'));
|
1 => array ( 'kind' => 'input', 'name' => 'userPassword_invalid', 'type' => 'checkbox', 'checked' => $this->userPassword_invalid),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Invalid password') ),
|
2 => array ('kind' => 'help', 'value' => 'userPassword_invalid'));
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword_invalid', 'type' => 'checkbox', 'checked' => $this->userPassword_invalid),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Lock password') ),
|
||||||
2 => array ('kind' => 'help', 'value' => 'userPassword_invalid'));
|
1 => array ( 'kind' => 'input', 'name' => 'userPassword_lock', 'type' => 'checkbox', 'checked' => $this->userPassword_lock),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Lock password') ),
|
2 => array ('kind' => 'help', 'value' => 'userPassword_lock'));
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'userPassword_lock', 'type' => 'checkbox', 'checked' => $this->userPassword_lock),
|
if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='')
|
||||||
2 => array ('kind' => 'help', 'value' => 'userPassword_lock'));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Change GID number of users and hosts') ),
|
||||||
if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='' && !$profile) {
|
1 => array ( 'kind' => 'input', 'name' => 'changegids', 'type' => 'checkbox', 'checked' => $this->changegids, 'value' => true),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Change GID number of users and hosts') ),
|
2 => array ('kind' => 'help', 'value' => 'changegids'));
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'changegids', 'type' => 'checkbox', 'checked' => $this->changegids, 'value' => true),
|
|
||||||
2 => array ('kind' => 'help', 'value' => 'changegids'));
|
|
||||||
}
|
|
||||||
return $return;
|
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
|
// load list with all groups
|
||||||
$dn_users = $_SESSION['cache']->get_cache('uid', 'posixAccount', 'user');
|
$dn_users = $_SESSION['cache']->get_cache('uid', 'posixAccount', 'user');
|
||||||
if (is_array($dn_users)) {
|
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
|
* Returns meta data that is interpreted by parent class
|
||||||
*
|
*
|
||||||
|
@ -457,166 +441,164 @@ class posixGroup extends baseModule {
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* 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'];
|
$this->attributes['description'][0] = $post['description'];
|
||||||
|
|
||||||
If (!$profile) {
|
if (($post['userPassword_lock'] && $post['userPassword_invalid']) || ($post['userPassword_nopassword'] && $post['userPassword_invalid'])) {
|
||||||
if (($post['userPassword_lock'] && $post['userPassword_invalid']) || ($post['userPassword_nopassword'] && $post['userPassword_invalid'])) {
|
// found invalid password parameter combination
|
||||||
// found invalid password parameter combination
|
$triggered_messages['userPassword'][] = $this->messages['userPassword'][3];
|
||||||
$errors['userPassword'][] = $this->messages['userPassword'][3];
|
}
|
||||||
|
else {
|
||||||
|
if ($post['userPassword_nopassword']) {
|
||||||
|
$this->userPassword_nopassword=true;
|
||||||
|
$this->userPassword_invalid=false;
|
||||||
|
$this->userPassword('');
|
||||||
|
$post['userPassword2'] = '';
|
||||||
|
if ($post['userPassword_lock'])
|
||||||
|
$this->userPassword_lock=true;
|
||||||
|
else $this->userPassword_lock=false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($post['userPassword_nopassword']) {
|
$this->userPassword_nopassword=false;
|
||||||
$this->userPassword_nopassword=true;
|
if ($post['userPassword_invalid']) {
|
||||||
$this->userPassword_invalid=false;
|
$this->userPassword_invalid=true;
|
||||||
|
$this->userPassword_lock=false;
|
||||||
$this->userPassword('');
|
$this->userPassword('');
|
||||||
$post['userPassword2'] = '';
|
$post['userPassword2'] = '';
|
||||||
if ($post['userPassword_lock'])
|
}
|
||||||
$this->userPassword_lock=true;
|
else {
|
||||||
|
$this->userPassword_invalid=false;
|
||||||
|
if ($post['genpass']) $this->userPassword(genpasswd());
|
||||||
|
else {
|
||||||
|
if ($post['userPassword'] != $post['userPassword2'])
|
||||||
|
$triggered_messages['userPassword'][] = $this->messages['userPassword'][0];
|
||||||
|
else $this->userPassword($post['userPassword']);
|
||||||
|
if (!get_preg($this->userPassword(), 'password'))
|
||||||
|
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
||||||
|
}
|
||||||
|
if ($post['userPassword_lock']) $this->userPassword_lock=true;
|
||||||
else $this->userPassword_lock=false;
|
else $this->userPassword_lock=false;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->userPassword_nopassword=false;
|
|
||||||
if ($post['userPassword_invalid']) {
|
|
||||||
$this->userPassword_invalid=true;
|
|
||||||
$this->userPassword_lock=false;
|
|
||||||
$this->userPassword('');
|
|
||||||
$post['userPassword2'] = '';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->userPassword_invalid=false;
|
|
||||||
if ($post['genpass']) $this->userPassword(genpasswd());
|
|
||||||
else {
|
|
||||||
if ($post['userPassword'] != $post['userPassword2'])
|
|
||||||
$errors['userPassword'][] = $this->messages['userPassword'][0];
|
|
||||||
else $this->userPassword($post['userPassword']);
|
|
||||||
if (!get_preg($this->userPassword(), 'password'))
|
|
||||||
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
|
||||||
}
|
|
||||||
if ($post['userPassword_lock']) $this->userPassword_lock=true;
|
|
||||||
else $this->userPassword_lock=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($post['changegids']) $this->changegids=true;
|
|
||||||
else $this->changegids=false;
|
|
||||||
if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->errors['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]);
|
|
||||||
$maxID = intval($this->moduleSettings['posixGroup_maxGID'][0]);
|
|
||||||
$dn_gids = $_SESSION['cache']->get_cache('gidNumber', 'posixGroup', '*');
|
|
||||||
// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
|
|
||||||
if(is_array($dn_gids)) {
|
|
||||||
foreach ($dn_gids as $gid) $gids[] = $gid[0];
|
|
||||||
sort ($gids, SORT_NUMERIC);
|
|
||||||
}
|
|
||||||
$this->attributes['gidNumber'][0]=$post['gidNumber'];
|
|
||||||
if ($this->attributes['gidNumber'][0]=='') {
|
|
||||||
// No id-number given
|
|
||||||
if ($this->orig['gidNumber'][0]=='') {
|
|
||||||
// new account -> we have to find a free id-number
|
|
||||||
if (count($gids)!=0) {
|
|
||||||
// There are some uids
|
|
||||||
// Store highest id-number
|
|
||||||
$id = $gids[count($gids)-1];
|
|
||||||
// Return minimum allowed id-number if all found id-numbers are too low
|
|
||||||
if ($id < $minID) $this->attributes['gidNumber'][0] = $minID;
|
|
||||||
// Return higesht used id-number + 1 if it's still in valid range
|
|
||||||
if ($id < $maxID) $this->attributes['gidNumber'][0] = $id+1;
|
|
||||||
/* If this function is still running we have to fid a free id-number between
|
|
||||||
* the used id-numbers
|
|
||||||
*/
|
|
||||||
$i = intval($minID);
|
|
||||||
while (in_array($i, $gids)) $i++;
|
|
||||||
if ($i>$maxID)
|
|
||||||
$errors['gidNumber'][] = $this->messages['gidNumber'][3];
|
|
||||||
else {
|
|
||||||
$this->attributes['gidNumber'][0] = $i;
|
|
||||||
$errors['gidNumber'][] = $this->messages['gidNumber'][2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else $this->attributes['gidNumber'][0] = $minID;
|
|
||||||
// return minimum allowed id-number if no id-numbers are found
|
|
||||||
}
|
|
||||||
else $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
|
|
||||||
// old account -> return id-number which has been used
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
// $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'));
|
|
||||||
// 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];
|
|
||||||
$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($this->attributes['cn'][0]!=$post['cn'] || ($this->errors['cn'][0]='ERROR')) {
|
if ($post['changegids']) $this->changegids=true;
|
||||||
$this->attributes['cn'][0] = $post['cn'];
|
else $this->changegids=false;
|
||||||
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
|
if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->triggered_messages['gidNumber'][0]='ERROR')) {
|
||||||
$errors['cn'][] = $this->messages['cn'][0];
|
// Check if GID is valid. If none value was entered, the next useable value will be inserted
|
||||||
// Check if Groupname contains only valid characters
|
// load min and may uidNumber
|
||||||
if ( !get_preg($this->attributes['cn'][0],'groupname'))
|
$minID = intval($this->moduleSettings['posixGroup_minGID'][0]);
|
||||||
$errors['cn'][] = $this->messages['cn'][2];
|
$maxID = intval($this->moduleSettings['posixGroup_maxGID'][0]);
|
||||||
// Create automatic useraccount with number if original user already exists
|
$dn_gids = $_SESSION['cache']->get_cache('gidNumber', 'posixGroup', '*');
|
||||||
// Reset name to original name if new name is in use
|
// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
|
||||||
// Set username back to original name if new username is in use
|
if(is_array($dn_gids)) {
|
||||||
if ($_SESSION['cache']->in_cache($this->attributes['cn'][0],'cn', '*')!=false && ($this->orig['cn'][0]!='')) {
|
foreach ($dn_gids as $gid) $gids[] = $gid[0];
|
||||||
$this->attributes['cn'][0] = $this->orig['cn'][0];
|
sort ($gids, SORT_NUMERIC);
|
||||||
}
|
}
|
||||||
// Change gid to a new gid until a free gid is found
|
$this->attributes['gidNumber'][0]=$post['gidNumber'];
|
||||||
else while ($_SESSION['cache']->in_cache($this->attributes['cn'][0], 'cn', '*')) {
|
if ($this->attributes['gidNumber'][0]=='') {
|
||||||
// get last character of username
|
// No id-number given
|
||||||
$lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1);
|
if ($this->orig['gidNumber'][0]=='') {
|
||||||
// Last character is no number
|
// new account -> we have to find a free id-number
|
||||||
if ( !ereg('^([0-9])+$', $lastchar))
|
if (count($gids)!=0) {
|
||||||
/* Last character is no number. Therefore we only have to
|
// There are some uids
|
||||||
* add "2" to it.
|
// Store highest id-number
|
||||||
*/
|
$id = $gids[count($gids)-1];
|
||||||
$this->attributes['cn'][0] = $this->attributes['cn'][0] . '2';
|
// Return minimum allowed id-number if all found id-numbers are too low
|
||||||
else {
|
if ($id < $minID) $this->attributes['gidNumber'][0] = $minID;
|
||||||
/* Last character is a number -> we have to increase the number until we've
|
// Return higesht used id-number + 1 if it's still in valid range
|
||||||
* found a groupname with trailing number which is not in use.
|
if ($id < $maxID) $this->attributes['gidNumber'][0] = $id+1;
|
||||||
*
|
/* If this function is still running we have to fid a free id-number between
|
||||||
* $i will show us were we have to split groupname so we get a part
|
* the used id-numbers
|
||||||
* with the groupname and a part with the trailing number
|
|
||||||
*/
|
*/
|
||||||
$i=strlen($this->attributes['cn'][0])-1;
|
$i = intval($minID);
|
||||||
$mark = false;
|
while (in_array($i, $gids)) $i++;
|
||||||
// Set $i to the last character which is a number in $account_new->general_username
|
if ($i>$maxID)
|
||||||
while (!$mark) {
|
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][3];
|
||||||
if (ereg('^([0-9])+$',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--;
|
else {
|
||||||
else $mark=true;
|
$this->attributes['gidNumber'][0] = $i;
|
||||||
|
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][2];
|
||||||
}
|
}
|
||||||
// increase last number with one
|
}
|
||||||
$firstchars = substr($this->attributes['cn'][0], 0, $i+1);
|
else $this->attributes['gidNumber'][0] = $minID;
|
||||||
$lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i);
|
// return minimum allowed id-number if no id-numbers are found
|
||||||
// Put username together
|
}
|
||||||
$this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1);
|
else $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
|
||||||
|
// old account -> return id-number which has been used
|
||||||
|
}
|
||||||
|
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)) $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]=='') $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]) ) {
|
||||||
|
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][4];
|
||||||
|
$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Show warning if lam has changed username
|
|
||||||
if ($this->attributes['cn'][0] != $post['cn']) {
|
|
||||||
$errors['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];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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']))
|
||||||
|
$triggered_messages['cn'][] = $this->messages['cn'][0];
|
||||||
|
// Check if Groupname contains only valid characters
|
||||||
|
if ( !get_preg($this->attributes['cn'][0],'groupname'))
|
||||||
|
$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
|
||||||
|
if ($_SESSION['cache']->in_cache($this->attributes['cn'][0],'cn', '*')!=false && ($this->orig['cn'][0]!='')) {
|
||||||
|
$this->attributes['cn'][0] = $this->orig['cn'][0];
|
||||||
|
}
|
||||||
|
// Change gid to a new gid until a free gid is found
|
||||||
|
else while ($_SESSION['cache']->in_cache($this->attributes['cn'][0], 'cn', '*')) {
|
||||||
|
// get last character of username
|
||||||
|
$lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1);
|
||||||
|
// Last character is no number
|
||||||
|
if ( !ereg('^([0-9])+$', $lastchar))
|
||||||
|
/* Last character is no number. Therefore we only have to
|
||||||
|
* add "2" to it.
|
||||||
|
*/
|
||||||
|
$this->attributes['cn'][0] = $this->attributes['cn'][0] . '2';
|
||||||
|
else {
|
||||||
|
/* Last character is a number -> we have to increase the number until we've
|
||||||
|
* found a groupname with trailing number which is not in use.
|
||||||
|
*
|
||||||
|
* $i will show us were we have to split groupname so we get a part
|
||||||
|
* with the groupname and a part with the trailing number
|
||||||
|
*/
|
||||||
|
$i=strlen($this->attributes['cn'][0])-1;
|
||||||
|
$mark = false;
|
||||||
|
// Set $i to the last character which is a number in $account_new->general_username
|
||||||
|
while (!$mark) {
|
||||||
|
if (ereg('^([0-9])+$',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--;
|
||||||
|
else $mark=true;
|
||||||
|
}
|
||||||
|
// increase last number with one
|
||||||
|
$firstchars = substr($this->attributes['cn'][0], 0, $i+1);
|
||||||
|
$lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i);
|
||||||
|
// Put username together
|
||||||
|
$this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Show warning if lam has changed username
|
||||||
|
if ($this->attributes['cn'][0] != $post['cn']) {
|
||||||
|
$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])
|
||||||
|
$triggered_messages['gidNumber'][] = $this->messages['gidNumber'][0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Return error-messages
|
// Return error-messages
|
||||||
if (count($errors)!=0) {
|
if (count($triggered_messages)!=0) {
|
||||||
$this->errors = $errors;
|
$this->triggered_messages = $triggered_messages;
|
||||||
return $errors;
|
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
|
// Go to additional group page when no error did ocour and button was pressed
|
||||||
if ($post['adduser']) return 'user';
|
if ($post['adduser']) return 'user';
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -625,7 +607,7 @@ class posixGroup extends baseModule {
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* 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
|
do { // X-Or, only one if() can be true
|
||||||
if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add groups to list
|
if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add groups to list
|
||||||
// Add new user
|
// Add new user
|
||||||
|
@ -783,6 +765,7 @@ class posixGroup extends baseModule {
|
||||||
else return '';
|
else return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -252,7 +252,7 @@ class quota extends baseModule {
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* 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
|
// Write all general values into $account_new
|
||||||
$i=0;
|
$i=0;
|
||||||
// loop for every mointpoint with quotas
|
// loop for every mointpoint with quotas
|
||||||
|
@ -263,22 +263,25 @@ class quota extends baseModule {
|
||||||
$this->quota[$i][7] = $post[$i . '_7'];
|
$this->quota[$i][7] = $post[$i . '_7'];
|
||||||
// Check if values are OK and set automatic values. if not error-variable will be set
|
// Check if values are OK and set automatic values. if not error-variable will be set
|
||||||
if (!get_preg($this->quota[$i][2], 'digit'))
|
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'))
|
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'))
|
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'))
|
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]))
|
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]))
|
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++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return error-messages
|
if (count($triggered_messages)!=0) {
|
||||||
if (is_array($errors)) return $errors;
|
$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
|
// Go to additional group page when no error did ocour and button was pressed
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +290,7 @@ class quota extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* 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') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Mountpoint') ),
|
||||||
1 => array ( 'kind' => 'text', 'text' => _('Used blocks') ),
|
1 => array ( 'kind' => 'text', 'text' => _('Used blocks') ),
|
||||||
|
|
|
@ -175,8 +175,8 @@ class sambaAccount extends baseModule {
|
||||||
// Array of well known rids
|
// Array of well known rids
|
||||||
var $rids;
|
var $rids;
|
||||||
|
|
||||||
/* $attribute['lmPassword'] and ntPassword can't accessed directly because it's enrcypted
|
/* $attribute['lmPassword'] and $attribute['ntPassword'] can't accessed directly because it's enrcypted
|
||||||
* To read / write password function userPassword is needed
|
* To read / write password function lmPassword is needed
|
||||||
* This function will return the unencrypted password when
|
* This function will return the unencrypted password when
|
||||||
* called without a variable
|
* called without a variable
|
||||||
* If it's called with a new password, the
|
* If it's called with a new password, the
|
||||||
|
@ -185,7 +185,9 @@ class sambaAccount extends baseModule {
|
||||||
function lmPassword($newpassword=false) {
|
function lmPassword($newpassword=false) {
|
||||||
if (is_string($newpassword)) {
|
if (is_string($newpassword)) {
|
||||||
// Write new password
|
// 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;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -303,7 +305,7 @@ class sambaAccount extends baseModule {
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* 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'];
|
$this->attributes['domain'][0] = $post['domain'];
|
||||||
// Start character
|
// Start character
|
||||||
$flag = "[";
|
$flag = "[";
|
||||||
|
@ -320,7 +322,7 @@ class sambaAccount extends baseModule {
|
||||||
$flag = $flag. "]";
|
$flag = $flag. "]";
|
||||||
$this->attributes['acctFlags'][0] = $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')];
|
$this->attributes['primaryGroupID'][0] = $this->rids[_('Domain Computers')];
|
||||||
if ($post['ResetSambaPassword']) {
|
if ($post['ResetSambaPassword']) {
|
||||||
// *** fixme. What is the default password?
|
// *** fixme. What is the default password?
|
||||||
|
@ -339,84 +341,86 @@ class sambaAccount extends baseModule {
|
||||||
$this->attributes['homeDrive'][0] = $post['homeDrive'];
|
$this->attributes['homeDrive'][0] = $post['homeDrive'];
|
||||||
$this->attributes['scriptPath'][0] = stripslashes($post['scriptPath']);
|
$this->attributes['scriptPath'][0] = stripslashes($post['scriptPath']);
|
||||||
$this->attributes['profilePath'][0] = stripslashes($post['profilePath']);
|
$this->attributes['profilePath'][0] = stripslashes($post['profilePath']);
|
||||||
if (!$profile) {
|
$rids = array_keys($this->rids);
|
||||||
$rids = array_keys($this->rids);
|
$wrid = false;
|
||||||
$wrid = false;
|
for ($i=0; $i<count($rids); $i++) {
|
||||||
for ($i=0; $i<count($rids); $i++) {
|
if ($post['primaryGroupID'] == $rids[$i]) {
|
||||||
if ($post['primaryGroupID'] == $rids[$i]) {
|
$wrid = true;
|
||||||
$wrid = true;
|
$this->attributes['primaryGroupID'][0] = $this->rids[$rids[$i]];
|
||||||
$this->attributes['primaryGroupID'][0] = $this->rids[$rids[$i]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
|
|
||||||
|
|
||||||
if (isset($post['lmPassword'])) {
|
|
||||||
if ($post['lmPassword'] != $post['lmPassword2']) {
|
|
||||||
$errors['lmPassword'][] = $this->messages['lmPassword'][0];
|
|
||||||
unset ($post['lmPassword2']);
|
|
||||||
}
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
$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];
|
|
||||||
$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];
|
|
||||||
$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['smbHome'][0]=='') && (!get_preg($this->attributes['smbHome'][0], 'UNC')))
|
|
||||||
$errors['smbHome'][] = $this->messages['homedir'][0];
|
|
||||||
if ( (!$this->attributes['scriptPath'][0]=='') && (!get_preg($this->attributes['scriptPath'][0], 'logonscript')))
|
|
||||||
$errors['scriptPath'][] = $this->messages['logonScript'][0];
|
|
||||||
if ( (!$this->attributes['profilePath'][0]=='') && (!get_preg($this->attributes['profilePath'][0], 'UNC')))
|
|
||||||
$errors['profilePath'][] = $this->messages['profilePath'][0];
|
|
||||||
}
|
}
|
||||||
else {
|
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
|
||||||
$smbHome = str_replace('$user', 'user', $this->attributes['smbHome'][0]);
|
|
||||||
$smbHome = str_replace('$group', 'group', $smbHome);
|
|
||||||
$scriptPath = str_replace('$user', 'user', $this->attributes['scriptPath'][0]);
|
|
||||||
$scriptPath = str_replace('$group', 'group', $scriptPath);
|
|
||||||
$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];
|
|
||||||
if ( (!$scriptPath=='') && (!get_preg($scriptPath, 'logonscript')))
|
|
||||||
$errors['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;
|
if ($post['useunixpwd']) $this->useunixpwd = true;
|
||||||
else $this->useunixpwd = false;
|
else $this->useunixpwd = false;
|
||||||
|
if (isset($post['lmPassword'])) {
|
||||||
|
if ($post['lmPassword'] != $post['lmPassword2']) {
|
||||||
|
$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)
|
||||||
|
$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)
|
||||||
|
$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'])) $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'])) $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'])) $triggered_messages['profilePath'][] = $this->messages['profilePath'][1];
|
||||||
|
if ( (!$this->attributes['smbHome'][0]=='') && (!get_preg($this->attributes['smbHome'][0], 'UNC')))
|
||||||
|
$triggered_messages['smbHome'][] = $this->messages['homedir'][0];
|
||||||
|
if ( (!$this->attributes['scriptPath'][0]=='') && (!get_preg($this->attributes['scriptPath'][0], 'logonscript')))
|
||||||
|
$triggered_messages['scriptPath'][] = $this->messages['logonScript'][0];
|
||||||
|
if ( (!$this->attributes['profilePath'][0]=='') && (!get_preg($this->attributes['profilePath'][0], 'UNC')))
|
||||||
|
$triggered_messages['profilePath'][] = $this->messages['profilePath'][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$smbHome = str_replace('$user', 'user', $this->attributes['smbHome'][0]);
|
||||||
|
$smbHome = str_replace('$group', 'group', $smbHome);
|
||||||
|
$scriptPath = str_replace('$user', 'user', $this->attributes['scriptPath'][0]);
|
||||||
|
$scriptPath = str_replace('$group', 'group', $scriptPath);
|
||||||
|
$profilePath = str_replace('$user', 'user', $this->attributes['profilePath'][0]);
|
||||||
|
$profilePath = str_replace('$group', 'group', $profilePath);
|
||||||
|
if ( (!$smbHome=='') && (!get_preg($smbHome, 'UNC')))
|
||||||
|
$triggered_messages['smbHome'][] = $this->messages['homePath'][0];
|
||||||
|
if ( (!$scriptPath=='') && (!get_preg($scriptPath, 'logonscript')))
|
||||||
|
$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')))
|
||||||
|
$triggered_messages['profilePath'][] = $this->messages['profilePath'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!$this->attributes['domain'][0]=='') && !get_preg($this->attributes['domain'][0], 'domainname'))
|
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';
|
if ($post['userWorkstations']) return 'userWorkstations';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* Write variables into object and do some regexp checks
|
||||||
*/
|
*/
|
||||||
function proccess_userWorkstations($post, $profile=false) {
|
function proccess_userWorkstations($post) {
|
||||||
// Load attributes
|
// Load attributes
|
||||||
if ($_SESSION[$this->base]->type=='user') {
|
if ($_SESSION[$this->base]->type=='user') {
|
||||||
do { // X-Or, only one if() can be true
|
do { // X-Or, only one if() can be true
|
||||||
|
@ -467,7 +471,7 @@ class sambaAccount extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* 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') {
|
if ($_SESSION[$this->base]->type=='user') {
|
||||||
$canchangedate = getdate($this->attributes['pwdCanChange'][0]);
|
$canchangedate = getdate($this->attributes['pwdCanChange'][0]);
|
||||||
$mustchangedate = getdate($this->attributes['pwdMustChange'][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']),
|
5 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
|
||||||
6 => array ( 'kind' => 'input', 'name' => 'acctFlagsU', 'type' => 'hidden', 'value' => 'true'));
|
6 => array ( 'kind' => 'input', 'name' => 'acctFlagsU', 'type' => 'hidden', 'value' => 'true'));
|
||||||
|
|
||||||
if (!$profile) {
|
if ($post['lmPassword2']!='') $password2 = $post['lmPassword2'];
|
||||||
if ($this->attributes['lmPassword'][0] != $this->orig['lmPassword'][0]) $password=$this->lmPassword();
|
else $password2 = $this->lmPassword();
|
||||||
else if ($this->attributes['lmPassword'][0] != '') $password=$post['lmPassword'];
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
|
1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->lmPassword()));
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||||
if ($post['lmPassword2']!='') $password2 = $post['lmPassword2'];
|
1 => array ( 'kind' => 'input', 'name' => 'lmPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
2 => array ('kind' => 'help', 'value' => 'lmPassword'));
|
||||||
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]) {
|
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') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use unix password') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd, 'value' => true),
|
1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd, 'value' => true),
|
||||||
|
@ -546,56 +546,50 @@ class sambaAccount extends baseModule {
|
||||||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations', 'value' => _('Edit workstations')),
|
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations', 'value' => _('Edit workstations')),
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'userWorkstations' ));
|
2 => array ( 'kind' => 'help', 'value' => 'userWorkstations' ));
|
||||||
|
|
||||||
if (!$profile) {
|
$names = array_keys($this->rids);
|
||||||
$names = array_keys($this->rids);
|
$wrid=false;
|
||||||
$wrid=false;
|
for ($i=0; $i<count($names); $i++) {
|
||||||
for ($i=0; $i<count($names); $i++) {
|
if ($this->attributes['primaryGroupID'][0]==$this->rids[$names[$i]]) {
|
||||||
if ($this->attributes['primaryGroupID'][0]==$this->rids[$names[$i]]) {
|
$selected[] = $names[$i];
|
||||||
$selected[] = $names[$i];
|
|
||||||
$wrid=true;
|
|
||||||
}
|
|
||||||
else $options[] = $names[$i];
|
|
||||||
}
|
|
||||||
if ($wrid) $options[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
|
||||||
else $selected[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
|
|
||||||
1 => array ( 'kind' => 'select', 'name' => 'primaryGroupID', 'options' => $options, 'options_selected' => $selected),
|
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'primaryGroupID' ));
|
|
||||||
// Display if group SID should be mapped to a well kown SID
|
|
||||||
$wrid=false;
|
|
||||||
if ($this->attributes['rid'][0]=="500") {
|
|
||||||
$selected[] = _('Administrator');
|
|
||||||
$wrid=true;
|
$wrid=true;
|
||||||
}
|
}
|
||||||
else $options[] = _('Administrator');
|
else $options[] = $names[$i];
|
||||||
if ($this->attributes['rid'][0]=="501") {
|
|
||||||
$selected[] = _('Guest');
|
|
||||||
$wrid=true;
|
|
||||||
}
|
|
||||||
else $options[] = _('Guest');
|
|
||||||
if ($wrid) $options[] = _('Ordinary user');
|
|
||||||
else $selected[] = _('Ordinary user');
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ),
|
|
||||||
1 => array ( 'kind' => 'select', 'name' => 'rid', 'options' => $options, 'options_selected' => $selected),
|
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'rid' ));
|
|
||||||
}
|
}
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
if ($wrid) $options[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
||||||
1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),
|
else $selected[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'domain' ));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
|
||||||
|
1 => array ( 'kind' => 'select', 'name' => 'primaryGroupID', 'options' => $options, 'options_selected' => $selected),
|
||||||
|
2 => array ( 'kind' => 'help', 'value' => 'primaryGroupID' ));
|
||||||
|
// Display if group SID should be mapped to a well kown SID
|
||||||
|
$wrid=false;
|
||||||
|
if ($this->attributes['rid'][0]=="500") {
|
||||||
|
$selected[] = _('Administrator');
|
||||||
|
$wrid=true;
|
||||||
|
}
|
||||||
|
else $options[] = _('Administrator');
|
||||||
|
if ($this->attributes['rid'][0]=="501") {
|
||||||
|
$selected[] = _('Guest');
|
||||||
|
$wrid=true;
|
||||||
|
}
|
||||||
|
else $options[] = _('Guest');
|
||||||
|
if ($wrid) $options[] = _('Ordinary user');
|
||||||
|
else $selected[] = _('Ordinary user');
|
||||||
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ),
|
||||||
|
1 => array ( 'kind' => 'select', 'name' => 'rid', 'options' => $options, 'options_selected' => $selected),
|
||||||
|
2 => array ( 'kind' => 'help', 'value' => 'rid' ));
|
||||||
}
|
}
|
||||||
|
$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') {
|
if ($_SESSION[$this->base]->type=='host') {
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'acctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
|
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'acctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
|
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
|
||||||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
|
2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
|
|
||||||
}
|
|
||||||
$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[] = 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;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
for ($i = 0; $i < sizeof($domains); $i++) {
|
for ($i = 0; $i < sizeof($domains); $i++) {
|
||||||
$nameToRIDBase[$domains[$i]->name] = $domains[$i]->RIDbase;
|
$nameToRIDBase[$domains[$i]->name] = $domains[$i]->RIDbase;
|
||||||
}
|
}
|
||||||
$errors = array();
|
$triggered_messages = array();
|
||||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
||||||
// group type
|
// group type
|
||||||
if ($rawAccounts[$i][$ids['sambaGroupMapping_groupType']] != "") {
|
if ($rawAccounts[$i][$ids['sambaGroupMapping_groupType']] != "") {
|
||||||
|
@ -94,7 +94,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
else { // invalid type
|
else { // invalid type
|
||||||
$errMsg = $this->messages['groupType'][0];
|
$errMsg = $this->messages['groupType'][0];
|
||||||
array_push($errMsg, array($i, implode(", ", array_keys($this->sambaGroupTypes) + $this->sambaGroupTypes)));
|
array_push($errMsg, array($i, implode(", ", array_keys($this->sambaGroupTypes) + $this->sambaGroupTypes)));
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -107,7 +107,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
$errMsg = $this->messages['sambaSID'][1];
|
$errMsg = $this->messages['sambaSID'][1];
|
||||||
array_push($errMsg, $rawAccounts[$i][$ids['sambaGroupMapping_domain']]);
|
array_push($errMsg, $rawAccounts[$i][$ids['sambaGroupMapping_domain']]);
|
||||||
array_push($errMsg, $i);
|
array_push($errMsg, $i);
|
||||||
$errors[] = $errMsg;
|
$triggered_messages[] = $errMsg;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// RID
|
// RID
|
||||||
|
@ -130,7 +130,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
$partialAccounts[$i]['displayName'] = $rawAccounts[$i][$ids['sambaGroupMapping_name']];
|
$partialAccounts[$i]['displayName'] = $rawAccounts[$i][$ids['sambaGroupMapping_name']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $errors;
|
return $triggered_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_attributes($post) {
|
function delete_attributes($post) {
|
||||||
|
@ -142,7 +142,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* It will output a complete html-table
|
||||||
*/
|
*/
|
||||||
function display_html_attributes($post, $profile=false) {
|
function display_html_attributes($post) {
|
||||||
// Get Domain SID from name
|
// Get Domain SID from name
|
||||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||||
// Get Domain-SID from group SID
|
// Get Domain-SID from group SID
|
||||||
|
@ -160,22 +160,20 @@ class sambaGroupMapping extends baseModule {
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $this->attributes['displayName'][0]),
|
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $this->attributes['displayName'][0]),
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'displayName' ));
|
2 => array ( 'kind' => 'help', 'value' => 'displayName' ));
|
||||||
|
|
||||||
if (!$profile) {
|
$names = array_keys($this->rids);
|
||||||
$names = array_keys($this->rids);
|
$wrid=false;
|
||||||
$wrid=false;
|
for ($i=0; $i<count($names); $i++) {
|
||||||
for ($i=0; $i<count($names); $i++) {
|
if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
||||||
if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
$selected[] = $names[$i];
|
||||||
$selected[] = $names[$i];
|
$wrid=true;
|
||||||
$wrid=true;
|
}
|
||||||
}
|
else $options[] = $names[$i];
|
||||||
else $options[] = $names[$i];
|
|
||||||
}
|
|
||||||
if ($wrid) $options[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
|
||||||
else $selected[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
|
||||||
$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' ));
|
|
||||||
}
|
}
|
||||||
|
if ($wrid) $options[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
||||||
|
else $selected[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
||||||
|
$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);
|
$names = array_keys($this->sambaGroupTypes);
|
||||||
$selected = array( _('Domain Group') );
|
$selected = array( _('Domain Group') );
|
||||||
|
@ -371,40 +369,40 @@ class sambaGroupMapping extends baseModule {
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* Write variables into object and do some regexp checks
|
||||||
*/
|
*/
|
||||||
function proccess_attributes($post, $profile=false) {
|
function proccess_attributes($post) {
|
||||||
// Save attributes
|
// Save attributes
|
||||||
$this->attributes['displayName'][0] = $post['displayName'];
|
$this->attributes['displayName'][0] = $post['displayName'];
|
||||||
$this->attributes['sambaGroupType'][0] = $this->sambaGroupTypes[$post['sambaGroupType']];
|
$this->attributes['sambaGroupType'][0] = $this->sambaGroupTypes[$post['sambaGroupType']];
|
||||||
|
|
||||||
if (!$profile) {
|
// Get Domain SID from name
|
||||||
// Get Domain SID from name
|
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
for ($i=0; $i<count($sambaDomains); $i++ )
|
||||||
for ($i=0; $i<count($sambaDomains); $i++ )
|
if ($post['sambaDomainName'] == $sambaDomains[$i]->name) {
|
||||||
if ($post['sambaDomainName'] == $sambaDomains[$i]->name) {
|
$SID = $sambaDomains[$i]->SID;
|
||||||
$SID = $sambaDomains[$i]->SID;
|
$RIDbase = $sambaDomain[$i]->RIDbase;
|
||||||
$RIDbase = $sambaDomain[$i]->RIDbase;
|
}
|
||||||
}
|
// Load attributes
|
||||||
|
$this->attributes['displayName'][0] = $post['displayName'];
|
||||||
// Load attributes
|
$rids = array_keys($this->rids);
|
||||||
$this->attributes['displayName'][0] = $post['displayName'];
|
$wrid = false;
|
||||||
|
for ($i=0; $i<count($rids); $i++) {
|
||||||
$rids = array_keys($this->rids);
|
if ($post['sambaSID'] == $rids[$i]) {
|
||||||
$wrid = false;
|
$wrid = true;
|
||||||
for ($i=0; $i<count($rids); $i++) {
|
// Get Domain SID
|
||||||
if ($post['sambaSID'] == $rids[$i]) {
|
$this->attributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]];
|
||||||
$wrid = true;
|
// Do a check if special grou pis unique
|
||||||
// Get Domain SID
|
if ($_SESSION['cache']->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group'))
|
||||||
$this->attributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]];
|
$triggered_messages[] = $this->messages['sambaSID'][0];
|
||||||
// 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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!$wrid) $this->attributes['sambaSID'][0] = $SID . "-" . ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+$RIDbase+1);
|
|
||||||
}
|
}
|
||||||
|
if (!$wrid) $this->attributes['sambaSID'][0] = $SID . "-" . ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+$RIDbase+1);
|
||||||
|
|
||||||
// Return error-messages
|
// 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,8 +116,8 @@ class sambaSamAccount extends baseModule {
|
||||||
var $rids;
|
var $rids;
|
||||||
|
|
||||||
|
|
||||||
/* $attribute['sambaLMPassword'] and sambaNTPassword can't accessed directly because it's enrcypted
|
/* $attribute['sambaLMPassword'] and $attribute['sambaNTPassword'] can't accessed directly because it's enrcypted
|
||||||
* To read / write password function userPassword is needed
|
* To read / write password function sambaLMPassword is needed
|
||||||
* This function will return the unencrypted password when
|
* This function will return the unencrypted password when
|
||||||
* called without a variable
|
* called without a variable
|
||||||
* If it's called with a new password, the
|
* If it's called with a new password, the
|
||||||
|
@ -127,7 +127,7 @@ class sambaSamAccount extends baseModule {
|
||||||
if (is_string($newpassword)) {
|
if (is_string($newpassword)) {
|
||||||
// Write new password
|
// Write new password
|
||||||
if ($newpassword=='')
|
if ($newpassword=='')
|
||||||
$this->attributes['userPassword'][0] = '';
|
$this->attributes['sambaLMPassword'][0] = '';
|
||||||
else $this->attributes['sambaLMPassword'][0] = base64_encode($_SESSION['ldap']->encrypt($newpassword));
|
else $this->attributes['sambaLMPassword'][0] = base64_encode($_SESSION['ldap']->encrypt($newpassword));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -178,17 +178,6 @@ class sambaSamAccount extends baseModule {
|
||||||
return false;
|
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
|
/* This function loads all attributes into the object
|
||||||
* $attr is an array as it's retured from ldap_get_attributes
|
* $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
|
/* Write variables into object and do some regexp checks
|
||||||
*/
|
*/
|
||||||
function proccess_attributes($post, $profile=false) {
|
function proccess_attributes($post) {
|
||||||
// Save attributes
|
// Save attributes
|
||||||
$this->attributes['sambaDomainName'][0] = $post['sambaDomainName'];
|
$this->attributes['sambaDomainName'][0] = $post['sambaDomainName'];
|
||||||
// Get Domain SID from name
|
// Get Domain SID from name
|
||||||
|
@ -321,74 +310,76 @@ class sambaSamAccount extends baseModule {
|
||||||
|
|
||||||
if ($post['useunixpwd']) $this->useunixpwd = true;
|
if ($post['useunixpwd']) $this->useunixpwd = true;
|
||||||
else $this->useunixpwd = false;
|
else $this->useunixpwd = false;
|
||||||
if (isset($post['sambaLMPassword']) && !$profile) {
|
if (isset($post['sambaLMPassword'])) {
|
||||||
if ($post['sambaLMPassword'] != $post['sambaLMPassword2']) {
|
if ($post['sambaLMPassword'] != $post['sambaLMPassword2']) {
|
||||||
$errors['sambaLMPassword'][] = $this->messages['sambaLMPassword'][0];
|
$triggered_messages['sambaLMPassword'][] = $this->messages['sambaLMPassword'][0];
|
||||||
unset ($post['sambaLMPassword2']);
|
unset ($post['sambaLMPassword2']);
|
||||||
}
|
}
|
||||||
else {
|
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']);
|
else $this->sambaLMPassword($post['sambaLMPassword']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$profile) {
|
if ($post['sambaSID']== _('Administrator')) {
|
||||||
if ($post['sambaSID']== _('Administrator')) {
|
$this->attributes['sambaSID'][0] = $SID."-500";
|
||||||
$this->attributes['sambaSID'][0] = $SID."-500";
|
// Do a check if an administrator already exists
|
||||||
// Do a check if an administrator already exists
|
if ($_SESSION['cache']->in_cache($SID."-500", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
|
||||||
if ($_SESSION['cache']->in_cache($SID."-500", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
|
$triggered_messages['sambaSID'][] = $this->messages['rid'][0];
|
||||||
$errors['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];
|
|
||||||
}
|
|
||||||
else if ($post['sambaSID']== _('Ordinary user')) {
|
|
||||||
$this->attributes['sambaSID'][0] = $SID."-". (($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2)+$RIDbase);
|
|
||||||
}
|
}
|
||||||
// Check values
|
else if ($post['sambaSID']== _('Guest')) {
|
||||||
$this->attributes['sambaHomePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaHomePath'][0]);
|
$this->attributes['sambaSID'][0] = $SID."-501";
|
||||||
$this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaHomePath'][0]);
|
// Do a check if an guest already exists
|
||||||
if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $errors['sambaHomePath'][] = $this->messages['homePath'][1];
|
if ($_SESSION['cache']->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
|
||||||
$this->attributes['sambaLogonScript'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]);
|
$triggered_messages['sambaSID'][] = $this->messages['rid'][1];
|
||||||
$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];
|
|
||||||
$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['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC')))
|
|
||||||
$errors['sambaHomePath'][] = $this->messages['homePath'][0];
|
|
||||||
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
|
|
||||||
$errors['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];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$sambaHomePath = str_replace('$user', 'user', $this->attributes['sambaHomePath'][0]);
|
|
||||||
$sambaHomePath = str_replace('$group', 'group', $sambaHomePath);
|
|
||||||
$sambaLogonScript = str_replace('$user', 'user', $this->attributes['sambaLogonScript'][0]);
|
|
||||||
$sambaLogonScript = str_replace('$group', 'group', $sambaLogonScript);
|
|
||||||
$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];
|
|
||||||
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
|
|
||||||
$errors[] = $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];
|
|
||||||
}
|
}
|
||||||
|
else if ($post['sambaSID']== _('Ordinary user')) {
|
||||||
|
$this->attributes['sambaSID'][0] = $SID."-". (($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2)+$RIDbase);
|
||||||
}
|
}
|
||||||
if (is_array($errors)) return $errors;
|
// 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'])) $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'])) $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'])) $triggered_messages['sambaProfilePath'][] = $this->messages['profilePath'][1];
|
||||||
|
if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC')))
|
||||||
|
$triggered_messages['sambaHomePath'][] = $this->messages['homePath'][0];
|
||||||
|
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
|
||||||
|
$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')))
|
||||||
|
$triggered_messages['sambaProfilePath'][] = $this->messages['profilePath'][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sambaHomePath = str_replace('$user', 'user', $this->attributes['sambaHomePath'][0]);
|
||||||
|
$sambaHomePath = str_replace('$group', 'group', $sambaHomePath);
|
||||||
|
$sambaLogonScript = str_replace('$user', 'user', $this->attributes['sambaLogonScript'][0]);
|
||||||
|
$sambaLogonScript = str_replace('$group', 'group', $sambaLogonScript);
|
||||||
|
$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')))
|
||||||
|
$triggered_messages[] = $this->messages['homePath'][0];
|
||||||
|
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
|
||||||
|
$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')))
|
||||||
|
$triggered_messages[] = $this->messages['profilePath'][0];
|
||||||
|
}
|
||||||
|
if (count($triggered_messages)!=0) {
|
||||||
|
$this->triggered_messages = $triggered_messages;
|
||||||
|
return $triggered_messages;
|
||||||
|
}
|
||||||
|
else $this->triggered_messages = array();
|
||||||
if ($post['sambaUserWorkstations']) return 'sambaUserWorkstations';
|
if ($post['sambaUserWorkstations']) return 'sambaUserWorkstations';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write variables into object and do some regexp checks
|
/* Write variables into object and do some regexp checks
|
||||||
*/
|
*/
|
||||||
function proccess_sambaUserWorkstations($post, $profile=false) {
|
function proccess_sambaUserWorkstations($post) {
|
||||||
// Load attributes
|
// Load attributes
|
||||||
if ($_SESSION[$this->base]->type=='user') {
|
if ($_SESSION[$this->base]->type=='user') {
|
||||||
do { // X-Or, only one if() can be true
|
do { // X-Or, only one if() can be true
|
||||||
|
@ -439,7 +430,7 @@ class sambaSamAccount extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* It will output a complete html-table
|
||||||
*/
|
*/
|
||||||
function display_html_attributes($post, $profile=false) {
|
function display_html_attributes($post) {
|
||||||
// Get Domain SID from name
|
// Get Domain SID from name
|
||||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||||
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
||||||
|
@ -458,15 +449,13 @@ class sambaSamAccount extends baseModule {
|
||||||
4 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']),
|
4 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']),
|
||||||
5 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
|
5 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
|
||||||
6 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsU', 'type' => 'hidden', 'value' => 'true'));
|
6 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsU', 'type' => 'hidden', 'value' => 'true'));
|
||||||
if (!$profile) {
|
if ($post['sambaLMPassword2']!='') $password2 = $post['sambaLMPassword2'];
|
||||||
if ($post['sambaLMPassword2']!='') $password2 = $post['sambaLMPassword2'];
|
else $password2 = $this->sambaLMPassword();
|
||||||
else $password2 = $this->sambaLMPassword();
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
|
1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->sambaLMPassword()));
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->sambaLMPassword()));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
|
1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
|
2 => array ('kind' => 'help', 'value' => 'sambaLMPassword'));
|
||||||
2 => array ('kind' => 'help', 'value' => 'sambaLMPassword'));
|
|
||||||
}
|
|
||||||
if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) {
|
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') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use unix password') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd),
|
1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd),
|
||||||
|
@ -523,52 +512,48 @@ class sambaSamAccount extends baseModule {
|
||||||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations', 'value' => _('Edit workstations')),
|
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations', 'value' => _('Edit workstations')),
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'sambaUserWorkstations' ));
|
2 => array ( 'kind' => 'help', 'value' => 'sambaUserWorkstations' ));
|
||||||
|
|
||||||
if (!$profile) {
|
$names = array_keys($this->rids);
|
||||||
$names = array_keys($this->rids);
|
$wrid=false;
|
||||||
$wrid=false;
|
for ($i=0; $i<count($names); $i++) {
|
||||||
for ($i=0; $i<count($names); $i++) {
|
if ($this->attributes['sambaPrimaryGroupSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
||||||
if ($this->attributes['sambaPrimaryGroupSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
$selected[] = $names[$i];
|
||||||
$selected[] = $names[$i];
|
|
||||||
$wrid=true;
|
|
||||||
}
|
|
||||||
else $options[] = $names[$i];
|
|
||||||
}
|
|
||||||
if ($wrid) $options[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
|
||||||
else $selected[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
|
|
||||||
1 => array ( 'kind' => 'select', 'name' => 'sambaPrimaryGroupSID', 'options' => $options, 'options_selected' => $selected),
|
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'sambaPrimaryGroupSID' ));
|
|
||||||
// Display if group SID should be mapped to a well kown SID
|
|
||||||
$wrid=false;
|
|
||||||
$options = array();
|
|
||||||
$selected = array();
|
|
||||||
if ($this->attributes['sambaSID'][0]==$SID."-500") {
|
|
||||||
$selected[] = _('Administrator');
|
|
||||||
$wrid=true;
|
$wrid=true;
|
||||||
}
|
}
|
||||||
else $options[] = _('Administrator');
|
else $options[] = $names[$i];
|
||||||
if ($this->attributes['sambaSID'][0]==$SIM."-501") {
|
|
||||||
$selected[] = _('Guest');
|
|
||||||
$wrid=true;
|
|
||||||
}
|
|
||||||
else $options[] = _('Guest');
|
|
||||||
if ($wrid) $options[] = _('Ordinary user');
|
|
||||||
else $selected[] = _('Ordinary user');
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ),
|
|
||||||
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
|
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
|
|
||||||
}
|
}
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
if ($wrid) $options[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
||||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array($this->attributes['sambaDomainName'][0])),
|
else $selected[] = $_SESSION['cache']->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]);
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
|
||||||
|
1 => array ( 'kind' => 'select', 'name' => 'sambaPrimaryGroupSID', 'options' => $options, 'options_selected' => $selected),
|
||||||
|
2 => array ( 'kind' => 'help', 'value' => 'sambaPrimaryGroupSID' ));
|
||||||
|
// Display if group SID should be mapped to a well kown SID
|
||||||
|
$wrid=false;
|
||||||
|
$options = array();
|
||||||
|
$selected = array();
|
||||||
|
if ($this->attributes['sambaSID'][0]==$SID."-500") {
|
||||||
|
$selected[] = _('Administrator');
|
||||||
|
$wrid=true;
|
||||||
|
}
|
||||||
|
else $options[] = _('Administrator');
|
||||||
|
if ($this->attributes['sambaSID'][0]==$SIM."-501") {
|
||||||
|
$selected[] = _('Guest');
|
||||||
|
$wrid=true;
|
||||||
|
}
|
||||||
|
else $options[] = _('Guest');
|
||||||
|
if ($wrid) $options[] = _('Ordinary user');
|
||||||
|
else $selected[] = _('Ordinary user');
|
||||||
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ),
|
||||||
|
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
|
||||||
|
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
|
||||||
}
|
}
|
||||||
|
$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') {
|
if ($_SESSION[$this->base]->type=='host') {
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
|
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
|
||||||
if (!$profile) {
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
|
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
|
||||||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
|
2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
|
|
||||||
}
|
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $this->attributes['sambaDomainName'][0]),
|
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $this->attributes['sambaDomainName'][0]),
|
||||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||||
|
@ -584,7 +569,7 @@ class sambaSamAccount extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* 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') {
|
if ($_SESSION[$this->base]->type=='user') {
|
||||||
// Get list of all hosts.
|
// Get list of all hosts.
|
||||||
$result = $_SESSION['cache']->get_cache('uid', 'sambaSamAccount', 'host');
|
$result = $_SESSION['cache']->get_cache('uid', 'sambaSamAccount', 'host');
|
||||||
|
|
|
@ -164,14 +164,6 @@ class shadowAccount extends baseModule {
|
||||||
return array('attributes');
|
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
|
/* This function loads all attributes into the object
|
||||||
* $attr is an array as it's retured from ldap_get_attributes
|
* $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
|
/* Write variables into object and do some regexp checks
|
||||||
*/
|
*/
|
||||||
function proccess_attributes($post, $profile=false) {
|
function proccess_attributes($post) {
|
||||||
// Load attributes
|
// Load attributes
|
||||||
$this->attributes['shadowMin'][0] = $post['shadowMin'];
|
$this->attributes['shadowMin'][0] = $post['shadowMin'];
|
||||||
$this->attributes['shadowMax'][0] = $post['shadowMax'];
|
$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'],
|
$this->attributes['shadowExpire'][0] = intval(mktime(10, 0, 0, $post['shadowExpire_mon'],
|
||||||
$post['shadowExpire_day'], $post['shadowExpire_yea'])/3600/24);
|
$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['shadowMin'][0], 'digit')) $triggered_messages['shadowMin'][] = $this->messages['shadowMin'][0];
|
||||||
if ( !get_preg($this->attributes['shadowMax'][0], 'digit')) $errors['shadowMax'][] = $this->messages['shadowMax'][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]) $errors['shadowMin'][] = $this->messages['shadow_cmp'][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')) $errors['shadowInactive'][] = $this->messages['inactive'][0];
|
if ( !get_preg($this->attributes['shadowInactive'][0], 'digit2')) $triggered_messages['shadowInactive'][] = $this->messages['inactive'][0];
|
||||||
if ( !get_preg($this->attributes['shadowWarning'][0], 'digit')) $errors['shadowWarning'][] = $this->messages['shadowWarning'][0];
|
if ( !get_preg($this->attributes['shadowWarning'][0], 'digit')) $triggered_messages['shadowWarning'][] = $this->messages['shadowWarning'][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();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +231,7 @@ class shadowAccount extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* 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
|
// Use dd-mm-yyyy format of date because it's easier to read for humans
|
||||||
$date = getdate ($this->attributes['shadowExpire'][0]*3600*24);
|
$date = getdate ($this->attributes['shadowExpire'][0]*3600*24);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue