added option if attribute "cn" should be managed (needed for rfc2307bisPosixGroup)

This commit is contained in:
Roland Gruber 2008-12-17 18:44:37 +00:00
parent 3375667c04
commit 4e6fbcc839
1 changed files with 42 additions and 27 deletions

View File

@ -41,6 +41,9 @@ class posixGroup extends baseModule {
/** change GIDs of users and hosts? */ /** change GIDs of users and hosts? */
private $changegids; private $changegids;
/** specifies if the cn attribute should be managed by this module */
protected $manageCnAttribute = true;
/** /**
@ -56,14 +59,16 @@ class posixGroup extends baseModule {
$needAutoGID = array(); $needAutoGID = 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 if ($this->manageCnAttribute) {
if (get_preg($rawAccounts[$i][$ids['posixGroup_cn']], 'groupname')) { // group name
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixGroup_cn']]; if (get_preg($rawAccounts[$i][$ids['posixGroup_cn']], 'groupname')) {
} $partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixGroup_cn']];
else { }
$errMsg = $this->messages['cn'][3]; else {
array_push($errMsg, array($i)); $errMsg = $this->messages['cn'][3];
$error_messages[] = $errMsg; array_push($errMsg, array($i));
$error_messages[] = $errMsg;
}
} }
// GID // GID
if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") { if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") {
@ -153,10 +158,12 @@ class posixGroup extends baseModule {
* @see baseModule::get_metaData() * @see baseModule::get_metaData()
*/ */
function display_html_attributes() { function display_html_attributes() {
$return[] = array( if ($this->manageCnAttribute) {
array('kind' => 'text', 'text' => _("Group name").'*'), $return[] = array(
array('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '30', 'maxlength' => '30', 'value' => $this->attributes['cn'][0]), array('kind' => 'text', 'text' => _("Group name").'*'),
array('kind' => 'help', 'value' => 'cn')); array('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '30', 'maxlength' => '30', 'value' => $this->attributes['cn'][0]),
array('kind' => 'help', 'value' => 'cn'));
}
$return[] = array( $return[] = array(
array('kind' => 'text', 'text' => _('GID number').'*'), array('kind' => 'text', 'text' => _('GID number').'*'),
array('kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $this->attributes['gidNumber'][0]), array('kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $this->attributes['gidNumber'][0]),
@ -337,21 +344,15 @@ class posixGroup extends baseModule {
'error_message' => $this->messages['gidNumber'][7]); 'error_message' => $this->messages['gidNumber'][7]);
// available PDF fields // available PDF fields
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'cn',
'gidNumber', 'gidNumber',
'memberUid', 'memberUid',
'description' 'description'
); );
if ($this->manageCnAttribute) {
array_unshift($return['PDF_fields'], 'cn');
}
// upload fields // upload fields
$return['upload_columns'] = array( $return['upload_columns'] = array(
array(
'name' => 'posixGroup_cn',
'description' => _('Group name'),
'help' => 'cn',
'example' => _('adminstrators'),
'required' => true,
'unique' => true
),
array( array(
'name' => 'posixGroup_gid', 'name' => 'posixGroup_gid',
'description' => _('GID number'), 'description' => _('GID number'),
@ -377,12 +378,20 @@ class posixGroup extends baseModule {
'example' => _('secret') 'example' => _('secret')
) )
); );
if ($this->manageCnAttribute) {
array_unshift($return['upload_columns'],
array(
'name' => 'posixGroup_cn',
'description' => _('Group name'),
'help' => 'cn',
'example' => _('adminstrators'),
'required' => true,
'unique' => true
)
);
}
// help Entries // help Entries
$return['help'] = array( $return['help'] = array(
'cn' => array(
"Headline" => _("Group name"),
"Text" => _("Group name of the group which should be created. Valid characters are: a-z, A-Z, 0-9 and .-_ . LAM does not allow a number as first character because groupadd also does not allow it. If group name is already used group name will be expanded with a number. The next free number will be used.")
),
'gidNumber' => array( 'gidNumber' => array(
"Headline" => _("GID number"), "Headline" => _("GID number"),
"Text" => _("If empty GID number will be generated automaticly depending on your configuration settings.") "Text" => _("If empty GID number will be generated automaticly depending on your configuration settings.")
@ -412,6 +421,12 @@ class posixGroup extends baseModule {
"Text" => _("LAM supports CRYPT, SHA, SSHA, MD5 and SMD5 to generate the hash value of passwords. SSHA and CRYPT are the most common but CRYPT does not support passwords greater than 8 letters. We do not recommend to use plain text passwords.") "Text" => _("LAM supports CRYPT, SHA, SSHA, MD5 and SMD5 to generate the hash value of passwords. SSHA and CRYPT are the most common but CRYPT does not support passwords greater than 8 letters. We do not recommend to use plain text passwords.")
) )
); );
if ($this->manageCnAttribute) {
$return['help']['cn'] = array(
"Headline" => _("Group name"),
"Text" => _("Group name of the group which should be created. Valid characters are: a-z, A-Z, 0-9 and .-_ . LAM does not allow a number as first character because groupadd also does not allow it. If group name is already used group name will be expanded with a number. The next free number will be used.")
);
}
return $return; return $return;
} }
@ -498,7 +513,7 @@ class posixGroup extends baseModule {
return true; return true;
} }
} }
if ($this->attributes['cn'][0] == '') return false; if ($this->manageCnAttribute && ($this->attributes['cn'][0] == '')) return false;
if ($this->attributes['gidNumber'][0] == '') return false; if ($this->attributes['gidNumber'][0] == '') return false;
return true; return true;
} }
@ -592,7 +607,7 @@ class posixGroup extends baseModule {
} }
} }
} }
if ($this->attributes['cn'][0]!=$_POST['cn']) { if ($this->manageCnAttribute && ($this->attributes['cn'][0]!=$_POST['cn'])) {
$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[] = $this->messages['cn'][0]; $errors[] = $this->messages['cn'][0];