<?xml version="1.0" encoding="UTF-8"?>
<config>
  <sync>
    <transaction>off</transaction>
    <data name="IDP">
      <object name="User">
        <syncdn>ou=People</syncdn>
        <syncfilter>(&amp;(objectClass=organizationalPerson)(!(uid=ADMINID)))</syncfilter>
        <dnignore>on</dnignore>
        <syncattr>
          <name>employeeNumber</name>
        </syncattr>
        <syncattr>
          <name>sn</name>
        </syncattr>
        <syncattr>
          <name>givenName</name>
        </syncattr>
        <syncattr>
          <name>mail</name>
        </syncattr>
        <syncattr>
          <name>distinguishedName</name>
        </syncattr>
      </object>
      <object name="Organization">
        <syncdn>ou=Organizations</syncdn>
        <syncfilter>(objectClass=organizationalUnit)</syncfilter>
        <syncattr>
          <name>description</name>
        </syncattr>
      </object>
    </data>
    <master>
      <containerdn>ou=Master</containerdn>
      <data>LDAP</data>
    </master>
  </sync>
  <data name="LDAP">
    <container>
      <oc>organizationalUnit</oc>
      <rdn>ou=LDAP</rdn>
    </container>
    <handler name="Rewrite">
      <libload>LISM/Utils/lism_util.pl</libload>
      <rewritemap name="dn2oupath" type="function"/>
      <rewrite context="request" match="ou=(People|Organizations),ou=(LDAP|Master)," substitution="ou=%2,"/>
      <rewrite context="searchResult" filter="(objectClass=user)" match="ou=(LDAP|Master)," substitution="ou=People,ou=%1,"/>
      <rewrite context="searchResult" filter="(objectClass=organizationalUnit)" match="ou=(LDAP|Master)," substitution="ou=Organizations,ou=%1,"/>
      <rewrite context="searchResult" filter="(objectClass=user)" match="distinguishedName: (.+)" substitution="distinguishedName: %{dn2oupath('%1', 'ou=People,', 1)}"/>
    </handler>
    <storage name="AD">
      <uri>ldap://localhost/dc=example,dc=com</uri>
      <binddn>cn=Administrator,cn=users,dc=example,dc=com</binddn>
      <bindpw>secret</bindpw>
      <ldapmap type="attribute" local="uid" foreign="cn"/>
      <ldapmap type="attribute" local="userPassword" foreign="unicodePwd"/>
    </storage>
  </data>
  <data name="IDP">
    <container>
      <oc>organizationalUnit</oc>
      <rdn>ou=IDP</rdn>
    </container>
    <handler name="Setval">
      <libload>LISM/Utils/lism_util.pl</libload>
      <entry dn="uid=[^,]+,ou=People,">
        <default name="objectclass">
          <value type="constant">person</value>
          <value type="constant">inetOrgPerson</value>
          <value type="constant">seciossPerson</value>
          <value type="constant">seciossIamAccount</value>
        </default>
        <default name="cn">
          <value type="function">getValue($entryStr, 'sn').' '.getValue($entryStr, 'givenName')</value>
        </default>
        <default name="preferredlanguage">
          <value type="constant">ja</value>
        </default>
        <default name="seciossaccountstatus">
          <value type="constant">active</value>
        </default>
        <default name="userpassword">
          <value type="function">randString(8, 'a..z', 'A..Z', '0..9')</value>
        </default>
        <default name="seciosspwdchangedtime">
          <value type="function">time2date()</value>
        </default>
        <default name="seciosspwdmustchange">
          <value type="constant">"TRUE"</value>
        </default>
<!--
        <default name="seciossallowedservice">
          <value type="constant">googleapps</value>
        </default>
-->
      </entry>
      <entry dn=",ou=Organizations,">
        <default name="objectclass">
          <value type="constant">organizationalUnit</value>
        </default>
      </entry>
    </handler>
    <handler name="Rewrite">
      <rewrite context="request" match="uid(=|: )([^,\)]+)" substitution="uid%1%2@TENANTID"/>
      <rewrite context="searchResult" dn="uid=[^,]+,ou=People," match="uid(=|: )([^@]+)@[^,]+" substitution="uid%1%2"/>
      <rewrite context="request" dn="uid=[^,]+,ou=People," match="distinguishedName: (.*)" substitution="ou: %1"/>
      <rewrite context="searchResult" dn="uid=[^,]+,ou=People," match="ou: (.*)" substitution="distinguishedName: %1"/>
    </handler>
    <storage name="SOAP">
      <uri>https://slink.secioss.com/SoapSIM</uri>
      <proxy>https://slink.secioss.com/cgi-bin/lism.cgi</proxy>
      <basedn>o=TENANTID,ou=Master,o=lism</basedn>
      <binddn>uid=ADMINID,ou=People,o=TENANTID,ou=Master,o=lism</binddn>
      <bindpw>ADMINPW</bindpw>
    </storage>
  </data>
</config>
