Populating location field for users imported via LDAP Scheduled Load / Adding locations

Chris Dea1
Tera Contributor

Hi All,

 

I am a relatively new admin for my work's ServiceNow instance.  During our implementation a scheduled load was set up to import our employees via LDAP/AD and add them as SN users on sys_user.  I was recently asked why most of our users do not have have the location populated....

 

I looked at the transform map related to the scheduled load and I don't see any mapping to location for "target field".  So this seems to be the reason why the users imported from LDAP don't have a location set on their user record.  Screenshot below of the current transform map.

ChrisDea1_0-1694800402653.png

 

If we wanted to update the scheduled load to start using the "physicalDeliveryOfficeName" (from users LDAP/AD) and populate the location field on new SN users, and create locations in cmn_locations as needed, let me know if the steps below are correct:

 

1) Go to LDAP Servers and update the list of attributes in the attributes field to include the physicalDeliveryOfficeName.

 

ChrisDea1_1-1694800529308.png

 

2) Go to Transform maps and add new field mapping with source field "u_physicalDeliveryOfficeName" to target field "location".  I believe coalesce should be "false" and choice action as "create", correct.  From what I have read, if I want locations to be automatically created (we have hundreds not in SN cmn_locations), I should select "create" on the field mappping, right?  Basically if a user from LDAP has a u_physicalDeliveryOfficeName that does not correspond to an existing location in cmn_locations I want the location to be created/added.'

 

Basically, I want to keep things as low maintenance as possible if we were to start including the new field for users imported from LDAP.

 

For people who have experience doing something similar, can you confirm for me whether or not the steps above look good?  Is there anything I am missing?  

 

I am still a little worried about the steps for #2 above.  I am pretty sure the parent field for any locations added with the updated transform map would have empty "parent" field.  Does anyone have recommendations if I wanted to create the parent/child relationships?  I am not sure if a separate scheduled load would have to be created just to populate locations but I am hoping to avoid that.

 

If there's a better approach you've used for this type of scenario, please do share with me!

 

Thanks,

Chris

 

4 REPLIES 4

Dharmaraj5
Tera Contributor

Hello @Chris Dea1 ,

 

The thing you shared are absolutely correct you can proceed with above mentioned approach. Regarding your #2 point location is reference field on user table if we user 'create' in tranform map field  it will create new location if location with same name is not present with parent field empty, If we select 'Ignore' it will update if user record with location if location present in cmn_locatiobn table and if location is not present transform map will update other field expect location and If we user 'Reject' choice action if location was not present in location table then  whole user record will not update.

 

Refer following docs to understand choice action:

https://docs.servicenow.com/en-US/bundle/vancouver-platform-security/page/integrate/ldap/task/t_SetC...

 

If my answer solves your issue please mark it as Helpful 👍 and Accepted✔️ based on impact.

Thanks,

Dharmaraj

Jaspal Singh
Mega Patron
Mega Patron

Hi Chris,

All seems fine for now for both steps. Suggestion for step 2 will be to let it 'Create' for now i.e. when a fresh pull happens post the Location configuration is in place. Later (after the first sync for location) you can set it to 'Ignore' to avoid any typo errors to create any new location in ServiceNow.

If you are sure location will not have typos then you can let it be 'Create' as action

Chris Dea1
Tera Contributor

Dharmaraj and Jaspal, I appreciate the support!  With the steps I mentioned, can you confirm any new locations where value from source field (physicalDeliveryOfficeName) does not match an existing location will get created in cmn_locations table, right?   One lingering question I have related to setting parent of a location in this case.  Let's say I have an existing location records for "Central Office", "Remote Office West", "Remote Office East", etc. and I want to set one of them as the parent of any new location added during the LDAP scheduled load, how would you recommend I can achieve that?  (to automatically associate/set parent for new locations added).

 

Would it require a script on the Table Transfer Map?  If you have any example of script I could use to associate a new location added with an existing location to be parent, please do share.  I understand there would need to be logic to determine the correct parent for a given new location...  I was thinking I might have to also add an additional attribute on the LDAP server like "department" field from AD user or another field that may indicate a user's physical workplace, then also have that on the transform map.  Then I could script "if user department = communications, then parent = Central Office (this is pseudo code :). Screenshot below of the table transform map we have for the current scheduled load.

ChrisDea1_0-1694817127307.png

 

Thanks,

Chris

Yes, it will create a new location.

For setting parent you may need an onAfter() script.

Check for comment from Venkat from thread.