Samba 3 part is now optional

This commit is contained in:
Roland Gruber 2007-11-18 11:16:03 +00:00
parent aedfdf029e
commit 0e44373ffb
2 changed files with 74 additions and 90 deletions

View File

@ -3,8 +3,10 @@
- account lists: added separate configuration page and store settings in cookies - account lists: added separate configuration page and store settings in cookies
- use suffix from account list as default for new accounts (patch 1823583) - use suffix from account list as default for new accounts (patch 1823583)
- Security: passwords in configuration files are now saved as hash values - Security: passwords in configuration files are now saved as hash values
- Unix: allow to set host passwords (RFE 1754069)
- style fixes for Internet Explorer users - style fixes for Internet Explorer users
- Unix: allow to set host passwords (RFE 1754069)
- Samba 3 groups: Samba part is now optional
- Personal: add object classes person and organizationalPerson for new accounts (RFE 1830033)
07.11.2007 2.1.0 07.11.2007 2.1.0

View File

@ -73,6 +73,7 @@ class sambaGroupMapping extends baseModule {
); );
// call parent constructor // call parent constructor
parent::baseModule($scope); parent::baseModule($scope);
$this->autoAddObjectClasses = false;
} }
/** /**
@ -169,64 +170,75 @@ class sambaGroupMapping extends baseModule {
* @return array HTML meta data * @return array HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
$sambaDomains = search_domains(); if (isset($_POST['form_subpage_sambaGroupMapping_attributes_addObjectClass'])) {
if (sizeof($sambaDomains) == 0) { $this->attributes['objectClass'][] = 'sambaGroupMapping';
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
return array();
} }
// Get Domain-SID from group SID $return = array();
if (isset($this->attributes['sambaSID'][0])) { if (in_array('sambaGroupMapping', $this->attributes['objectClass'])) {
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); $sambaDomains = search_domains();
} if (sizeof($sambaDomains) == 0) {
for ($i=0; $i<count($sambaDomains); $i++ ) { StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
// List with all valid domains return array();
$sambaDomainNames[] = $sambaDomains[$i]->name;
if (isset($domainSID) && ($domainSID==$sambaDomains[$i]->SID)) {
$SID = $sambaDomains[$i]->SID;
$sel_domain = $sambaDomains[$i]->name;
} }
} // Get Domain-SID from group SID
$displayName = ''; if (isset($this->attributes['sambaSID'][0])) {
if (isset($this->attributes['displayName'][0])) $displayName = $this->attributes['displayName'][0]; $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Display name') ), }
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $displayName), for ($i=0; $i<count($sambaDomains); $i++ ) {
2 => array ( 'kind' => 'help', 'value' => 'displayName' )); // List with all valid domains
$sambaDomainNames[] = $sambaDomains[$i]->name;
if (isset($domainSID) && ($domainSID==$sambaDomains[$i]->SID)) {
$SID = $sambaDomains[$i]->SID;
$sel_domain = $sambaDomains[$i]->name;
}
}
$displayName = '';
if (isset($this->attributes['displayName'][0])) $displayName = $this->attributes['displayName'][0];
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Display name') ),
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $displayName),
2 => array ( 'kind' => 'help', 'value' => 'displayName' ));
$names = array_keys($this->rids); $names = array_keys($this->rids);
$wrid=false; $wrid=false;
for ($i=0; $i<count($names); $i++) { for ($i=0; $i<count($names); $i++) {
if (isset($this->attributes['sambaSID'][0]) && ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]])) { if (isset($this->attributes['sambaSID'][0]) && ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]])) {
$selected[] = $names[$i]; $selected[] = $names[$i];
$wrid=true; $wrid=true;
}
else $options[] = $names[$i];
} }
else $options[] = $names[$i]; $attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
} if ($wrid) {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes(); $options[] = $attrs['cn'][0];
if ($wrid) { }
$options[] = $attrs['cn'][0]; else {
$selected[] = $attrs['cn'][0];
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
$names = array_keys($this->sambaGroupTypes);
$selected = array( _('Domain group') );
for ($i=0; $i<count($names); $i++) {
if (!isset($this->attributes['sambaGroupType'][0])) break;
if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]]) $selected = array( $names[$i] );
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Group type') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaGroupType', 'options' => $names , 'options_selected' => $selected ),
2 => array ( 'kind' => 'help', 'value' => 'type' ));
$selectedDomain = array();
if (isset($sel_domain)) $selectedDomain = array($sel_domain);
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $selectedDomain),
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
} }
else { else {
$selected[] = $attrs['cn'][0]; $return[] = array(
array('kind' => 'text', 'text' => '&nbsp;'),
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_sambaGroupMapping_attributes_addObjectClass', 'value' => _('Add Samba 3 account'))
);
} }
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
$names = array_keys($this->sambaGroupTypes);
$selected = array( _('Domain group') );
for ($i=0; $i<count($names); $i++) {
if (!isset($this->attributes['sambaGroupType'][0])) break;
if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]]) $selected = array( $names[$i] );
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Group type') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaGroupType', 'options' => $names , 'options_selected' => $selected ),
2 => array ( 'kind' => 'help', 'value' => 'type' ));
$selectedDomain = array();
if (isset($sel_domain)) $selectedDomain = array($sel_domain);
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $selectedDomain),
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
return $return; return $return;
} }
@ -384,19 +396,6 @@ class sambaGroupMapping extends baseModule {
} }
/**
* 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;
if ($this->attributes['sambaGroupType'][0] == '') return false;
return true;
}
/** /**
* This function is used to check if this module page can be displayed. * This function is used to check if this module page can be displayed.
* It returns false if a module depends on data from other modules which was not yet entered. * It returns false if a module depends on data from other modules which was not yet entered.
@ -417,6 +416,9 @@ class sambaGroupMapping extends baseModule {
* @return array list of info/error messages * @return array list of info/error messages
*/ */
function process_attributes() { function process_attributes() {
if (!in_array('sambaGroupMapping', $this->attributes['objectClass'])) {
return array();
}
$errors = array(); $errors = array();
$sambaDomains = search_domains(); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
@ -474,31 +476,11 @@ class sambaGroupMapping extends baseModule {
* <br>"modify" are attributes which have to been modified in LDAP entry * <br>"modify" are attributes which have to been modified in LDAP entry
*/ */
function save_attributes() { function save_attributes() {
// Get Domain SID from name if (!in_array('sambaGroupMapping', $this->attributes['objectClass'])) {
$sambaDomains = search_domains(); return array();
// Get Domain-SID from group SID
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
for ($i=0; $i<count($sambaDomains); $i++ ) {
if ($domainSID==$sambaDomains[$i]->SID) {
$SID = $sambaDomains[$i]->SID;
$RIDbase = $sambaDomains[$i]->RIDbase;
}
}
$names = array_keys($this->rids);
$wrid=false;
for ($i=0; $i<count($names); $i++) {
if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) {
$wrid=true;
}
}
if (!$wrid) {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
$this->attributes['sambaSID'][0] = $SID."-".($attrs['gidNumber'][0]*2+1+$RIDbase);
}
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
return $return;
} }
return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
}
} }