mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 00:09:06 +01:00
- LSaddon::Samba :
- Ajout des functions suivantes : - generate_uidNumber_withSambaDomainObject() - generate_gidNumber_withSambaDomainObject() - Correction d'utilisation de message d'erreur n'existant plus
This commit is contained in:
parent
3362273688
commit
6f22dd091c
4 changed files with 85 additions and 6 deletions
|
@ -29,6 +29,9 @@
|
||||||
// SID du domaine Samba géré
|
// SID du domaine Samba géré
|
||||||
define('LS_SAMBA_DOMAIN_SID','S-1-5-21-2421470416-3566881284-3047381809');
|
define('LS_SAMBA_DOMAIN_SID','S-1-5-21-2421470416-3566881284-3047381809');
|
||||||
|
|
||||||
|
// Le DN de l'objet sambaDomain du domaine
|
||||||
|
define('LS_SAMBA_DOMAIN_OBJECT_DN','sambaDomainName=LS,o=ls');
|
||||||
|
|
||||||
// Nombre de base pour le calcul des sambaSID Utilisateur
|
// Nombre de base pour le calcul des sambaSID Utilisateur
|
||||||
define('LS_SAMBA_SID_BASE_USER',1000);
|
define('LS_SAMBA_SID_BASE_USER',1000);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
||||||
'ldap_type' => 'numeric',
|
'ldap_type' => 'numeric',
|
||||||
'html_type' => 'text',
|
'html_type' => 'text',
|
||||||
'required' => 1,
|
'required' => 1,
|
||||||
'generate_function' => 'generate_gidNumber',
|
'generate_function' => 'generate_gidNumber_withSambaDomainObject',
|
||||||
'validation' => array (
|
'validation' => array (
|
||||||
array (
|
array (
|
||||||
'filter' => 'gidNumber=%{val}',
|
'filter' => 'gidNumber=%{val}',
|
||||||
|
|
|
@ -169,7 +169,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
||||||
'ldap_type' => 'numeric',
|
'ldap_type' => 'numeric',
|
||||||
'html_type' => 'text',
|
'html_type' => 'text',
|
||||||
'required' => 1,
|
'required' => 1,
|
||||||
'generate_function' => 'generate_uidNumber',
|
'generate_function' => 'generate_uidNumber_withSambaDomainObject',
|
||||||
'check_data' => array (
|
'check_data' => array (
|
||||||
'numeric' => array(
|
'numeric' => array(
|
||||||
'msg' => "The numeric identifier must be an integer."
|
'msg' => "The numeric identifier must be an integer."
|
||||||
|
|
|
@ -38,6 +38,15 @@ LSerror :: defineError('SAMBA_SUPPORT_03',
|
||||||
LSerror :: defineError('SAMBA_01',
|
LSerror :: defineError('SAMBA_01',
|
||||||
_("SAMBA Support : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.")
|
_("SAMBA Support : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.")
|
||||||
);
|
);
|
||||||
|
LSerror :: defineError('SAMBA_02',
|
||||||
|
_("SAMBA Support : Can't get the sambaDomain object.")
|
||||||
|
);
|
||||||
|
LSerror :: defineError('SAMBA_03',
|
||||||
|
_("SAMBA Support : Error modifying the sambaDomain object.")
|
||||||
|
);
|
||||||
|
LSerror :: defineError('SAMBA_04',
|
||||||
|
_("SAMBA Support : The %{attr} of the sambaDomain object is incorrect.")
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verification du support Samba par ldapSaisie
|
* Verification du support Samba par ldapSaisie
|
||||||
|
@ -61,6 +70,7 @@ LSerror :: defineError('SAMBA_01',
|
||||||
|
|
||||||
$MUST_DEFINE_CONST= array(
|
$MUST_DEFINE_CONST= array(
|
||||||
'LS_SAMBA_DOMAIN_SID',
|
'LS_SAMBA_DOMAIN_SID',
|
||||||
|
'LS_SAMBA_DOMAIN_OBJECT_DN',
|
||||||
'LS_SAMBA_SID_BASE_USER',
|
'LS_SAMBA_SID_BASE_USER',
|
||||||
'LS_SAMBA_SID_BASE_GROUP',
|
'LS_SAMBA_SID_BASE_GROUP',
|
||||||
'LS_SAMBA_UIDNUMBER_ATTR',
|
'LS_SAMBA_UIDNUMBER_ATTR',
|
||||||
|
@ -150,7 +160,7 @@ LSerror :: defineError('SAMBA_01',
|
||||||
*/
|
*/
|
||||||
function generate_sambaPrimaryGroupSID($ldapObject) {
|
function generate_sambaPrimaryGroupSID($ldapObject) {
|
||||||
if ( get_class($ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ]) != 'LSattribute' ) {
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ]) != 'LSattribute' ) {
|
||||||
LSerror :: addErrorCode('SAMBA_02',array('dependency' => LS_SAMBA_GIDNUMBER_ATTR, 'attr' => 'sambaPrimaryGroupSID'));
|
LSerror :: addErrorCode('SAMBA_01',array('dependency' => LS_SAMBA_GIDNUMBER_ATTR, 'attr' => 'sambaPrimaryGroupSID'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +182,7 @@ LSerror :: defineError('SAMBA_01',
|
||||||
*/
|
*/
|
||||||
function generate_sambaNTPassword($ldapObject) {
|
function generate_sambaNTPassword($ldapObject) {
|
||||||
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
||||||
LSerror :: addErrorCode('SAMBA_03',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaNTPassword'));
|
LSerror :: addErrorCode('SAMBA_01',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaNTPassword'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +207,7 @@ LSerror :: defineError('SAMBA_01',
|
||||||
*/
|
*/
|
||||||
function generate_sambaLMPassword($ldapObject) {
|
function generate_sambaLMPassword($ldapObject) {
|
||||||
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
||||||
LSerror :: addErrorCode('SAMBA_04',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaLMPassword'));
|
LSerror :: addErrorCode('SAMBA_01',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaLMPassword'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,4 +221,70 @@ LSerror :: defineError('SAMBA_01',
|
||||||
return $sambaLMPassword;
|
return $sambaLMPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generation de uidNumber en utilisant l'objet sambaDomain
|
||||||
|
*
|
||||||
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
|
*
|
||||||
|
* @param[in] $ldapObject L'objet ldap
|
||||||
|
*
|
||||||
|
* @retval integer uidNumber ou false si il y a un problème durant la génération
|
||||||
|
*/
|
||||||
|
function generate_uidNumber_withSambaDomainObject($ldapObject) {
|
||||||
|
$sambaDomain = LSldap :: getLdapEntry ( LS_SAMBA_DOMAIN_OBJECT_DN );
|
||||||
|
if ($sambaDomain === false) {
|
||||||
|
LSerror :: addErrorCode('SAMBA_02');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$uidNumber = $sambaDomain->getValue('uidNumber','single');
|
||||||
|
if (Net_LDAP2::isError($uidNumber) || $uidNumber==0) {
|
||||||
|
LSerror :: addErrorCode('SAMBA_04','uidNumber');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sambaDomain->replace(array('uidNumber' => ($uidNumber+1)));
|
||||||
|
$res = $sambaDomain->update();
|
||||||
|
if(!Net_LDAP2::isError($res)) {
|
||||||
|
return $uidNumber;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LSerror :: addErrorCode('SAMBA_03');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generation de gidNumber en utilisant l'objet sambaDomain
|
||||||
|
*
|
||||||
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
|
*
|
||||||
|
* @param[in] $ldapObject L'objet ldap
|
||||||
|
*
|
||||||
|
* @retval integer gidNumber ou false si il y a un problème durant la génération
|
||||||
|
*/
|
||||||
|
function generate_gidNumber_withSambaDomainObject($ldapObject) {
|
||||||
|
$sambaDomain = LSldap :: getLdapEntry ( LS_SAMBA_DOMAIN_OBJECT_DN );
|
||||||
|
if ($sambaDomain === false) {
|
||||||
|
LSerror :: addErrorCode('SAMBA_02');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$gidNumber = $sambaDomain->getValue('gidNumber','single');
|
||||||
|
if (Net_LDAP2::isError($gidNumber) || $gidNumber==0) {
|
||||||
|
LSerror :: addErrorCode('SAMBA_04','gidNumber');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sambaDomain->replace(array('gidNumber' => ($gidNumber+1)));
|
||||||
|
$res = $sambaDomain->update();
|
||||||
|
if(!Net_LDAP2::isError($res)) {
|
||||||
|
return $gidNumber;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LSerror :: addErrorCode('SAMBA_03');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue