LSaddon/supann : Added functions generate_eduPersonOrgDN(), generate_eduPersonPrimaryOrgUnitDN() and generate_eduPersonOrgUnitDN()

This commit is contained in:
Benjamin Renard 2010-03-09 19:16:50 +01:00
parent 35f293e871
commit 21a6761371
2 changed files with 88 additions and 1 deletions

View file

@ -32,4 +32,14 @@ define('LS_SUPANN_LASTNAME_ATTR','sn');
// Nom de l'attribut LDAP prenom // Nom de l'attribut LDAP prenom
define('LS_SUPANN_FIRSTNAME_ATTR','givenName'); define('LS_SUPANN_FIRSTNAME_ATTR','givenName');
// Type de LSobject correspondant aux entites SUPANN
define('LS_SUPANN_LSOBJECT_ENTITE_TYPE','LSsupannEntite');
// DN de l'entite SUPANN correspondant à l'etablissement
define('LS_SUPANN_ETABLISSEMENT_DN','supannCodeEntite=XXX,ou=structures,dc=univ,dc=fr');
// Type de LSobject correspondant aux entites SUPANN
// Exemple : 0753742K
define('LS_SUPANN_ETABLISSEMENT_UAI','0753742K');
?> ?>

View file

@ -26,11 +26,18 @@
LSerror :: defineError('SUPANN_SUPPORT_01', LSerror :: defineError('SUPANN_SUPPORT_01',
_("SUPANN Support : The constant %{const} is not defined.") _("SUPANN Support : The constant %{const} is not defined.")
); );
LSerror :: defineError('SUPANN_SUPPORT_02',
_("SUPANN Support : The LSobject type %{type} does not exist. Can't work with entities..")
);
// Autres erreurs // Autres erreurs
LSerror :: defineError('SUPANN_01', LSerror :: defineError('SUPANN_01',
_("SUPANN Support : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.") _("SUPANN Support : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.")
); );
LSerror :: defineError('SUPANN_02',
_("SUPANN Support : Can't get the basedn of entities. Unable to forge the attribute %{attr}.")
);
/** /**
* Verification du support SUPANN par ldapSaisie * Verification du support SUPANN par ldapSaisie
@ -44,7 +51,10 @@ LSerror :: defineError('SUPANN_01',
$MUST_DEFINE_CONST= array( $MUST_DEFINE_CONST= array(
'LS_SUPANN_LASTNAME_ATTR', 'LS_SUPANN_LASTNAME_ATTR',
'LS_SUPANN_FIRSTNAME_ATTR' 'LS_SUPANN_FIRSTNAME_ATTR',
'LS_SUPANN_LSOBJECT_ENTITE_TYPE',
'LS_SUPANN_ETABLISSEMENT_UAI',
'LS_SUPANN_ETABLISSEMENT_DN'
); );
foreach($MUST_DEFINE_CONST as $const) { foreach($MUST_DEFINE_CONST as $const) {
@ -53,6 +63,12 @@ LSerror :: defineError('SUPANN_01',
$retval=false; $retval=false;
} }
} }
if ( defined('LS_SUPANN_LSOBJECT_ENTITE_TYPE') ) {
if ( ! LSsession :: loadLSobject( LS_SUPANN_LSOBJECT_ENTITE_TYPE ) ) {
LSerror :: addErrorCode('SUPANN_SUPPORT_02', LS_SUPANN_LSOBJECT_ENTITE_TYPE);
}
}
return $retval; return $retval;
} }
@ -171,4 +187,65 @@ LSerror :: defineError('SUPANN_01',
); );
return strtr($string, $replaceAccent); return strtr($string, $replaceAccent);
} }
function generate_eduPersonOrgUnitDN($ldapObject) {
if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectation' ]) != 'LSattribute' ) {
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEntiteAffectation', 'attr' => 'eduPersonOrgUnitDN'));
return;
}
$affectations = $ldapObject -> attrs[ 'supannEntiteAffectation' ] -> getUpdateData();
$basedn=LSconfig :: get('LSobjects.'.LS_SUPANN_LSOBJECT_ENTITE_TYPE.'.container_dn').','.LSsession::getTopDn();
if ($basedn=="") {
LSerror :: addErrorCode('SUPANN_02','eduPersonOrgUnitDN');
return;
}
$retval=array();
foreach ($affectations as $aff) {
$retval[]="supannCodeEntite=".$aff.",$basedn";
}
return $retval;
}
function generate_eduPersonPrimaryOrgUnitDN($ldapObject) {
if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ]) != 'LSattribute' ) {
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEntiteAffectationPrincipale', 'attr' => 'eduPersonPrimaryOrgUnitDN'));
return;
}
$affectations = $ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ] -> getUpdateData();
$basedn=LSconfig :: get('LSobjects.'.LS_SUPANN_LSOBJECT_ENTITE_TYPE.'.container_dn').','.LSsession::getTopDn();
if ($basedn=="") {
LSerror :: addErrorCode('SUPANN_02','eduPersonPrimaryOrgUnitDN');
return;
}
$retval=array();
foreach ($affectations as $aff) {
$retval[]="supannCodeEntite=".$aff.",$basedn";
}
return $retval;
}
function generate_eduPersonOrgDN($ldapObject) {
if ( get_class($ldapObject -> attrs[ 'supannEtablissement' ]) != 'LSattribute' ) {
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEtablissement', 'attr' => 'eduPersonOrgDN'));
return;
}
$eta = $ldapObject -> attrs[ 'supannEtablissement' ] -> getUpdateData();
$retval=array();
if ($eta[0] == '{UAI}'.LS_SUPANN_ETABLISSEMENT_UAI) {
$retval[] = LS_SUPANN_ETABLISSEMENT_DN;
}
return $retval;
}
?> ?>