*************************************** Convert recursive groups to flat groups *************************************** Presentation ============ This tutorial explains how to synchronize recursive groups to flat groups in an LDAP directory. It will just focus on the script needed to do it, not on how to configure LDAP connection and filters. .. tip:: You can use the script to synchronize groups from one directory to another, or use the same directory in source and destination to provide flat groups to applications that can't use groups of groups. Script content ============== This script should be put as separated js file and included in LSC taks, like explained in :doc:`scripting documentation page `. To sum up, the script reads members of a group. If the member's DN is inside group branch, then it calls again the method to find sub group members. It the member's DN is inside user branch, then it adds the DN value to the destination value (and converts this value to the correct DN value expected in the destination directory). .. code-block:: console # vi /etc/lsc/lib.js .. code-block:: js function getMembersDn(srcLdap, dstLdap, dn, groupsRegistry) { // Manage forward slash in DN dn = dn.replace(/\//g,"\\2F"); var result = new java.util.ArrayList(); // Check if object is a group var ocs = srcLdap.attribute(dn, "objectClass"); var isGroup = false; for (var i=0; i 1) { return result; } var destMemberDn = destDn.get(0) + "," + dstLdap.getContextDn(); result.add(destMemberDn); } return result; } There are some hard-coded values in the script that you may want to change: * ``group`` : objectClass of group entries * ``member``: attribute name containing member DN in source LDAP * ``sAMAccountName``: attribute name containing user identifier in source LDAP * ``ou=users`` : RDN of the users branch in destination LDAP * ``uid``: attribute name containing user identifier in destination LDAP Script usage in LSC configuration ================================= Here is an example of how to call this script inside a dataset: .. code-block:: console # vi /etc/lsc/lsc.xml .. code-block:: XML member FORCE