Le 19/10/2016 à 09:52, [email protected] a écrit :

Delete entry in destination using conditions (syncOptions)

Hello,

I am trying to enforce the following behavior with "<conditions>" directive 
using the documentation (i.e. Documentation » Version 2.1 » LSC Configuration » Synchronization 
Rules) :

    IF ( "mail" attribute in source == "mail" attribute in destination (i.e. 
duplicate entry) )
    AND IF ( "description" attribute in destination == "FR" )
    THEN delete entry in destination.


I don't want to synchronize entries because it is already done by first task 
inside same xml file (only delete duplicate entry).
I tried the configuration bellow but nothing happen (no erreor, no delete) :
----------------------------------------------------
<task>

   <name>delete-duplicate-entry</name>
   <bean>org.lsc.beans.SimpleBean</bean>

   <ldapSourceService>
     <name>src-ldap</name>
     <connection reference="ldap-ro" />
     <baseDn>dc=contacts,dc=fr</baseDn>
     <pivotAttributes>
       <string>mail</string>
       <string>description</string>
     </pivotAttributes>
     <fetchedAttributes>
       <string>mail</string>
       <string>description</string>
       <string>objectClass</string>
     </fetchedAttributes>
     <getAllFilter>(objectClass=inetOrgPerson)</getAllFilter>
     <getOneFilter>(&amp; (mail={mail}) (objectClass=inetOrgPerson) 
)</getOneFilter>
     <cleanFilter>(&amp; (mail={mail}) (objectClass=inetOrgPerson) 
)</cleanFilter>
   </ldapSourceService>

   <ldapDestinationService>
     <name>dst-ldap</name>
     <connection reference="ldap-rw" />
     <baseDn>dc=contacts,dc=internal</baseDn>
     <pivotAttributes>
       <string>mail</string>
       <string>description</string>
     </pivotAttributes>
     <fetchedAttributes>
       <string>description</string>
       <string>mail</string>
       <string>objectClass</string>
     </fetchedAttributes>
     <getAllFilter>(objectClass=inetOrgPerson)</getAllFilter>
     <getOneFilter>(&amp; (mail={mail}) (objectClass=inetOrgPerson) 
)</getOneFilter>
   </ldapDestinationService>

   <propertiesBasedSyncOptions>
     <!-- If you have an “update only” task, and the DN cannot be inferred from 
the source referrential, you can also use the dstBean: -->
     <mainIdentifier>dstBean.getMainIdentifier()</mainIdentifier>
     <defaultDelimiter>;</defaultDelimiter>
     <defaultPolicy>FORCE</defaultPolicy>
     <conditions>
       <create>false</create>
       <update>false</update>
       <!-- In the condition delete you have access to the dstBean. -->
       <delete><![CDATA[ dstBean.getDatasetFirstValueById('description') == "FR" 
]]></delete>
       <changeId>false</changeId>
     </conditions>
   </propertiesBasedSyncOptions>

</task>
----------------------------------------------------

I probably misunderstood something but I don't see where...

So how can I configure LSC to apply this behavior with "conditions" ?
Or maybe is there another way to do this ?


This seems correct. Maybe you should use a javascript variable to return the evaluation result, but I don't know if this is the problem.

What you also need to verify is that the corresponding entry in the source is not present. Setting the delete condition will not force LSC to delete the entry in destination if the entry still exists in source. It will just allow or prevent the deletion if LSC has found the entry should be removed.

--
Clément OUDOT
Consultant en logiciels libres, Expert infrastructure et sécurité
Savoir-faire Linux
137 boulevard de Magenta - 75008 PARIS
Blog: http://sflx.ca/coudot

_______________________________________________________________
Ldap Synchronization Connector (LSC) - http://lsc-project.org

lsc-users mailing list
[email protected]
http://lists.lsc-project.org/listinfo/lsc-users

Reply via email to