added rfc2307bisPosixGroup

This commit is contained in:
Roland Gruber 2008-12-18 12:21:07 +00:00
parent a5a71f27b1
commit 49a0222918
1 changed files with 64 additions and 25 deletions

View File

@ -91,6 +91,42 @@ class sambaGroupMapping extends baseModule {
} }
} }
/**
* Gets the GID number from the Unix group module.
*
* @return String GID number
*/
private function getGID() {
$modules = array('posixGroup', 'rfc2307bisPosixGroup');
for ($i = 0; $i < sizeof($modules); $i++) {
if ($this->getAccountContainer()->getAccountModule($modules[$i]) != null) {
$attrs = $this->getAccountContainer()->getAccountModule($modules[$i])->getAttributes();
if (isset($attrs['gidNumber'][0])) {
return $attrs['gidNumber'][0];
}
}
}
return null;
}
/**
* Gets the cn from the Unix group module.
*
* @return String cn attribute
*/
private function getCn() {
$modules = array('posixGroup', 'groupOfNames', 'groupOfUniqueNames');
for ($i = 0; $i < sizeof($modules); $i++) {
if ($this->getAccountContainer()->getAccountModule($modules[$i]) != null) {
$attrs = $this->getAccountContainer()->getAccountModule($modules[$i])->getAttributes();
if (isset($attrs['cn'][0])) {
return $attrs['cn'][0];
}
}
}
return null;
}
/** /**
* In this function the LDAP account is built up. * In this function the LDAP account is built up.
* *
@ -194,9 +230,10 @@ class sambaGroupMapping extends baseModule {
} }
$displayName = ''; $displayName = '';
if (isset($this->attributes['displayName'][0])) $displayName = $this->attributes['displayName'][0]; if (isset($this->attributes['displayName'][0])) $displayName = $this->attributes['displayName'][0];
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Display name') ), $return[] = array (
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $displayName), array('kind' => 'text', 'text' => _('Display name') ),
2 => array ( 'kind' => 'help', 'value' => 'displayName' )); array('kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $displayName),
array('kind' => 'help', 'value' => 'displayName' ));
$names = array_keys($this->rids); $names = array_keys($this->rids);
$wrid=false; $wrid=false;
@ -207,16 +244,16 @@ class sambaGroupMapping extends baseModule {
} }
else $options[] = $names[$i]; else $options[] = $names[$i];
} }
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
if ($wrid) { if ($wrid) {
$options[] = $attrs['cn'][0]; $options[] = $this->getCn();
} }
else { else {
$selected[] = $attrs['cn'][0]; $selected[] = $this->getCn();
} }
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), $return[] = array(
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected), array('kind' => 'text', 'text' => _('Windows group') ),
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' )); array('kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
array('kind' => 'help', 'value' => 'sambaSID' ));
$names = array_keys($this->sambaGroupTypes); $names = array_keys($this->sambaGroupTypes);
$selected = array( _('Domain group') ); $selected = array( _('Domain group') );
@ -224,14 +261,16 @@ class sambaGroupMapping extends baseModule {
if (!isset($this->attributes['sambaGroupType'][0])) break; if (!isset($this->attributes['sambaGroupType'][0])) break;
if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]]) $selected = array( $names[$i] ); if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]]) $selected = array( $names[$i] );
} }
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Group type') ), $return[] = array(
1 => array ( 'kind' => 'select', 'name' => 'sambaGroupType', 'options' => $names , 'options_selected' => $selected ), array('kind' => 'text', 'text' => _('Group type') ),
2 => array ( 'kind' => 'help', 'value' => 'type' )); array('kind' => 'select', 'name' => 'sambaGroupType', 'options' => $names , 'options_selected' => $selected ),
array('kind' => 'help', 'value' => 'type' ));
$selectedDomain = array(); $selectedDomain = array();
if (isset($sel_domain)) $selectedDomain = array($sel_domain); if (isset($sel_domain)) $selectedDomain = array($sel_domain);
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), $return[] = array(
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $selectedDomain), array('kind' => 'text', 'text' => _('Domain') ),
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' )); array('kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $selectedDomain),
array('kind' => 'help', 'value' => 'sambaDomainName' ));
} }
else { else {
$return[] = array( $return[] = array(
@ -240,7 +279,7 @@ class sambaGroupMapping extends baseModule {
); );
} }
return $return; return $return;
} }
/** /**
* Returns meta data that is interpreted by parent class * Returns meta data that is interpreted by parent class
@ -258,7 +297,7 @@ class sambaGroupMapping extends baseModule {
// alias name // alias name
$return["alias"] = _('Samba 3'); $return["alias"] = _('Samba 3');
// module dependencies // module dependencies
$return['dependencies'] = array('depends' => array('posixGroup'), 'conflicts' => array()); $return['dependencies'] = array('depends' => array(array('posixGroup', 'rfc2307bisPosixGroup')), 'conflicts' => array());
// managed object classes // managed object classes
$return['objectClasses'] = array('sambaGroupMapping'); $return['objectClasses'] = array('sambaGroupMapping');
// managed attributes // managed attributes
@ -306,7 +345,7 @@ class sambaGroupMapping extends baseModule {
'example' => '2' 'example' => '2'
) )
); );
$return['upload_preDepends'] = array('posixGroup'); $return['upload_preDepends'] = array('posixGroup', 'rfc2307bisPosixGroup');
} }
// help Entries // help Entries
$return['help'] = array( $return['help'] = array(
@ -366,9 +405,9 @@ class sambaGroupMapping extends baseModule {
} }
// domain // domain
$return[] = array ( $return[] = array (
0 => array('kind' => 'text', 'text' => _('Domain')), array('kind' => 'text', 'text' => _('Domain')),
1 => array('kind' => 'select', 'name' => 'sambaGroupMapping_sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ()), array('kind' => 'select', 'name' => 'sambaGroupMapping_sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ()),
2 => array('kind' => 'help', 'value' => 'sambaDomainName' )); array('kind' => 'help', 'value' => 'sambaDomainName' ));
return $return; return $return;
} }
@ -407,8 +446,9 @@ class sambaGroupMapping extends baseModule {
* @return boolean true, if page can be displayed * @return boolean true, if page can be displayed
*/ */
function module_ready() { function module_ready() {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes(); if (($this->getGID() == null) || ($this->getGID() == '')) {
if ($attrs['gidNumber'][0]=='') return false; return false;
}
return true; return true;
} }
@ -460,8 +500,7 @@ class sambaGroupMapping extends baseModule {
} }
} }
if (!$wrid) { if (!$wrid) {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes(); $this->attributes['sambaSID'][0] = $SID . "-" . ($this->getGID()*2+$RIDbase+1);
$this->attributes['sambaSID'][0] = $SID . "-" . ($attrs['gidNumber'][0]*2+$RIDbase+1);
} }
// Return error-messages // Return error-messages
return $errors; return $errors;