Add LSattr LDAP & HTML sambaAcctFlags type

This commit is contained in:
Benjamin Renard 2020-09-09 18:45:34 +02:00
parent 7e74853021
commit 15941ac678
13 changed files with 474 additions and 3 deletions

View file

@ -15,6 +15,7 @@
&conf-LSattr_html_postaladdress;
&conf-LSattr_html_pre;
&conf-LSattr_html_rss;
&conf-LSattr_html_sambaAcctFlags;
&conf-LSattr_html_select_box;
&conf-LSattr_html_select_list;
&conf-LSattr_html_select_object;

View file

@ -11,6 +11,7 @@
<!ENTITY conf-LSattr_html_postaladdress SYSTEM "LSattr_html_postaladdress.docbook">
<!ENTITY conf-LSattr_html_pre SYSTEM "LSattr_html_pre.docbook">
<!ENTITY conf-LSattr_html_rss SYSTEM "LSattr_html_rss.docbook">
<!ENTITY conf-LSattr_html_sambaAcctFlags SYSTEM "LSattr_html_sambaAcctFlags.docbook">
<!ENTITY conf-LSattr_html_select_box SYSTEM "LSattr_html_select_box.docbook">
<!ENTITY conf-LSattr_html_select_list SYSTEM "LSattr_html_select_list.docbook">
<!ENTITY conf-LSattr_html_select_object SYSTEM "LSattr_html_select_object.docbook">
@ -24,5 +25,6 @@
<!ENTITY conf-LSattr_html_xmpp SYSTEM "LSattr_html_xmpp.docbook">
<!ENTITY LSattr_html_jsonCompositeAttribute "<link linkend='config-LSattr_html_jsonCompositeAttribute'>LSattr_html_jsonCompositeAttribute</link>">
<!ENTITY LSattr_html_sambaAcctFlags "<link linkend='config-LSattr_html_sambaAcctFlags'>LSattr_html_sambaAcctFlags</link>">
<!ENTITY LSattr_html_select_list "<link linkend='config-LSattr_html_select_list'>LSattr_html_select_list</link>">
<!ENTITY LSattr_html_textarea "<link linkend='config-LSattr_html_textarea'>LSattr_html_textarea</link>">

View file

@ -0,0 +1,13 @@
<sect4 id="config-LSattr_html_sambaAcctFlags">
<title>LSattr_html_sambaAcctFlags</title>
<para>Ce type est prévu pour gérer l'attribut <emphasis>sambaAcctFlags</emphasis> du
schéma Samba, qui au travers d'une seule et unique valeur, respectant un format prévu,
liste l'ensemble des drapeaux actifs d'un compte Samba. Il est conçu pour être utilisé
conjointement avec le type d'attribut LDAP &LSattr_ldap_sambaAcctFlags;.</para>
<note><simpara>Ce type d'attribut est implémenté en dérivant le type
<emphasis>LSattr_html_select_box</emphasis> dont les valeurs possibles sont
pré-configurées (paramètre <literal>possible_values</literal>). Même si cela n'est pas
forcément utiles, les autres paramètres du type parent restent utilisables.</simpara>
</note>
</sect4>

View file

@ -12,4 +12,5 @@
&conf-LSattr_ldap_numeric;
&conf-LSattr_ldap_password;
&conf-LSattr_ldap_postaladdress;
&conf-LSattr_ldap_sambaAcctFlags;
</sect3>

View file

@ -8,5 +8,7 @@
<!ENTITY conf-LSattr_ldap_numeric SYSTEM "LSattr_ldap_numeric.docbook">
<!ENTITY conf-LSattr_ldap_password SYSTEM "LSattr_ldap_password.docbook">
<!ENTITY conf-LSattr_ldap_postaladdress SYSTEM "LSattr_ldap_postaladdress.docbook">
<!ENTITY conf-LSattr_ldap_sambaAcctFlags SYSTEM "LSattr_ldap_sambaAcctFlags.docbook">
<!ENTITY LSattr_ldap_date "<link linkend='config-LSattr_ldap_date'>LSattr_ldap_date</link>">
<!ENTITY LSattr_ldap_sambaAcctFlags "<link linkend='config-LSattr_ldap_sambaAcctFlags'>LSattr_ldap_sambaAcctFlags</link>">

View file

@ -0,0 +1,9 @@
<sect4 id="config-LSattr_ldap_sambaAcctFlags">
<title>LSattr_ldap_sambaAcctFlags</title>
<para>Ce type est prévu pour gérer l'attribut <emphasis>sambaAcctFlags</emphasis> du
schéma Samba, qui au travers d'une seule et unique valeur, respectant un format prévu,
liste l'ensemble des drapeaux actifs d'un compte Samba. Il transforme l'unique valeur
de l'attribut LDAP en une liste de drapeaux actuellement activés sur le compte. Il est
conçu pour être utilisé conjointement avec le type d'attribut HTML
&LSattr_html_sambaAcctFlags;.</para>
</sect4>

View file

@ -144,6 +144,7 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
'label' => 'Samba',
'args' => array (
'sambaSID',
'sambaAcctFlags',
'sambaLogonTime',
'sambaLogoffTime',
'sambaKickoffTime',
@ -701,6 +702,24 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
),
/* ----------- end -----------*/
/* ----------- start -----------*/
'sambaAcctFlags' => array (
'label' => 'Samba account flags',
'ldap_type' => 'sambaAcctFlags',
'html_type' => 'sambaAcctFlags',
'required' => 1,
'default_value' => array('U'),
'rights' => array(
'admin' => 'w'
),
'view' => 1,
'form' => array (
'create' => 1,
'modify' => 1
)
),
/* ----------- end -----------*/
/* ----------- start -----------*/
'sambaLogonTime' => array (
'label' => 'Samba last logon time',

View file

@ -0,0 +1,57 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSattr_html_select_box');
/**
* HTML attribute type for sambaAcctFlags
*/
class LSattr_html_sambaAcctFlags extends LSattr_html_select_box {
var $LSformElement_type = 'sambaAcctFlags';
/**
* Retourne un tableau des valeurs possibles de la liste
*
* @param[in] $options Attribute options (optional)
* @param[in] $name Attribute name (optional)
* @param[in] &$ldapObject Related LSldapObject (optional)
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retval array Tableau associatif des valeurs possible de la liste avec en clé
* la valeur des balises option et en valeur ce qui sera affiché.
*/
public static function _getPossibleValues($options=false, $name=false, &$ldapObject=false) {
$retInfos = array();
if (!LSsession :: loadLSclass('LSattr_ldap_sambaAcctFlags', null, true))
return $retInfos;
foreach(LSattr_ldap_sambaAcctFlags :: get_available_flags() as $group_label => $flags) {
$retInfos[] = array(
'label' => $group_label,
'possible_values' => $flags,
);
}
return $retInfos;
}
}

View file

@ -0,0 +1,170 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* LDAP attribute type for sambaAcctFlags
**/
class LSattr_ldap_sambaAcctFlags extends LSattr_ldap {
/**
* Return display value of attribute after treatment related to LDAP type
*
* @param[in] $data mixed Attribute data
*
* @retval mixed Attribute display value
**/
public function getDisplayValue($data) {
$values = self :: parse_flags($data);
if (is_array($values))
return $values;
return array();
}
/**
* Return attribute value after treatment related to LDAP type
*
* @param[in] $data mixed Attribute data
*
* @retval mixed Attribute data
**/
public function getUpdateData($data) {
$values = self :: format_flags($data);
if (is_array($values))
return $values;
return array();
}
/**
* Parse flags
*
* @param[in] $data Attribute data
*
* @retval array Array of enabled flags
**/
public static function parse_flags($data) {
if (!is_array($data)) {
$data = array($data);
}
if (count($data) > 1) {
LSerror :: addErrorCode('LSattr_ldap_sambaAcctFlags_01');
return;
}
$value = $data[0];
$preg_pattern = "/^\[([ ";
foreach(self :: get_available_flags() as $group_label => $flags)
foreach($flags as $flag => $label)
$preg_pattern .= $flag;
$preg_pattern .= "]{0,16})\]$/";
self :: log_trace("parse($value): PREG composed pattern = '$preg_pattern'");
if (!preg_match($preg_pattern, $value, $m)) {
self :: log_error("parse($value): fail to parse value.");
LSerror :: addErrorCode('LSattr_ldap_sambaAcctFlags_02');
return;
}
$flags = array();
foreach(str_split($m[1]) as $flag) {
if ($flag == ' ')
continue;
if (in_array($flag, $flags))
continue;
$flags[] = $flag;
}
return $flags;
}
/**
* Format flags as one LDAP attribute value
*
* @param[in] $flags array of string Flags
*
* @retval array Array of LDAP attribute value
**/
public static function format_flags($flags) {
if (!is_array($flags))
$flags = array($flags);
foreach($flags as $flag) {
if (!self :: check_flag($flag)) {
LSerror :: addErrorCode('LSattr_ldap_sambaAcctFlags_03', $flag);
return;
}
}
// Add some space if need
for ($i=count($flags); $i <= 11; $i++)
$flags[] = ' ';
return array(
"[".implode("", $flags)."]"
);
}
/**
* Check if a flag is valid
*
* @param[in] $flag string The flag
*
* @retval boolean True if flag is valid, False otherwise
**/
public static function check_flag($flag) {
foreach(self :: get_available_flags() as $group_label => $flags)
if (array_key_exists($flag, $flags))
return true;
return false;
}
/**
* Get list of available flags grouped by type
*
* @return array List of available flags grouped by type
*/
public static function get_available_flags() {
return array(
___('Account types') => array(
'U' => ___('Regular user account'),
'W' => ___('Workstation Trust Account'),
'S' => ___('Server Trust Account'),
'I' => ___('Domain Trust Account'),
'M' => ___('Majority Node Set (MNS) logon account'),
),
___('Account settings') => array(
'H' => ___('Home directory required'),
'N' => ___('Account without password'),
'X' => ___('Password does not expire'),
'D' => ___('Account disabled'),
'T' => ___('Temporary duplicate of other account'),
'L' => ___('Account automatically locked'),
),
);
}
}
/**
* Error Codes
**/
LSerror :: defineError('LSattr_ldap_sambaAcctFlags_01',
___("LSattr_ldap_sambaAcctFlags: invalid attribute values count. This attribute type could only handle single value attribute.")
);
LSerror :: defineError('LSattr_ldap_sambaAcctFlags_02',
___("LSattr_ldap_sambaAcctFlags: invalid attribute value. Fail to parse current flags set.")
);
LSerror :: defineError('LSattr_ldap_sambaAcctFlags_03',
___("LSattr_ldap_sambaAcctFlags: invalid flag '%{flag}'. Can't format the LDAP attribute value.")
);

View file

@ -0,0 +1,47 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSformElement_select_box');
/**
* Select box form element for LdapSaisie
*
* This class define select box form element.
* It's an extention of LSformElement_select class.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_sambaAcctFlags extends LSformElement_select_box {
/**
* Return display data of this element
*
* This method return display data of this element
*
* @retval array
*/
public function isMultiple(){
return true;
}
}

View file

@ -477,6 +477,82 @@ msgstr "Attribut"
msgid "Incorrect value"
msgstr "Valeur incorrecte"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:134
msgid "Account types"
msgstr "Types de comptes"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:135
msgid "Regular user account"
msgstr "Compte utilisateur standard"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:136
msgid "Workstation Trust Account"
msgstr "Compte de poste de travail approuvé"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:137
msgid "Server Trust Account"
msgstr "Compte de serveur approuvé"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:138
msgid "Domain Trust Account"
msgstr "Compte de domaine approuvé"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:139
msgid "Majority Node Set (MNS) logon account"
msgstr "Compte de connexion Majority Node Set (MNS)"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:141
msgid "Account settings"
msgstr "Paramètres de compte"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:142
msgid "Home directory required"
msgstr "Dossier personnel requis"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:143
msgid "Account without password"
msgstr "Compte sans mot de passe"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:144
msgid "Password does not expire"
msgstr "Le mot de passe n'expire jamais"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:145
msgid "Account disabled"
msgstr "Compte désactivé"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:146
msgid "Temporary duplicate of other account"
msgstr "Copie temporaire d'un autre compte"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:147
msgid "Account automatically locked"
msgstr "Compte automatiquement bloqué"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:158
msgid ""
"LSattr_ldap_sambaAcctFlags: invalid attribute values count. This attribute "
"type could only handle single value attribute."
msgstr ""
"LSattr_ldap_sambaAcctFlags : nombre de valeurs de l'attribut incorrect. Ce "
"type d'attribut ne peut gérer que des attributs mono-valués."
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:161
msgid ""
"LSattr_ldap_sambaAcctFlags: invalid attribute value. Fail to parse current "
"flags set."
msgstr ""
"LSattr_ldap_sambaAcctFlags : valeur de l'attribut incorrect. Impossible de "
"détecter les drapeaux actuellement définis."
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:164
msgid ""
"LSattr_ldap_sambaAcctFlags: invalid flag '%{flag}'. Can't format the LDAP "
"attribute value."
msgstr ""
"LSattr_ldap_sambaAcctFlags : drapeau '%{flag}' invalide. Impossible de "
"formater la valeur de l'attribut LDAP."
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_ssh_key.php:57
msgid "Display the full key."
msgstr "Affichier la clé en entier."

View file

@ -238,6 +238,10 @@ $GLOBALS['LSlang'] = array (
"Samba Password (NT)" =>
"Mot de passe Samba (NT)",
# LSobjects.LSpeople.attrs.sambaAcctFlags.label
"Samba account flags" =>
"Drapeaux de compte Samba",
# LSobjects.LSpeople.attrs.sambaKickoffTime.label
"Samba expiration time" =>
"Date d'expiration Samba",

View file

@ -396,6 +396,76 @@ msgstr ""
msgid "Incorrect value"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:134
msgid "Account types"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:135
msgid "Regular user account"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:136
msgid "Workstation Trust Account"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:137
msgid "Server Trust Account"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:138
msgid "Domain Trust Account"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:139
msgid "Majority Node Set (MNS) logon account"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:141
msgid "Account settings"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:142
msgid "Home directory required"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:143
msgid "Account without password"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:144
msgid "Password does not expire"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:145
msgid "Account disabled"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:146
msgid "Temporary duplicate of other account"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:147
msgid "Account automatically locked"
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:158
msgid ""
"LSattr_ldap_sambaAcctFlags: invalid attribute values count. This attribute "
"type could only handle single value attribute."
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:161
msgid ""
"LSattr_ldap_sambaAcctFlags: invalid attribute value. Fail to parse current "
"flags set."
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSattr_ldap_sambaAcctFlags.php:164
msgid ""
"LSattr_ldap_sambaAcctFlags: invalid flag '%{flag}'. Can't format the LDAP "
"attribute value."
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_ssh_key.php:57
msgid "Display the full key."
msgstr ""