fixed password handling in sambaAccount module

changed error code handling
This commit is contained in:
katagia 2004-10-16 19:51:36 +00:00
parent b96fa3e32f
commit d8b02d37aa
11 changed files with 757 additions and 837 deletions

View File

@ -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-&gt;triggered_messages when it wants to
display
status messages. This can be done with $this-&gt;triggered_messages =
array();<br>
<br>
<br> <br>
<br> <br>
<h3>2.2.15. proccess_*<br> <h3>2.2.15. proccess_*<br>

View File

@ -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;

View File

@ -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;
} }

View File

@ -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,7 +357,6 @@ 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] ),
@ -376,12 +365,10 @@ class inetOrgPerson extends baseModule {
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] ),
@ -410,11 +397,10 @@ class inetOrgPerson extends baseModule {
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;
} }

View File

@ -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,22 +542,20 @@ 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 (!$profile) {
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0]) if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
$errors['uid'][] = $this->messages['uid'][0]; $triggered_messages['uid'][] = $this->messages['uid'][0];
if ($this->orig['gidNumber'][0]!='' && $_SESSION['cache']->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0]) if ($this->orig['gidNumber'][0]!='' && $_SESSION['cache']->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0])
$errors['gidNumber'][] = $this->dynamic_Message('gidNumber',0); $triggered_messages['gidNumber'][] = $this->dynamic_Message('gidNumber',0);
if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0]) if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0])
$errors['uidNumber'][] = $this->dynamic_Message('uidNumber',0); $triggered_messages['uidNumber'][] = $this->dynamic_Message('uidNumber',0);
if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0]) if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0])
$errors['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0); $triggered_messages['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0);
// Load attributes // Load attributes
$this->attributes['uid'][0] = $post['uid']; $this->attributes['uid'][0] = $post['uid'];
$this->attributes['cn'][0] = $this->attributes['uid'][0]; $this->attributes['cn'][0] = $this->attributes['uid'][0];
@ -607,10 +595,10 @@ class posixAccount extends baseModule {
$i = intval($minID); $i = intval($minID);
while (in_array($i, $uids)) $i++; while (in_array($i, $uids)) $i++;
if ($i>$maxID) if ($i>$maxID)
$errors['uidNumber'][] = $this->messages['uidNumber'][1]; $triggered_messages['uidNumber'][] = $this->messages['uidNumber'][1];
else { else {
$this->attributes['uidNumber'][0] = $i; $this->attributes['uidNumber'][0] = $i;
$errors['uidNumber'][] = $this->messages['uidNumber'][2]; $triggered_messages['uidNumber'][] = $this->messages['uidNumber'][2];
} }
} }
else $this->attributes['uidNumber'][0] = $minID; else $this->attributes['uidNumber'][0] = $minID;
@ -622,28 +610,27 @@ class posixAccount extends baseModule {
else { else {
// Check manual ID // Check manual ID
// id-number is out of valid range // id-number is out of valid range
if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $errors['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID)); if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $triggered_messages['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
// $uids is allways an array but not if no entries were found // $uids is allways an array but not if no entries were found
if (is_array($uids)) { if (is_array($uids)) {
// id-number is in use and account is a new account // id-number is in use and account is a new account
if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use')); if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $triggered_messages['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
// id-number is in use, account is existing account and id-number is not used by itself // 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]) ) { if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) {
$errors['uidNumber'][] = $this->messages['uidNumber'][3]; $triggered_messages['uidNumber'][] = $this->messages['uidNumber'][3];
$this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0]; $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
} }
} }
} }
if ($_SESSION[$this->base]->type=='user') { if ($_SESSION[$this->base]->type=='user') {
if (($this->attributes['uid'][0] != $post['uid']) && !get_preg($post['uid'], '!upper')) if (($this->attributes['uid'][0] != $post['uid']) && !get_preg($post['uid'], '!upper'))
$errors['uid'][] = $this->messages['uid'][1]; $triggered_messages['uid'][] = $this->messages['uid'][1];
if ( !get_preg($this->attributes['homeDirectory'][0], 'homeDirectory' )) if ( !get_preg($this->attributes['homeDirectory'][0], 'homeDirectory' ))
$errors['homeDirecotry'][] = $this->messages['homeDirectory'][0]; $triggered_messages['homeDirecotry'][] = $this->messages['homeDirectory'][0];
} }
if (($post['userPassword_lock'] && $post['userPassword_invalid']) || ($post['userPassword_nopassword'] && $post['userPassword_invalid'])) { 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 { else {
if ($post['userPassword_nopassword']) { if ($post['userPassword_nopassword']) {
@ -668,29 +655,28 @@ class posixAccount extends baseModule {
if ($post['genpass']) $this->userPassword(genpasswd()); if ($post['genpass']) $this->userPassword(genpasswd());
else { else {
if ($post['userPassword'] != $post['userPassword2']) if ($post['userPassword'] != $post['userPassword2'])
$errors['userPassword'][] = $this->messages['userPassword'][0]; $triggered_messages['userPassword'][] = $this->messages['userPassword'][0];
else $this->userPassword($post['userPassword']); else $this->userPassword($post['userPassword']);
if (!get_preg($this->userPassword(), 'password')) if (!get_preg($this->userPassword(), 'password'))
$errors['userPassword'][] = $this->messages['userPassword'][1]; $triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
} }
if ($post['userPassword_lock']) $this->userPassword_lock=true; if ($post['userPassword_lock']) $this->userPassword_lock=true;
else $this->userPassword_lock=false; else $this->userPassword_lock=false;
} }
} }
if ($_SESSION[$this->base]->type=='user') { if ($_SESSION[$this->base]->type=='user') {
$this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]); $this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]);
if ($this->attributes['uid'][0] != '') if ($this->attributes['uid'][0] != '')
$this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]); $this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]);
if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $errors['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.')); if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $triggered_messages['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.'));
// Check if Username contains only valid characters // Check if Username contains only valid characters
if ( !get_preg($this->attributes['uid'][0], 'username') && !$profile) if ( !get_preg($this->attributes['uid'][0], 'username') && !$profile)
$errors['uid'][] = $this->messages['uid'][2]; $triggered_messages['uid'][] = $this->messages['uid'][2];
} }
if ($_SESSION[$this->base]->type=='host') { if ($_SESSION[$this->base]->type=='host') {
// Check if Hostname contains only valid characters // Check if Hostname contains only valid characters
if ( !get_preg($this->attributes['uid'][0], 'hostname')) if ( !get_preg($this->attributes['uid'][0], 'hostname'))
$errors['uid'][] = $this->messages['uid'][4]; $triggered_messages['uid'][] = $this->messages['uid'][4];
} }
// Create automatic useraccount with number if original user already exists // Create automatic useraccount with number if original user already exists
// Reset name to original name if new name is in use // Reset name to original name if new name is in use
@ -734,20 +720,19 @@ class posixAccount extends baseModule {
// Show warning if lam has changed username // Show warning if lam has changed username
if ($this->attributes['uid'][0] != $post['uid']) { if ($this->attributes['uid'][0] != $post['uid']) {
if ($_SESSION[$this->base]->type=='user') if ($_SESSION[$this->base]->type=='user')
$errors['uid'][] = $this->messages['uid'][5]; $triggered_messages['uid'][] = $this->messages['uid'][5];
if ($_SESSION[$this->base]->type=='host') if ($_SESSION[$this->base]->type=='host')
$errors['uid'][] = $this->messages['uid'][6]; $triggered_messages['uid'][] = $this->messages['uid'][6];
} }
if (!get_preg($this->userPassword(), 'password')) if (!get_preg($this->userPassword(), 'password'))
$errors['userPassword'][] = $this->messages['userPassword'][1]; $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;
@ -755,7 +740,7 @@ class posixAccount extends baseModule {
/* 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
@ -778,18 +763,16 @@ class posixAccount 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) {
$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,15 +782,12 @@ 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),
@ -821,7 +801,6 @@ class posixAccount extends baseModule {
$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;
} }
} }

View File

@ -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,18 +122,15 @@ 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'));
@ -145,7 +142,6 @@ class posixGroup extends baseModule {
$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'));
@ -155,11 +151,10 @@ class posixGroup extends baseModule {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Lock password') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Lock password') ),
1 => array ( 'kind' => 'input', 'name' => 'userPassword_lock', 'type' => 'checkbox', 'checked' => $this->userPassword_lock), 1 => array ( 'kind' => 'input', 'name' => 'userPassword_lock', 'type' => 'checkbox', 'checked' => $this->userPassword_lock),
2 => array ('kind' => 'help', 'value' => 'userPassword_lock')); 2 => array ('kind' => 'help', 'value' => 'userPassword_lock'));
if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='' && !$profile) { if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='')
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Change GID number of users and hosts') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Change GID number of users and hosts') ),
1 => array ( 'kind' => 'input', 'name' => 'changegids', 'type' => 'checkbox', 'checked' => $this->changegids, 'value' => true), 1 => array ( 'kind' => 'input', 'name' => 'changegids', 'type' => 'checkbox', 'checked' => $this->changegids, 'value' => true),
2 => array ('kind' => 'help', 'value' => 'changegids')); 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,13 +441,12 @@ 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
$errors['userPassword'][] = $this->messages['userPassword'][3]; $triggered_messages['userPassword'][] = $this->messages['userPassword'][3];
} }
else { else {
if ($post['userPassword_nopassword']) { if ($post['userPassword_nopassword']) {
@ -488,10 +471,10 @@ class posixGroup extends baseModule {
if ($post['genpass']) $this->userPassword(genpasswd()); if ($post['genpass']) $this->userPassword(genpasswd());
else { else {
if ($post['userPassword'] != $post['userPassword2']) if ($post['userPassword'] != $post['userPassword2'])
$errors['userPassword'][] = $this->messages['userPassword'][0]; $triggered_messages['userPassword'][] = $this->messages['userPassword'][0];
else $this->userPassword($post['userPassword']); else $this->userPassword($post['userPassword']);
if (!get_preg($this->userPassword(), 'password')) if (!get_preg($this->userPassword(), 'password'))
$errors['userPassword'][] = $this->messages['userPassword'][1]; $triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
} }
if ($post['userPassword_lock']) $this->userPassword_lock=true; if ($post['userPassword_lock']) $this->userPassword_lock=true;
else $this->userPassword_lock=false; else $this->userPassword_lock=false;
@ -499,7 +482,7 @@ class posixGroup extends baseModule {
} }
if ($post['changegids']) $this->changegids=true; if ($post['changegids']) $this->changegids=true;
else $this->changegids=false; else $this->changegids=false;
if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->errors['gidNumber'][0]='ERROR')) { if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->triggered_messages['gidNumber'][0]='ERROR')) {
// Check if GID is valid. If none value was entered, the next useable value will be inserted // Check if GID is valid. If none value was entered, the next useable value will be inserted
// load min and may uidNumber // load min and may uidNumber
$minID = intval($this->moduleSettings['posixGroup_minGID'][0]); $minID = intval($this->moduleSettings['posixGroup_minGID'][0]);
@ -529,10 +512,10 @@ class posixGroup extends baseModule {
$i = intval($minID); $i = intval($minID);
while (in_array($i, $gids)) $i++; while (in_array($i, $gids)) $i++;
if ($i>$maxID) if ($i>$maxID)
$errors['gidNumber'][] = $this->messages['gidNumber'][3]; $triggered_messages['gidNumber'][] = $this->messages['gidNumber'][3];
else { else {
$this->attributes['gidNumber'][0] = $i; $this->attributes['gidNumber'][0] = $i;
$errors['gidNumber'][] = $this->messages['gidNumber'][2]; $triggered_messages['gidNumber'][] = $this->messages['gidNumber'][2];
} }
} }
else $this->attributes['gidNumber'][0] = $minID; else $this->attributes['gidNumber'][0] = $minID;
@ -544,26 +527,26 @@ class posixGroup extends baseModule {
else { else {
// Check manual ID // Check manual ID
// id-number is out of valid range // id-number is out of valid range
if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $errors['gidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID)); if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $triggered_messages['gidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
// $uids is allways an array but not if no entries were found // $uids is allways an array but not if no entries were found
if (is_array($gids)) { if (is_array($gids)) {
// id-number is in use and account is a new account // id-number is in use and account is a new account
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use')); if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $triggered_messages['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
// id-number is in use, account is existing account and id-number is not used by itself // 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]) ) { if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) {
$errors['gidNumber'][] = $this->messages['gidNumber'][4]; $triggered_messages['gidNumber'][] = $this->messages['gidNumber'][4];
$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0]; $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
} }
} }
} }
} }
if ($this->attributes['cn'][0]!=$post['cn'] || ($this->errors['cn'][0]='ERROR')) { if ($this->attributes['cn'][0]!=$post['cn'] || ($this->triggered_messages['cn'][0]='ERROR')) {
$this->attributes['cn'][0] = $post['cn']; $this->attributes['cn'][0] = $post['cn'];
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn'])) if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
$errors['cn'][] = $this->messages['cn'][0]; $triggered_messages['cn'][] = $this->messages['cn'][0];
// Check if Groupname contains only valid characters // Check if Groupname contains only valid characters
if ( !get_preg($this->attributes['cn'][0],'groupname')) if ( !get_preg($this->attributes['cn'][0],'groupname'))
$errors['cn'][] = $this->messages['cn'][2]; $triggered_messages['cn'][] = $this->messages['cn'][2];
// Create automatic useraccount with number if original user already exists // Create automatic useraccount with number if original user already exists
// Reset name to original name if new name is in use // Reset name to original name if new name is in use
// Set username back to original name if new username is in use // Set username back to original name if new username is in use
@ -603,20 +586,19 @@ class posixGroup extends baseModule {
} }
// Show warning if lam has changed username // Show warning if lam has changed username
if ($this->attributes['cn'][0] != $post['cn']) { if ($this->attributes['cn'][0] != $post['cn']) {
$errors['cn'][] = $this->messages['cn'][0]; $triggered_messages['cn'][] = $this->messages['cn'][0];
} }
// show info when gidnumber has changed // 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]) if (($this->orig['gidNumber'][0]!=$this->attributes['gidNumber'][0]) && $this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0])
$errors['gidNumber'][] = $this->messages['gidNumber'][0]; $triggered_messages['gidNumber'][] = $this->messages['gidNumber'][0];
}
} }
} }
// Return error-messages // 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 '';
} }
} }
} }
?> ?>

View File

@ -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') ),

View File

@ -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,7 +341,6 @@ 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++) {
@ -349,42 +350,45 @@ class sambaAccount extends baseModule {
} }
} }
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001; if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
if ($post['useunixpwd']) $this->useunixpwd = true;
else $this->useunixpwd = false;
if (isset($post['lmPassword'])) { if (isset($post['lmPassword'])) {
if ($post['lmPassword'] != $post['lmPassword2']) { if ($post['lmPassword'] != $post['lmPassword2']) {
$errors['lmPassword'][] = $this->messages['lmPassword'][0]; $triggered_messages['lmPassword'][] = $this->messages['lmPassword'][0];
unset ($post['lmPassword2']); unset ($post['lmPassword2']);
} }
else {
if ( !get_preg($this->lmPassword(), 'password')) $triggered_messages['lmPassword'][] = $this->messages['lmPassword'][1];
else $this->lmPassword($post['lmPassword']); else $this->lmPassword($post['lmPassword']);
} }
}
if ($post['rid']== _('Administrator')) { if ($post['rid']== _('Administrator')) {
$this->attributes['rid'][0] = "500"; $this->attributes['rid'][0] = "500";
// Do a check if an administrator already exists // Do a check if an administrator already exists
if ($_SESSION['cache']->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig) if ($_SESSION['cache']->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
$errors['rid'][] = $this->messages['rid'][0]; $triggered_messages['rid'][] = $this->messages['rid'][0];
} }
if ($post['rid']== _('Guest')) { if ($post['rid']== _('Guest')) {
$this->attributes['rid'][0] = "501"; $this->attributes['rid'][0] = "501";
// Do a check if an administrator already exists // Do a check if an administrator already exists
if ($_SESSION['cache']->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig) if ($_SESSION['cache']->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
$errors['rid'][] = $this->messages['rid'][1]; $triggered_messages['rid'][] = $this->messages['rid'][1];
} }
$this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]); $this->attributes['smbHome'][0] = str_replace('$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]); $this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]);
if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $errors['smbHome'][] = $this->messages['homePath'][1]; if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $triggered_messages['smbHome'][] = $this->messages['homePath'][1];
$this->attributes['scriptPath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['scriptPath'][0]); $this->attributes['scriptPath'][0] = str_replace('$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]); $this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['scriptPath'][0]);
if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $errors['scriptPath'][] = $this->messages['logonScript'][1]; if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $triggered_messages['scriptPath'][] = $this->messages['logonScript'][1];
$this->attributes['profilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['profilePath'][0]); $this->attributes['profilePath'][0] = str_replace('$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]); $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 ($this->attributes['profiletPath'][0] != stripslashes($post['profilePath'])) $triggered_messages['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'))) if ( (!$this->attributes['smbHome'][0]=='') && (!get_preg($this->attributes['smbHome'][0], 'UNC')))
$errors['smbHome'][] = $this->messages['homedir'][0]; $triggered_messages['smbHome'][] = $this->messages['homedir'][0];
if ( (!$this->attributes['scriptPath'][0]=='') && (!get_preg($this->attributes['scriptPath'][0], 'logonscript'))) if ( (!$this->attributes['scriptPath'][0]=='') && (!get_preg($this->attributes['scriptPath'][0], 'logonscript')))
$errors['scriptPath'][] = $this->messages['logonScript'][0]; $triggered_messages['scriptPath'][] = $this->messages['logonScript'][0];
if ( (!$this->attributes['profilePath'][0]=='') && (!get_preg($this->attributes['profilePath'][0], 'UNC'))) if ( (!$this->attributes['profilePath'][0]=='') && (!get_preg($this->attributes['profilePath'][0], 'UNC')))
$errors['profilePath'][] = $this->messages['profilePath'][0]; $triggered_messages['profilePath'][] = $this->messages['profilePath'][0];
} }
else { else {
$smbHome = str_replace('$user', 'user', $this->attributes['smbHome'][0]); $smbHome = str_replace('$user', 'user', $this->attributes['smbHome'][0]);
@ -394,29 +398,29 @@ class sambaAccount extends baseModule {
$profilePath = str_replace('$user', 'user', $this->attributes['profilePath'][0]); $profilePath = str_replace('$user', 'user', $this->attributes['profilePath'][0]);
$profilePath = str_replace('$group', 'group', $profilePath); $profilePath = str_replace('$group', 'group', $profilePath);
if ( (!$smbHome=='') && (!get_preg($smbHome, 'UNC'))) if ( (!$smbHome=='') && (!get_preg($smbHome, 'UNC')))
$errors['smbHome'][] = $this->messages['homePath'][0]; $triggered_messages['smbHome'][] = $this->messages['homePath'][0];
if ( (!$scriptPath=='') && (!get_preg($scriptPath, 'logonscript'))) if ( (!$scriptPath=='') && (!get_preg($scriptPath, 'logonscript')))
$errors['scriptPath'][] = $this->messages['logonScript'][0]; $triggered_messages['scriptPath'][] = $this->messages['logonScript'][0];
if ( (!$profilePath=='') && (!get_preg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $profilePath)) if ( (!$profilePath=='') && (!get_preg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $profilePath))
&& (!get_preg($profilePath, 'UNC'))) && (!get_preg($profilePath, 'UNC')))
$errors['profilePath'][] = $this->messages['profilePath'][0]; $triggered_messages['profilePath'][] = $this->messages['profilePath'][0];
}
if ($post['useunixpwd']) $this->useunixpwd = true;
else $this->useunixpwd = false;
} }
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 ($this->attributes['lmPassword'][0] != $this->orig['lmPassword'][0]) $password=$this->lmPassword();
else if ($this->attributes['lmPassword'][0] != '') $password=$post['lmPassword'];
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password));
if ($post['lmPassword2']!='') $password2 = $post['lmPassword2']; if ($post['lmPassword2']!='') $password2 = $post['lmPassword2'];
else $password2 = $this->lmPassword();
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $this->lmPassword()));
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
1 => array ( 'kind' => 'input', 'name' => 'lmPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2), 1 => array ( 'kind' => 'input', 'name' => 'lmPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
2 => array ('kind' => 'help', 'value' => 'lmPassword')); 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,7 +546,6 @@ 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++) {
@ -582,11 +581,8 @@ class sambaAccount extends baseModule {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('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]), 1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),
2 => array ( 'kind' => 'help', 'value' => 'domain' )); 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' ));
@ -594,8 +590,6 @@ class sambaAccount extends baseModule {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('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]), 1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),
2 => array ( 'kind' => 'help', 'value' => 'domain' )); 2 => array ( 'kind' => 'help', 'value' => 'domain' ));
}
return $return; return $return;
} }

View File

@ -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,7 +160,6 @@ 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++) {
@ -175,7 +174,6 @@ class sambaGroupMapping extends baseModule {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected), 1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' )); 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,12 +369,11 @@ 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++ )
@ -384,10 +381,8 @@ class sambaGroupMapping extends baseModule {
$SID = $sambaDomains[$i]->SID; $SID = $sambaDomains[$i]->SID;
$RIDbase = $sambaDomain[$i]->RIDbase; $RIDbase = $sambaDomain[$i]->RIDbase;
} }
// Load attributes // Load attributes
$this->attributes['displayName'][0] = $post['displayName']; $this->attributes['displayName'][0] = $post['displayName'];
$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++) {
@ -397,14 +392,17 @@ class sambaGroupMapping extends baseModule {
$this->attributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]]; $this->attributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]];
// Do a check if special grou pis unique // Do a check if special grou pis unique
if ($_SESSION['cache']->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group')) if ($_SESSION['cache']->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group'))
$errors[] = $this->messages['sambaSID'][0]; $triggered_messages[] = $this->messages['sambaSID'][0];
} }
} }
if (!$wrid) $this->attributes['sambaSID'][0] = $SID . "-" . ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+$RIDbase+1); 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;
} }

View File

@ -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,28 +310,27 @@ 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)
$errors['sambaSID'][] = $this->messages['rid'][0]; $triggered_messages['sambaSID'][] = $this->messages['rid'][0];
} }
else if ($post['sambaSID']== _('Guest')) { else if ($post['sambaSID']== _('Guest')) {
$this->attributes['sambaSID'][0] = $SID."-501"; $this->attributes['sambaSID'][0] = $SID."-501";
// Do a check if an guest already exists // Do a check if an guest already exists
if ($_SESSION['cache']->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig) if ($_SESSION['cache']->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
$errors['sambaSID'][] = $this->messages['rid'][1]; $triggered_messages['sambaSID'][] = $this->messages['rid'][1];
} }
else if ($post['sambaSID']== _('Ordinary user')) { else if ($post['sambaSID']== _('Ordinary user')) {
$this->attributes['sambaSID'][0] = $SID."-". (($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2)+$RIDbase); $this->attributes['sambaSID'][0] = $SID."-". (($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2)+$RIDbase);
@ -350,20 +338,20 @@ class sambaSamAccount extends baseModule {
// Check values // 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('$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]); $this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaHomePath'][0]);
if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $errors['sambaHomePath'][] = $this->messages['homePath'][1]; if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $triggered_messages['sambaHomePath'][] = $this->messages['homePath'][1];
$this->attributes['sambaLogonScript'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]); $this->attributes['sambaLogonScript'][0] = str_replace('$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]); $this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaLogonScript'][0]);
if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $errors['sambaLogonScript'][] = $this->messages['logonScript'][1]; if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $triggered_messages['sambaLogonScript'][] = $this->messages['logonScript'][1];
$this->attributes['sambaProfilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaProfilePath'][0]); $this->attributes['sambaProfilePath'][0] = str_replace('$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]); $this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaProfilePath'][0]);
if ($this->attributes['sambaProfilePath'][0] != stripslashes($post['sambaProfilePath'])) $errors['sambaProfilePath'][] = $this->messages['profilePath'][1]; if ($this->attributes['sambaProfilePath'][0] != stripslashes($post['sambaProfilePath'])) $triggered_messages['sambaProfilePath'][] = $this->messages['profilePath'][1];
if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC'))) if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC')))
$errors['sambaHomePath'][] = $this->messages['homePath'][0]; $triggered_messages['sambaHomePath'][] = $this->messages['homePath'][0];
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript'))) if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
$errors['sambaScriptPath'][] = $this->messages['logonScript'][0]; $triggered_messages['sambaScriptPath'][] = $this->messages['logonScript'][0];
if (!($this->attributes['sambaProfilePath'][0] == '') && if (!($this->attributes['sambaProfilePath'][0] == '') &&
!(get_preg($this->attributes['sambaProfilePath'][0], 'UNC') xor get_preg($this->attributes['sambaProfilePath'][0], 'homeDirectory'))) !(get_preg($this->attributes['sambaProfilePath'][0], 'UNC') xor get_preg($this->attributes['sambaProfilePath'][0], 'homeDirectory')))
$errors['sambaProfilePath'][] = $this->messages['profilePath'][0]; $triggered_messages['sambaProfilePath'][] = $this->messages['profilePath'][0];
} }
else { else {
$sambaHomePath = str_replace('$user', 'user', $this->attributes['sambaHomePath'][0]); $sambaHomePath = str_replace('$user', 'user', $this->attributes['sambaHomePath'][0]);
@ -373,22 +361,25 @@ class sambaSamAccount extends baseModule {
$sambaProfilePath = str_replace('$user', 'user', $this->attributes['sambaProfilePath'][0]); $sambaProfilePath = str_replace('$user', 'user', $this->attributes['sambaProfilePath'][0]);
$sambaProfilePath = str_replace('$group', 'group', $sambaProfilePath); $sambaProfilePath = str_replace('$group', 'group', $sambaProfilePath);
if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC'))) if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC')))
$errors[] = $this->messages['homePath'][0]; $triggered_messages[] = $this->messages['homePath'][0];
if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript'))) if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!get_preg($this->attributes['sambaLogonScript'][0], 'logonscript')))
$errors[] = $this->messages['logonScript'][0]; $triggered_messages[] = $this->messages['logonScript'][0];
if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!get_preg($this->attributes['sambaProfilePath'][0], 'UNC')) if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!get_preg($this->attributes['sambaProfilePath'][0], 'UNC'))
&& (!get_preg($this->attributes['sambaProfilePath'][0], 'UNC'))) && (!get_preg($this->attributes['sambaProfilePath'][0], 'UNC')))
$errors[] = $this->messages['profilePath'][0]; $triggered_messages[] = $this->messages['profilePath'][0];
} }
if (count($triggered_messages)!=0) {
$this->triggered_messages = $triggered_messages;
return $triggered_messages;
} }
if (is_array($errors)) return $errors; else $this->triggered_messages = array();
if ($post['sambaUserWorkstations']) return 'sambaUserWorkstations'; 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,7 +449,6 @@ 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') ),
@ -466,7 +456,6 @@ class sambaSamAccount extends baseModule {
$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,7 +512,6 @@ 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++) {
@ -561,14 +549,11 @@ class sambaSamAccount extends baseModule {
$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' => array($this->attributes['sambaDomainName'][0])), 1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array($this->attributes['sambaDomainName'][0])),
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' )); 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');

View File

@ -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);