<?xml version="1.0" ?>
<lsc xmlns="http://lsc-project.org/XSD/lsc-core-2.1.xsd" revision="0">
<!--  ./connections Connections list node, must contain at least two connections -->
  <connections>
      <ldapConnection>
      <name>cnx-mte</name>
      <url>ldap://ldapmte.id.fr:389/dc=mte,dc=fr</url>
      <username>cn=syncuser,ou=System,dc=mte,dc=fr</username>
      <password>secret</password>
      <authentication>SIMPLE</authentication>
      <referral>IGNORE</referral>
      <derefAliases>NEVER</derefAliases>
      <version>VERSION_3</version>
      <pageSize>-1</pageSize>
      <factory>com.sun.jndi.ldap.LdapCtxFactory</factory>
      <tlsActivated>false</tlsActivated>
    </ldapConnection>

    <ldapConnection>
      <name>ldap-id-conn</name>
<!--  ./url mandatory, the JNDI URL -->
      <url>ldap://localhost:389/dc=id,dc=fr</url>
<!--  ./username mandatory, the DN to bind with -->
      <username>cn=syncuser,ou=system,dc=id,dc=fr</username>
<!--  ./password mandatory, credentials to bind with -->
      <password>secret</password>
<!--  ./authentication mandatory, must contain either ANONYMOUS, SIMPLE, SASL, GSSAPI or DIGEST_MD5 -->
      <authentication>SIMPLE</authentication>
<!--  ./referral mandatory, must contain either IGNORE, THROUGH, THROW or FOLLOW -->
      <referral>IGNORE</referral>
<!--  ./derefAliases mandatory, must contain either NEVER, SEARCH, FIND, ALWAYS -->
      <derefAliases>NEVER</derefAliases>
<!--  ./version mandatory, must contain either VERSION_2, VERSION_3 -->
      <version>VERSION_3</version>
<!--  ./pageSize optional, specify the paged size when searching -->
      <pageSize>-1</pageSize>
<!--  ./factory mandatory, points to LDAP Context Factory, com.sun.jndi.ldap.LdapCtxFactory for a SUN JDK -->
      <factory>com.sun.jndi.ldap.LdapCtxFactory</factory>
<!--  ./tlsActivated optional, specify if SSL/TLS is activated to connect to the LDAP server -->
      <tlsActivated>false</tlsActivated>
    </ldapConnection>
  </connections>

<!--  ./tasks Task list node, must contain at least one task -->
  <tasks>

<!--  ./task Task node, this is the main node, in which synchronization is defined -->
    <task>
<!--  ./name mandatory task node this is the main node, in which synchronization is defined -->
      <name>user</name>
<!--  ./bean optional bean node, default to org.lsc.beans.SimpleBean, define the pivot object used to store datasets and values -->
      <bean>org.lsc.beans.SimpleBean</bean>
<!--  ./sourceService mandatory node containing definition of the source service settings  
			possible builtin types are :
				databaseSourceService, ldapSourceService 
					Plugins also provides: syncreplSourceService, nisSourceService
		-->
	<ldapSourceService>
        <name>ldap-source-service</name>
        <connection reference="cnx-mte" />
	<baseDn>ou=people,dc=mte,dc=fr</baseDn>
        <pivotAttributes>
          <string>eduPersonPrincipalName</string>
        </pivotAttributes>
        <fetchedAttributes>
          <string>uid</string>
          <string>description</string>
          <string>cn</string>
          <string>mail</string>
          <string>sn</string>
          <string>departmentNumber</string>
          <string>employeeType</string>
          <string>givenName</string>
          <string>telephoneNumber</string>
          <string>mobile</string>
          <string>LabeledURI</string>
          <string>postalAddress</string>
          <string>RoomNumber</string>
          <string>title</string>
          <string>jpegphoto</string>
          <string>edupersonAffiliation</string>
          <string>eduPersonPrincipalName</string>
          <string>supanncivilite</string>
          <string>supannListeRouge</string>
          <string>supannEntiteAffectation</string>
        </fetchedAttributes>
        <getAllFilter><![CDATA[(&(eduPersonPrincipalName=*)(objectClass=inetOrgPerson)(eduPersonOrgUnitDn=*sn=TSP,*)(uid=pro*)(!(employeeType=System)))]]></getAllFilter>
        <getOneFilter><![CDATA[(&(objectClass=inetOrgPerson)(eduPersonPrincipalName={eduPersonPrincipalName}))]]></getOneFilter>
        <cleanFilter><![CDATA[(&(objectClass=inetOrgPerson)(eduPersonPrincipalName={eduPersonPrincipalName}))]]></cleanFilter>
    </ldapSourceService>

<!--  ./destinationService mandatory node containing definition of the source service settings  
			@class define the implementation, possible builtin types are :
				databaseDestinationService, ldapDestinationService 
					Plugins also provides: jndiExecDstService
		-->
      <ldapDestinationService>
<!-- 	A ldap destination service will have to contain at least a name, a connection reference, a base DN, a filter to list
			entries, a filter to get a particular entry, a list of pivot attributes and a list of fetched attributes -->
        <name>ldap-dst-service</name>
        <connection reference="ldap-id-conn" />
<!--	./baseDn This mandatory node provide the directory base branch that will be used to look for entries (list and get) -->
        <baseDn>ou=people,ou=mte,dc=id,dc=fr</baseDn>
<!--	./pivotAttributes This mandatory node must include string nodes with attributes name that will be used with their values 
			as pivot datasets (used to get the corresponding entry and to identify the counter-part object, here in the source database
			used during the clean phase to delete the corresponding entry if no corresponding object is found)-->
        <pivotAttributes>
          <string>eduPersonPrincipalName</string>
        </pivotAttributes>
<!--	./fetchedAttributes This mandatory node must include string nodes with attributes name that will fill the full object.
			In a LDAP destination service, fetched attributes will be written to the target directory, whereas source provided datasets
			that are not listed their will silently be canceled, i.e. not synchronized with the directory. -->
        <fetchedAttributes>
          <string>description</string>
          <string>cn</string>
          <string>sn</string>
          <string>userPassword</string>
          <string>objectClass</string>
          <string>uid</string>
          <string>mail</string>
	  <string>departmentNumber</string>
          <string>employeeType</string>
          <string>givenName</string>
          <string>telephoneNumber</string>
          <string>mobile</string>
          <string>LabeledURI</string>
          <string>postalAddress</string>
          <string>title</string>
          <string>jpegphoto</string>
          <string>edupersonAffiliation</string>
          <string>eduPersonPrincipalName</string>
          <string>supanncivilite</string>
          <string>supannListeRouge</string>
          <string>supannEntiteAffectation</string>
        </fetchedAttributes>
<!--	./getAllFilter This mandatory node must include the filter that will be used to list all target objects. In a LDAP destination service
					this value is used during the clean phase to look for every object that it has a corresponding object in the source database -->
        <getAllFilter>(objectClass=inetorgperson)</getAllFilter>
<!--	./getOneFilter This mandatory node must include the filter that will be used to get a particular entry. In a LDAP destination service
					this value is used during the synchronization phase to get the object - in conjonction with fetchedAttributes to synchronize them -->
        <getOneFilter>(&amp;(objectClass=inetorgperson)(eduPersonPrincipalName={eduPersonPrincipalName}))</getOneFilter>
      </ldapDestinationService>
<!--  ./syncOptions This mandatory node describes how to handle the various situations encountered while synchronizing datasets.
			It must contains a main identifier construction rule and a default policy.
			It may contains synchronization conditions, a default delimiter and datasets synchronization rules (attribute nodes) -->
      <propertiesBasedSyncOptions>
<!--    ./mainIdentifier This mandatory node must contain a string Javascript expression that will enforce the object main identifier.-->
       <!--  <mainIdentifier>"uid=" + srcBean.getDatasetValueById("uid") + ",ou=people,ou=mte,dc=id,dc=fr"</mainIdentifier> -->
	<mainIdentifier>js:"eduPersonPrincipalName=" + javax.naming.ldap.Rdn.escapeValue(srcBean.getDatasetFirstValueById("eduPersonPrincipalName")) + ",ou=people,ou=mte,dc=id,dc=fr"</mainIdentifier>
<!--    ./defaultDelimiter This mandatory node must contain a string Javascript expression that will enforce the object main identifier.-->
        <defaultDelimiter>;</defaultDelimiter>
<!--    ./defaultPolicy This mandatory node must contain a string Javascript expression that will enforce the object main identifier.-->
        <defaultPolicy>FORCE</defaultPolicy>
<!--    ./conditions This optional node may contain one or more of the four node : create, update, delete and changeId -->
        <conditions>
<!--       ./create This optional node may contain a boolean Javascript expression that will indicate whenever a new entry must be created or not -->
        	<create>true</create>
<!--       ./update This optional node may contain a boolean Javascript expression that will indicate whenever a existing entry must be updated or not -->
        	<update>true</update>
<!--       ./delete This optional node may contain a boolean Javascript expression that will indicate whenever a existing entry must be deleted or not -->
        	<delete>true</delete>
<!--       ./changeId This optional node may contain a boolean Javascript expression that will indicate whenever an existing object main identifier must be changed or not -->
        	<changeId>false</changeId>
        </conditions>
<!--    ./dataset This multi-valued node may contain a structure that will describe how to synchronize the corresponding dataset -->
        <dataset>
<!--      ./name Mandatory node containing the dataset name -->
          <name>objectClass</name>
<!--      ./policy Mandatory node containing the policy to apply to this dataset. Contains KEEP, FORCE or MERGE value -->
          <policy>KEEP</policy>
<!--      ./defaultValues Optional node containing a list of string values that will be used if noone is provided by datasource -->
          <defaultValues></defaultValues>
<!--      ./forceValues Optional node containing a list of string values that will be used to force destination service dataset values -->
          <forceValues></forceValues>
<!--      ./createValues Optional node containing a list of string values that will be used to force destination service dataset values when creating object -->
          <createValues>
            <string>"top"</string>
            <string>"person"</string>
	    <string>"inetOrgPerson"</string>
	    <string>"supannPerson"</string>
	    <string>"eduPerson"</string>
            <string>"organizationalPerson"</string>
            <string>"person"</string>
            <string>"labeledURIObject"</string>
          </createValues>
<!--      ./delimiter Used when multiples values are provided in a single joined value -->
          <delimiter>,</delimiter>
        </dataset>
        <dataset>
	<name>departmentNumber</name>
          <policy>FORCE</policy>
          <forceValues>
            <string><![CDATA[js:
                var department = srcBean.getDatasetFirstValueById("departmentNumber");
                if ( department == "TNT" ) { department = "TSP"; }
                if ( department == "TEMTSP" ) { department = "TM-TP"; }
                if ( department == "ITM" ) { department = "TM"; }
                department;
            ]]></string>
          </forceValues>
       </dataset>

      </propertiesBasedSyncOptions>
    </task>
  </tasks>
</lsc>
