<h2>How LDAP Imports Link Users with Groups (Group Membership)</h2><br/><div style="overflow-x:auto"><article><div ><h3 >Summary</h3><section><div>This is done by the OOB onAfter() script of Transform Map <em>LDAP Group Import (</em>/nav_to.do?uri=sys_transform_script.do?sys_id=0dc646160a0a0b26007beb877ee7cdf9)<em>.</em> The onAfter() script runs even if the record was ignored during the transform (due to no changes). This onAfter() script will update Group Membership[sys_user_grmember], adding or deleting records as appropriate.</div> <div> </div> <div><strong>More Details</strong></div> <div>The Script Include that the onAfter script calls relies on the value of the member[u_member] field of the imported LDAP Group Imports[ldap_group_import] record. member[u_member] should have a '^' separated list of all users who are members of that group, for example:</div> <pre>CN=John Smith,OU=IT,DC=ad,DC=ACME,DC=com^CN=Jane Doe,OU=IT,DC=ad,DC=ACME,DC=com</pre> <div> </div> <div>The mechanism that the onAfter() script uses is in the code in the GlideLDAPGroups class (in the Java code). Basically this code splits the value of the <em>member</em> field in the staging table (<em>ldap_group_import</em>) record on the '^' character. Each of the sub-strings is the DN of a user who should be added to the group. To add the user to the group, the code queries the sys_user table with the filter 'source=ldap:<DN of one user from member attribute>'. Any pre-existing sys_user_grmember records for users who are no longer seen in that member[u_member] field are removed</div></section></div><div ><h3 >Related Links</h3><section><div><strong>LDAP Scheduled Data Import Not Updating Group Membership[sys_user_grmember]</strong></div> <div>On some versions the example <em>LDAP Group Import</em> Scheduled Data Import has the <em>Run as</em> field blank, meaning the import runs as the <em>system</em> user. In London PRB1168978/KB0689665 was fixed, which involved a lot of changes around which users are allowed to give group memberships (and therefore roles, which are tied in to group membership) to others. It looks like this resulted in the <em>system</em> user no longer being able to create or delete Group Membership[sys_user_grmember] records when doing so would grant certain roles to a user.</div> <div> </div> <div>The recommendation is to create an <em>admin</em> Role user specifically for LDAP imports (with a random unknown password) and set that in the <em>Run as</em> field on the <em>LDAP Group Import</em> Scheduled Data Import.</div> <div> </div> <div><strong>Users' group membership is not updated via LDAP import</strong></div> <div>You can refer to <a href="https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0727831">KB0727831</a> for more information.</div></section></div></article></div>