<?xml version="1.0" ?>
<lsc xmlns="http://lsc-project.org/XSD/lsc-core-2.3.xsd" revision="0">
<!--
     See full documentation online:
     https://lsc-project.org/documentation/latest/index_configuration.html
-->
  <connections>

    <ldapConnection>
      <name>ldap-src-conn</name>
      <url>ldaps://ldap.example.com/dc=example,dc=com</url>
      <username>cn=admin,dc=example,dc=com</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>
      <saslMutualAuthentication>false</saslMutualAuthentication>
    </ldapConnection>

    <ldapConnection>
      <name>ldap-dst-conn</name>
      <url>ldaps://directory.acme.com/dc=acme,dc=com</url>
      <username>cn=administrator,cn=users,dc=acme,dc=com</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>
      <saslMutualAuthentication>false</saslMutualAuthentication>
    </ldapConnection>
  </connections>

  <tasks>

    <task>
      <name>user</name>
      <bean>org.lsc.beans.SimpleBean</bean>

      <ldapSourceService>
        <name>user-src-service</name>
        <connection reference="ldap-src-conn"/>
        <baseDn>ou=users,dc=example,dc=com</baseDn>
        <pivotAttributes>
          <string>uid</string>
        </pivotAttributes>
        <fetchedAttributes>
          <string>cn</string>
          <string>givenName</string>
          <string>mail</string>
          <string>sn</string>
          <string>uid</string>
        </fetchedAttributes>
        <allEntriesFilter>"(&amp;(objectClass=inetOrgPerson))"</allEntriesFilter>
        <oneEntryFilter>"(&amp;(objectClass=inetOrgPerson)(uid=" + pivotAttributes["uid"] + "))"</oneEntryFilter>
        <cleanEntryFilter>"(&amp;(objectClass=inetOrgPerson)(uid=" + pivotAttributes["samaccountname"] + "))"</cleanEntryFilter>
      </ldapSourceService>

      <ldapDestinationService>
        <name>user-dst-service</name>
        <connection reference="ldap-dst-conn" />
        <baseDn>cn=users,dc=acme,dc=com</baseDn>
        <pivotAttributes>
          <string>sAMAccountName</string>
        </pivotAttributes>
        <fetchedAttributes>
          <string>cn</string>
          <string>description</string>
          <string>givenName</string>
          <string>mail</string>
          <string>objectClass</string>
          <string>sAMAccountName</string>
          <string>sn</string>
        </fetchedAttributes>
        <allEntriesFilter>"(objectClass=user)"</allEntriesFilter>
        <oneEntryFilter>"(&amp;(objectClass=user)(sAMAccountName=" + pivotAttributes["uid"] + "))"</oneEntryFilter>
      </ldapDestinationService>

      <propertiesBasedSyncOptions>

        <mainIdentifier>"cn=" + javax.naming.ldap.Rdn.escapeValue( srcBean.getDatasetFirstValueById("cn") ) + ",ou=users,dc=acme,dc=com"</mainIdentifier>
        <defaultDelimiter>;</defaultDelimiter>
        <defaultPolicy>FORCE</defaultPolicy>

        <conditions>
            <create>true</create>
            <update>true</update>
            <delete>true</delete>
            <changeId>true</changeId>
        </conditions>

        <dataset>
          <name>description</name>
          <forceValues>
            <string>"Synchronized by LSC"</string>
          </forceValues>
        </dataset>

        <dataset>
          <name>objectClass</name>
          <policy>KEEP</policy>
          <createValues>
            <string>"top"</string>
            <string>"user"</string>
          </createValues>
        </dataset>

        <dataset>
          <name>sAMAccountName</name>
          <forceValues>
            <string>srcBean.getDatasetFirstValueById("uid")</string>
          </forceValues>
        </dataset>

      </propertiesBasedSyncOptions>

    </task>

  </tasks>

</lsc>
