Projet Socle ENT
Pages enfant
  • Grouper - Store SmartLdapGroupStore (esup 4)

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

  •     childGroupKeyRegex : une expression régulière qui permet de déterminer si les membres d'un groupe sont eux-même des groupes. L'expression régulière doit matcher si le membre est un groupe.
  •     keyIndexMatchingGroup : cet index est utilisé conjointement avec le childGroupKeyRegex pour extraire la clé du groupe.

  •     memberOfAttributeName : le nom de l'attribut, dans une entrée de personne, qui référence les groupes auxquels la personne appartient.

  •     keyAttributeName : le nom de l'attribut, dans l'entrée de groupe, qui référence la clé du groupe. Si on souhaite utiliser le dn comme clé, cette propriété doit être commentée.
  •     groupNameAttributeName: le nom de l'attribut, dans l'entrée de groupe, qui référence le nom du groupe.
  •     membershipAttributeName : : le nom de l'attribut, dans l'entrée de groupe, qui référence les membres du groupe.

 Le nom du groupe est utilisé pour l'affichage. La clé du groupe est utilisée pour appeller le groupe. La clé est utilisée pour déterminer si une personne fait partie d'un groupe (en comparant avec l'attribut LDAP définit sous la propriété memberOfAttributeName).

Configuration du SmartLdapGroupStore avec un cn dans l'entrée de personne

 

...

La configuration attendue est la suivante :

Bloc de code
    <!--
     | This bean is the ContextSource instance that will be used to connect to LDAP.
     +-->
    <bean id="ldapContext" class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="url" value="ldap://frmp0165ldap.frmluniv.bull.fr:389"/>
        <property name="userDn" value="uid=root,dc=univ,dc=fr"/>
        <property name="password" value="secretXXXX"/>
    </bean>

    <!--
     | Period, in seconds, after which SmartLdap will drop and re-init the groups 
     | tree.  A value of zero or less (negative) disables this feature.
     +-->
    <bean id="groupsTreeRefreshIntervalSeconds" class="java.lang.Long">
        <constructor-arg><value>900</value></constructor-arg>
    </bean>
    
    <!--
     | BaseDn that will be passed to the search (not to the context).
     |
     | WARNING:  If you get an error like this...
     |   ...PartialResultException: [LDAP: error code 10...
     | it probably means your baseDn isn't correct!
     +-->
    <bean id="baseDn" class="java.lang.String">
        <constructor-arg><value>ou=groups,dc=univ,dc=fr</value></constructor-arg>
    </bean>

    <!--
     | ESUP Parameter. 
     | This parameter is used to extract the id path of the groups 
     | from their dn. 
     | The id path is caught from the nth group of the regex where n is the value 
     | of keyIndexMatchingGroup.
     | (http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#group%28int%29)
    -->
    <bean id="childGroupKeyRegex" class="java.lang.String">
        <constructor-arg><value>cn=(.*),ou=groups,dc=univ,dc=fr</value></constructor-arg>
    </bean>
    <bean id="keyIndexMatchingGroup" class="java.lang.Integer">
        <constructor-arg><value>1</value></constructor-arg>
    </bean>

    <!--
     | NOTE:  The remaining examples in this file are configured correctly for 
     | Active Directory servers.
     +-->

    <!--
     | LDAP query string that will be passed to the search.
     +-->
    <bean id="filter" class="java.lang.String">
        <constructor-arg><value>(objectClass=groupOfNames)</value></constructor-arg>
    </bean>

    <!--
     | These beans tell smartLdap whether to gather additional groups that are 
     | members of groups returned by the first baseDn and filter, and where to 
     | look if so.
     |
     |   - resolveMemberGroups=[true|false]
     |   - resolveDn={a different, broader baseDn than the one above}
     |
     | Here's how it works:  smartLdap will first collect all groups under the 
     | baseDn specified above.  If 'resolveMemberGroups' is enabled, it will 
     | also search for additional groups (found within the 'resolveDn' specified 
     | here) that are members of groups in the first collection.
     +-->
    <bean id="resolveMemberGroups" class="java.lang.Boolean">
        <constructor-arg><value>false</value></constructor-arg>
    </bean>
    <bean id="resolveDn" class="java.lang.String">
        <constructor-arg><value>changeme</value></constructor-arg>
    </bean>

    <!--
     | This bean identifies the name of the Person Attribute that
     | lists the SmartLdap groups each person is a member of.
     +-->
    <bean id="memberOfAttributeName" class="java.lang.String">
        <constructor-arg><value>isMemberOf</value></constructor-arg>
    </bean>

    <!--
     | This bean identifies the org.springframework.ldap.core.AttributesMapper
     | implementation used in reading the groups records from LDAP.
     +-->
    <bean id="contextMapper" class="org.jasig.portal.groups.smartldap.SimpleContextMapper">
        <!--
         | Name of the group attribute that tells you its key.
         | If ommited, will use the dn.
         +-->
        <property name="keyAttributeName">
            <value>cn</value>
        </property>
        <!--
         | Name of the group attribute that tells you its name.
         +-->
        <property name="groupNameAttributeName">
            <value>cn</value>
        </property>
        <!--
         | Name of the group attribute that lists its members.
         +-->
        <property name="membershipAttributeName">
            <value>member</value>
        </property>
    </bean>

Le code utilise les attributs suivant comme suit :

  1. Recherche de tous les groupes
  2. Pour chaque groupe
    1. Extraire l'attribut qui servira clé soit le cn (keyAttributeName ou bien le dn du groupe si le keyAttributeName n'existe pas)
    2. Extraire l'attribut qui servira de nom soit le cn (groupNameAttributeName)
    3. Extraire la liste des membres en interrogeant l'attribut member (membershipAttributeName)
    4. Pour chaque membre
      1. Vérifier s'il s'agit d'un groupe ( en vérifiant que l'expression matche childGroupKeyRegex)l'expression cn=(.*),ou=groups,dc=univ,dc=fr (childGroupKeyRegex)
      2. S'il s'agit S'il s'agit bien d'un groupe, extraire la clé en utilisant le groupe dont l'index est 1 (keyIndexMatchingGroup). Cela renvoie donc le cn du groupe.
      3. Insérer le sous-groupe en tant qu'enfant du groupe

Lors de la recherche de l'appartenance d'une personne à un groupe, le test se fera en parcourant l'attribut memberOfAttributeName et en effectuant une comparaison avec la clé des groupes. 

Configuration du SmartLdapGroupStore avec un dn dans l'entrée de personne

 

...


La configuration attendue est la suivante :

Bloc de code
    <!--
     | This bean is the ContextSource instance that will be used to connect to LDAP.
     +-->
    <bean id="ldapContext" class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="url" value="ldap://frmp0165.frml.bull.fr:389"/>
        <property name="userDn" value="uid=root,dc=univ,dc=fr"/>
        <property name="password" value="secret"/>
    </bean>

    <!--
     | Period, in seconds, after which SmartLdap will drop and re-init the groups 
     | tree.  A value of zero or less (negative) disables this feature.
     +-->
    <bean id="groupsTreeRefreshIntervalSeconds" class="java.lang.Long">
        <constructor-arg><value>900</value></constructor-arg>
    </bean>
    
    <!--
     | BaseDn that will be passed to the search (not to the context).
     |
     | WARNING:  If you get an error like this...
     |   ...PartialResultException: [LDAP: error code 10...
     | it probably means your baseDn isn't correct!
     +-->
    <bean id="baseDn" class="java.lang.String">
        <constructor-arg><value>ou=groups,dc=univ,dc=fr</value></constructor-arg>
    </bean>

    <!--
     | ESUP Parameter. 
     | This parameter is used to extract the id path of the groups 
     | from their dn. 
     | The id path is caught from the nth group of the regex where n is the value 
     | of keyIndexMatchingGroup.
     | (http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#group%28int%29)
    -->
    <bean id="childGroupKeyRegex" class="java.lang.String">
        <constructor-arg><value>cn=(.*),ou=groups,dc=univ,dc=fr</value></constructor-arg>
    </bean>
    <bean id="keyIndexMatchingGroup" class="java.lang.Integer">
        <constructor-arg><value>0</value></constructor-arg>
    </bean>

    <!--
     | NOTE:  The remaining examples in this file are configured correctly for 
     | Active Directory servers.
     +-->

    <!--
     | LDAP query string that will be passed to the search.
     +-->
    <bean id="filter" class="java.lang.String">
        <constructor-arg><value>(objectClass=groupOfNames)</value></constructor-arg>
    </bean>

    <!--
     | These beans tell smartLdap whether to gather additional groups that are 
     | members of groups returned by the first baseDn and filter, and where to 
     | look if so.
     |
     |   - resolveMemberGroups=[true|false]
     |   - resolveDn={a different, broader baseDn than the one above}
     |
     | Here's how it works:  smartLdap will first collect all groups under the 
     | baseDn specified above.  If 'resolveMemberGroups' is enabled, it will 
     | also search for additional groups (found within the 'resolveDn' specified 
     | here) that are members of groups in the first collection.
     +-->
    <bean id="resolveMemberGroups" class="java.lang.Boolean">
        <constructor-arg><value>false</value></constructor-arg>
    </bean>
    <bean id="resolveDn" class="java.lang.String">
        <constructor-arg><value>changeme</value></constructor-arg>
    </bean>

    <!--
     | This bean identifies the name of the Person Attribute that
     | lists the SmartLdap groups each person is a member of.
     +-->
    <bean id="memberOfAttributeName" class="java.lang.String">
        <constructor-arg><value>isMemberOf</value></constructor-arg>
    </bean>

    <!--
     | This bean identifies the org.springframework.ldap.core.AttributesMapper
     | implementation used in reading the groups records from LDAP.
     +-->
    <bean id="contextMapper" class="org.jasig.portal.groups.smartldap.SimpleContextMapper">
        <!--
         | Name of the group attribute that tells you its key.
         | If ommited, will use the dn.
         +-->
		<!--
        <property name="keyAttributeName">
            <value>cn</value>
        </property>
		-->
        <!--
         | Name of the group attribute that tells you its name.
         +-->
        <property name="groupNameAttributeName">
            <value>cn</value>
        </property>
        <!--
         | Name of the group attribute that lists its members.
         +-->
        <property name="membershipAttributeName">
            <value>member</value>
        </property>
    </bean>

Prise en compte du SmartLdapGroupStore dans les groupes uPortal

...

 Le code utilise les attributs comme suit :

...

  1. Recherche de tous les groupes
  2. Pour chaque groupe
    1. Extraire l'attribut qui servira clé soit le dn en l'absence de keyAttributeName
    2. Extraire l'attribut qui servira de nom soit le cn (groupNameAttributeName)
    3. Extraire la liste des membres soit les member (membershipAttributeName)
    4. Pour chaque membre
      1. Vérifier s'il s'agit d'un groupe en vérifiant que l'expression matche l'expression cn=(.*),ou=groups,dc=univ,dc=fr (childGroupKeyRegex)
      2. S'il s'agit bien d'un groupe, extraire la clé en utilisant le groupe dont l'index est 0 (keyIndexMatchingGroup). Cela renvoie donc le dn du groupe.
      3. Insérer le sous-groupe en tant qu'enfant du groupe

Prise en compte du SmartLdapGroupStore dans les groupes uPortal

  • Ajouter les groupes smartLDAP à votre arborescence des groupes. Par exemple, on peut modifier le fichier Everyone.group-membership.xml comme suit :
Bloc de code
<group script="classpath://org/jasig/portal/io/import-group_membership_v3-2.crn">
  <name>Everyone</name>
  <entity-type>org.jasig.portal.security.IPerson</entity-type>
  <creator>system</creator>
  <description>All Users</description>
  <children>
    <group>Authenticated Users</group>
    <group>PAGS Root</group>
    <group>Faculty</group>
    <group>Guests</group>
    <group>Portal System</group>
    <group>Staff</group>
    <group>Students</group>
    <!-- Ajout des groupes SmartLdap -->
    <group>SmartLdap ROOT</group>
  </children>
</group>

 

  • L'import du fichier modifié s'effectue via la tâche d'import du portail. L'arborescence des groupes est alors construite. Dans les logs, on peut lire l'ensemble des groupes importés.
Bloc de code
ant data-import -Dfile=uportal-war/src/main/data/quickstart_entities/group_membership/Everyone.group-membership.xml
>>>
...
	 [java]  INFO SmartLdap adding record for group:  esup:etablissements:etablissement_5:composantes:composante_17:tous with key esup:etablissements:etablissement_5:composantes:composante_17:tous

     [java]  INFO SmartLdap adding record for group:  esup:etablissements:etablissement_5:composantes:composante_18:tous with key esup:etablissements:etablissement_5:composantes:composante_18:tous

     [java]  INFO SmartLdap adding record for group:  esup:etablissements:etablissement_5:composantes:composante_19:tous with key esup:etablissements:etablissement_5:composantes:composante_19:tous

     [java]  INFO SmartLdap adding record for group:  esup:etablissements:etablissement_5:composantes:composante_20:tous with key esup:etablissements:etablissement_5:composantes:composante_20:tous
..


 

Appel d'un groupe provenant du SmartLdapGroupStore

...

Bloc de code
<group>admin:appli:appli1</group>

 Il faudra ensuite réimporter le fichier via la commande d'import pour qu'il soit pris en compte par le portail.