<config>
  <sync>
    <transaction>off</transaction>
<!-- Synchronize XOOPS
    <data name="Xoops">
      <object name="User">
        <syncdn>ou=People</syncdn>
        <masterdn>ou=People</masterdn>
        <syncattr>
          <name>cn</name>
        </syncattr>
        <syncattr>
          <name>userPassword</name>
        </syncattr>
        <syncattr>
          <name>mail</name>
        </syncattr>
        <syncattr>
          <name>createTimestamp</name>
          <check>off</check>
        </syncattr>
      </object>
    </data>
-->
<!-- Synchronize GroupOffice
    <data name="GroupOffice">
      <syncop>add</syncop>
      <syncop>delete</syncop>
      <syncop>modify</syncop>
      <object name="User">
        <syncdn>ou=People</syncdn>
        <syncattr>
          <name>cn</name>
        </syncattr>
        <syncattr>
          <name>sn</name>
        </syncattr>
        <syncattr>
          <name>initials</name>
        </syncattr>
        <syncattr>
          <name>title</name>
        </syncattr>
        <syncattr>
          <name>userPassword</name>
        </syncattr>
        <syncattr>
          <name>mail</name>
        </syncattr>
        <syncattr>
          <name>homePhone</name>
        </syncattr>
        <syncattr>
          <name>telephoneNumber</name>
        </syncattr>
        <syncattr>
          <name>fax</name>
        </syncattr>
        <syncattr>
          <name>mobile</name>
        </syncattr>
        <syncattr>
          <name>labeledURI</name>
        </syncattr>
        <syncattr>
          <name>preferredLanguage</name>
        </syncattr>
        <syncattr>
          <name>createTimestamp</name>
          <check>off</check>
        </syncattr>
      </object>
    </data>
-->
<!-- Synchronize SquirrelMail
    <data name="SquirrelMail">
      <object name="User">
        <syncdn>ou=People</syncdn>
        <syncattr>
          <name>cn</name>
        </syncattr>
        <syncattr>
          <name>mail</name>
        </syncattr>
      </object>
    </data>
-->
<!-- Synchronize OpenDocMan
    <data name="OpenDocMan">
      <object name="User">
        <syncdn>ou=People</syncdn>
        <syncattr>
          <name>cn</name>
        </syncattr>
        <syncattr>
          <name>sn</name>
        </syncattr>
        <syncattr>
          <name>userPassword</name>
        </syncattr>
        <syncattr>
          <name>telephoneNumber</name>
        </syncattr>
        <syncattr>
          <name>mail</name>
        </syncattr>
        <syncattr>
          <name>seeAlso</name>
          <rule>ou=Departments,ou=Roles,ou=Master,dc=lism,dc=com$</rule>
        </syncattr>
      </object>
      <object name="Role">
        <syncdn>ou=Departments,ou=Roles</syncdn>
        <syncattr>
          <name>cn</name>
        </syncattr>
      </object>
    </data>
-->
<!-- Synchronize CSV
    <data name="CSV">
      <object name="User">
        <syncdn>ou=People</syncdn>
        <syncattr>
          <name>cn</name>
        </syncattr>
        <syncattr>
          <name>sn</name>
        </syncattr>
        <syncattr>
          <name>userPassword</name>
        </syncattr>
        <syncattr>
          <name>mail</name>
        </syncattr>
      </object>
    </data>
-->
    <master>
      <containerdn>ou=Master</containerdn>
      <data>LDAP</data>
    </master>
  </sync>
<!-- XOOPS Data Management
  <data name="Xoops">
    <handler name="Rewrite">
      <libload>/usr/local/lism/lib/lism_util.pm</libload>
      <rewritemap name="date2time" type="function"/>
      <rewritemap name="time2date" type="function"/>
      <rewrite context="request" match="createtimestamp: *([0-9]*Z)" substitution="createtimestamp: %{date2time('%1')}"/>
      <rewrite context="searchResult" match="createtimestamp: *([0-9]*)" substitution="createtimestamp: %{time2date('%1')}"/>
    </handler>
    <container>
      <oc>organizationalUnit</oc>
      <rdn>ou=Xoops</rdn>
    </container>
    <storage name="SQL" hash="MD5:hex">
      <dsn>DBI:mysql:xoops:localhost</dsn>
      <admin>admin</admin>
      <passwd>secret</passwd>
      <mbcode>euc-jp</mbcode>
      <object name="User">
        <container>
          <oc>organizationalUnit</oc>
          <rdn>ou=People</rdn>
        </container>
        <table>xoops_users</table>
        <id>
          <column>uid</column>
        </id>
        <oc>inetOrgPerson</oc>
        <rdn>uid</rdn>
        <attr name="uid">
          <column>uname</column>
        </attr>
        <attr name="cn">
          <column>name</column>
        </attr>
        <attr name="sn">
          <selexpr>substring(name, 1, (case when position(' ' in name) then position(' ' in name)-1 else length(name) end))</selexpr>
        </attr>
        <attr name="userpassword">
          <column>pass</column>
        </attr>
        <attr name="mail">
          <column>email</column>
        </attr>
        <attr name="seealso">
          <oname>Role</oname>
          <fromtbls>xoops_groups_users_link</fromtbls>
          <joinwhere>xoops_groups.groupid=xoops_groups_users_link.groupid and xoops_users.uid=xoops_groups_users_link.uid</joinwhere>
          <addproc>insert into xoops_groups_users_link(uid, groupid) values(%o,
%a)</addproc>
          <delproc>delete from xoops_groups_users_link where uid = %o and groupid = %a</delproc>
        </attr>
        <attr name="createtimestamp">
          <column>user_regdate</column>
        </attr>
      </object>
      <object name="Role">
        <container>
          <oc>organizationalUnit</oc>
          <rdn>ou=Roles</rdn>
        </container>
        <table>xoops_groups</table>
        <id>
          <column>groupid</column>
        </id>
        <oc>organizationalRole</oc>
        <rdn>cn</rdn>
        <attr name="cn">
          <column>group_type</column>
        </attr>
        <attr name="description">
          <column>name</column>
        </attr>
      </object>
    </storage>
  </data>
-->
<!-- Group Office Data Management
  <data name="GroupOffice">
    <container>
      <oc>organizationalUnit</oc>
      <rdn>ou=GroupOffice</rdn>
      <attr name="description">GroupWare</attr>
    </container>
    <handler name="Rewrite">
      <libload>/usr/local/lism/lib/lism_util.pm</libload>
      <rewritemap name="date2time" type="function"/>
      <rewritemap name="time2date" type="function"/>
      <rewrite context="request" match="createtimestamp: *([0-9]*Z)" substitution="createtimestamp: %{date2time('%1')}"/>
      <rewrite context="searchResult" match="createtimestamp: *([0-9]*)" substitution="createtimestamp: %{time2date('%1')}"/>
    </handler>
    <handler name="Script">
      <execrule type="post" dn=".*,ou=People,ou=GroupOffice,dc=lism,dc=com">
        <op name="add">
          <script>/usr/local/lism/sbin/mkhomedir.sh localhost add %r uidNumber=48#gidNumber=48</script>
        </op>
        <op name="delete">
          <script>/usr/local/lism/sbin/mkhomedir.sh localhost delete %r</script>
        </op>
      </execrule>
    </handler>
    <storage name="SQL" hash="MD5:hex">
      <dsn>DBI:mysql:groupoffice:localhost</dsn>
      <admin>admin</admin>
      <passwd>secret</passwd>
      <object name="User">
        <container>
          <rdn>ou=People</rdn>
          <oc>organizationalUnit</oc>
        </container>
        <table>users</table>
        <id>
          <column>id</column>
        </id>
        <oc>inetOrgPerson</oc>
        <rdn>uid</rdn>
        <attr name="uid">
          <column>username</column>
        </attr>
        <attr name="cn">
          <selexpr>concat(first_name, ' ', last_name)</selexpr>
          <addproc>update users set last_name = substring('%a',position(' ' in '%a')+1,char_length('%a')-position(' ' in '%a')) where id = %o</addproc>
          <delproc>update users set last_name = '' where id = %o</delproc>
        </attr>
        <attr name="sn">
          <column>first_name</column>
        </attr>
        <attr name="initials">
          <column>initials</column>
        </attr>
        <attr name="title">
          <column>title</column>
        </attr>
        <attr name="userpassword">
          <column>password</column>
        </attr>
        <attr name="mail">
          <column>email</column>
        </attr>
        <attr name="homephone">
          <column>home_phone</column>
        </attr>
        <attr name="telephonenumber">
          <column>work_phone</column>
        </attr>
        <attr name="mobile">
          <column>cellular</column>
        </attr>
        <attr name="fax">
          <column>fax</column>
        </attr>
        <attr name="seealso">
          <oname>Role</oname>
          <fromtbls>users_groups</fromtbls>
          <joinwhere>groups.id=users_groups.group_id and users.id=users_groups.user_id</joinwhere>
          <addproc>insert into users_groups(user_id, group_id) values(%o, %a)</addproc>
          <delproc>delete from users_groups where user_id = %o and group_id = %a</delproc>
        </attr>
        <attr name="createtimestamp">
          <column>registration_time</column>
        </attr>
        <strginfo>
          <column>authcode</column>
          <value type="function">substr(Digest::MD5::md5_base64(time), 0, 8)</value>
        </strginfo>
        <strginfo>
          <column>date_format</column>
          <value type="constant">d-m-Y</value>
        </strginfo>
        <strginfo>
          <value type="function">($entryStr =~ /mail: (.*)$/mi)[0]</value>
          <addproc>insert into acl_items(user_id, description) values('%o', '%v')</addproc>
          <addproc>insert into acl values((select id from acl_items where user_id = %o), 0, 1)</addproc>
          <addproc>insert into acl values((select id from acl_items where user_id = %o), 0, 2)</addproc>
          <delproc>delete from acl where acl_id in (select id from acl_items where user_id = %o)</delproc>
          <delproc>delete from acl_items where user_id = %o</delproc>
        </strginfo>
      </object>
      <object name="Role">
        <container>
          <rdn>ou=Roles</rdn>
          <oc>organizationalUnit</oc>
        </container>
        <table>groups</table>
        <id>
          <column>id</column>
        </id>
        <oc>organizationalRole</oc>
        <rdn>cn</rdn>
        <attr name="cn">
          <column>name</column>
        </attr>
      </object>
    </storage>
  </data>
-->
<!-- SquirrelMail Data Management
  <data name="SquirrelMail">
    <container>
      <oc>organizationalUnit</oc>
      <rdn>ou=SquirrelMail</rdn>
    </container>
    <storage name="SQL">
      <dsn>DBI:mysql:squirrelmail:localhost</dsn>
      <admin>admin</admin>
      <passwd>secret</passwd>
      <mbcode>euc-jp</mbcode>
      <object name="User">
        <container>
          <oc>organizationalUnit</oc>
          <rdn>ou=People</rdn>
        </container>
        <table>userprefs</table>
        <id>
          <column>user</column>
        </id>
        <oc>inetOrgPerson</oc>
        <rdn>uid</rdn>
        <attr name="uid">
          <column>user</column>
        </attr>
        <attr name="cn">
          <selexpr>prefval</selexpr>
          <joinwhere>prefkey="full_name"</joinwhere>
          <addproc>insert into userprefs values('%o', 'full_name', '%a')</addproc>
          <delproc>delete from userprefs where user = '%o' and prefkey = 'full_name'</delproc>
        </attr>
        <attr name="mail">
          <selexpr>prefval</selexpr>
          <joinwhere>prefkey="email_address"</joinwhere>
          <addproc>insert into userprefs values('%o', 'email_address', '%a')</addproc>
          <delproc>delete from userprefs where user = '%o' and prefkey = 'email_address'</delproc>
        </attr>
        <strginfo>
          <addproc>insert into userprefs values('%o', 'hililist', 'a:0:{}')</addproc>
        </strginfo>
        <strginfo>
          <addproc>insert into userprefs values('%o', 'javascript_on', '1')</addproc>
        </strginfo>
        <strginfo>
          <addproc>insert into userprefs values('%o', 'prefix_sig', '0')</addproc>
        </strginfo>
      </object>
    </storage>
  </data>
-->
<!-- OpenDocMan Data Management
  <data name="OpenDocMan">
    <container>
      <oc>organizationalUnit</oc>
      <rdn>ou=OpenDocMan</rdn>
      <attr name="description">Document Repository</attr>
    </container>
    <storage name="SQL" hash="MYSQL">
      <dsn>DBI:mysql:opendocman:localhost</dsn>
      <admin>admin</admin>
      <passwd>secret</passwd>
      <object name="User">
        <container>
          <rdn>ou=People</rdn>
          <oc>organizationalUnit</oc>
        </container>
        <table>user</table>
        <id>
          <column>id</column>
        </id>
        <oc>inetOrgPerson</oc>
        <rdn>uid</rdn>
        <attr name="uid">
          <column>username</column>
        </attr>
        <attr name="cn">
          <selexpr>concat(first_name, ' ', last_name)</selexpr>
          <addproc>update user set last_name = substring('%a',position(' ' in '%a')+1,char_length('%a')-position(' ' in '%a')) where id = %o</addproc>
          <delproc>update user set last_name = '' where id = %o</delproc>
        </attr>
        <attr name="sn">
          <column>first_name</column>
        </attr>
        <attr name="userpassword">
          <column>password</column>
        </attr>
        <attr name="telephonenumber">
          <column>phone</column>
        </attr>
        <attr name="mail">
          <column>Email</column>
        </attr>
        <attr name="seealso">
          <oname>Role</oname>
          <joinwhere>user.department=department.id</joinwhere>
          <addproc>update user set department = %a where id = %o</addproc>
          <delproc>update user set department = '' where id = %o</delproc>
        </attr>
      </object>
      <object name="Role">
        <container>
          <oname>Category</oname>
        </container>
        <table>department</table>
        <id>
          <column>id</column>
        </id>
        <oc>organizationalRole</oc>
        <rdn>cn</rdn>
        <attr name="cn">
          <column>name</column>
        </attr>
      </object>
      <object name="Category">
        <container>
          <rdn>ou=Roles</rdn>
          <oc>organizationalUnit</oc>
        </container>
        <entry>
          <rdn>ou=Departments</rdn>
          <oc>organizationalUnit</oc>
        </entry>
      </object>
    </storage>
  </data>
-->
<!-- CSV Data Management
  <data name="CSV">
    <container>
      <rdn>ou=CSV</rdn>
      <oc>organizationalUnit</oc>
    </container>
    <storage name="CSV" hash="CLEARTEXT">
      <object name="User">
        <container>
          <rdn>ou=People</rdn>
          <oc>organizationalUnit</oc>
        </container>
        <file>/usr/local/lism/var/lib/csv/user.csv</file>
        <id>
          <column>0</column>
        </id>
        <oc>inetOrgPerson</oc>
        <rdn>uid</rdn>
        <attr name="uid">
          <column>0</column>
        </attr>
        <attr name="cn">
          <column>1</column>
        </attr>
        <attr name="sn">
          <column>2</column>
        </attr>
        <attr name="userpassword">
          <column>3</column>
        </attr>
        <attr name="mail">
          <column>4</column>
        </attr>
      </object>
    </storage>
  </data>
-->
  <data name="LDAP">
    <container>
      <oc>organizationalUnit</oc>
      <rdn>ou=LDAP</rdn>
    </container>
<!-- Use Samba password
    <handler name="Rewrite">
      <libload>/usr/local/lism/lib/lism_smb.pm</libload>
      <rewritemap name="smbPassword" type="function"/>
      <rewrite context="request" match="(userPassword: .*)" substitution="%{smbPassword('%1')}"/>
    </handler>
-->
    <storage name="LDAP" hash="MD5">
      <uri>ldap://localhost/dc=example,dc=com</uri>
      <binddn>cn=Manager,dc=example,dc=com</binddn>
      <bindpw>secret</bindpw>
    </storage>
  </data>
</config>
