do not automatically add object class

This commit is contained in:
Roland Gruber 2007-08-25 10:08:15 +00:00
parent e1f888546b
commit d46ae32a6d
1 changed files with 212 additions and 187 deletions

View File

@ -475,6 +475,14 @@ class sambaSamAccount extends baseModule {
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
return;
}
// do not automatically add Samba 3 object class
for ($i = 0; $i < sizeof($this->attributes['objectClass']); $i++) {
if ($this->attributes['objectClass'][$i] == 'sambaSamAccount') {
unset($this->attributes['objectClass'][$i]);
$this->attributes['objectClass'] = array_values($this->attributes['objectClass']);
break;
}
}
}
/**
@ -490,17 +498,6 @@ class sambaSamAccount extends baseModule {
return true;
}
/**
* This functions is used to check if all settings for this module have been made.
*
* @return boolean true, if settings are complete
*/
function module_complete() {
if (!$this->module_ready()) return false;
if ($this->attributes['sambaSID'][0] == '') return false;
return true;
}
/* This function loads all attributes into the object
* $attr is an array as it's retured from ldap_get_attributes
*/
@ -514,6 +511,16 @@ class sambaSamAccount extends baseModule {
if (strpos($this->attributes['sambaAcctFlags'][0], "X")) $this->noexpire = true;
else $this->noexpire = false;
}
if (!isset($this->orig['objectClass']) || !in_array('sambaSamAccount', $this->orig['objectClass'])) {
// do not automatically add Samba 3 object class
for ($i = 0; $i < sizeof($this->attributes['objectClass']); $i++) {
if ($this->attributes['objectClass'][$i] == 'sambaSamAccount') {
unset($this->attributes['objectClass'][$i]);
$this->attributes['objectClass'] = array_values($this->attributes['objectClass']);
break;
}
}
}
}
/* This function returns an array with 3 entries:
@ -525,6 +532,9 @@ class sambaSamAccount extends baseModule {
* modify are attributes which have to been modified in ldap entry
*/
function save_attributes() {
if (!in_array('sambaSamAccount', $this->attributes['objectClass'])) {
return array();
}
/* Create sambaSID. Can't create it while loading attributes because
* it's psssible uidNumber has changed
*/
@ -553,6 +563,9 @@ class sambaSamAccount extends baseModule {
* @return array list of info/error messages
*/
function process_attributes() {
if (!in_array('sambaSamAccount', $this->attributes['objectClass'])) {
return array();
}
$errors = array();
$sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) {
@ -831,6 +844,11 @@ class sambaSamAccount extends baseModule {
* It will output a complete html-table
*/
function display_html_attributes() {
if (isset($_POST['form_subpage_sambaSamAccount_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'sambaSamAccount';
}
$return = array();
if (in_array('sambaSamAccount', $this->attributes['objectClass'])) {
// Get Domain SID from user SID
$sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) {
@ -1010,6 +1028,13 @@ class sambaSamAccount extends baseModule {
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword', 'value' => _('Reset')),
2 => array ( 'kind' => 'help', 'value' => 'resetPassword' ));
}
}
else {
$return[] = array(
array('kind' => 'text', 'text' => '&nbsp;'),
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_sambaSamAccount_attributes_addObjectClass', 'value' => _('Add Samba 3 account'))
);
}
return $return;
}