<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>post LDAP Integration - Load Locations and Departments along with user records. in ServiceNow AI Platform blog</title>
    <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/ba-p/2282819</link>
    <description>&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;Many a times we integrate LDAP with servicenow and does not get all the information required for reference fields like 'location' and 'department' on 'sys_user' table from LDAP itself. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;We are then left with the option to load these information from another spreadsheet and then associate it with user records which is sometime a painful task. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;Recently we happened to work on LDAP integration with one of the customer. Good thing &amp;nbsp; we noticed while doing this integration is that their user object attributes were really defined nicely and contained a lot of information rather than the basic attributes like samAccountName, firstName etc.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;We found user object was containing information related to locations (attributes like 'c' for country, 'st' for state, 'physicaldeliveryofficename' for city and 'streetaddress' for street address. Similar thing we noticed about department information also. So we thought to leverage those attributes, import location and department details to their respective tables and associate them to user record along with loading user information from LDAP. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;I had to write certain amount of code but it paid well and we could load locations and department details with no issue. So sharing the same with you, so that you can use it with &lt;STRONG&gt;little bit modification&lt;/STRONG&gt; if required after analyzing location attributes completely.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;You will require to paste this code into 'onBefore' transform map of LDAP. Code will take care to import locations and department details.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_14386015725094908 jive_macro_code" jivemacro_uid="_14386015725094908"&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;//gs.log('Deepak: xform User ' + source.u_givenname + ' ' + source.u_sn + ' in country: &amp;nbsp; ' + &lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; //source.u_c + ' With complete address ' + source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st + ', ' + source.u_c);&lt;BR /&gt;if(source.u_c != '')&lt;BR /&gt;{&lt;BR /&gt; var country = new GlideRecord('cmn_location');&lt;BR /&gt; country.addQuery('name',source.u_c); //look for country assoicated with current user record being imported&lt;BR /&gt; country.addQuery('company','a4e3e06a37014200cb18341643990e39');// query a record in domain separated environment associated with company&lt;BR /&gt; country.query();&lt;BR /&gt; var countryCount = 0;&lt;BR /&gt; if(country.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var countrySysID = country.sys_id; // if exists, then store sys_id to variable. Lateron, it will be used to set as parent for state&lt;BR /&gt; &amp;nbsp; countryCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist country' + ' ' &amp;nbsp; + countryCount + ' ' + source.u_c );&lt;BR /&gt; }&lt;BR /&gt; else if(countryCount == 0)&lt;BR /&gt; {&lt;BR /&gt; //gs.log('Deepak: ' + 'We need to insert new Country ' + source.u_c);&lt;BR /&gt; var countryNew = new GlideRecord('cmn_location');&lt;BR /&gt; countryNew.initialize();&lt;BR /&gt; countryNew.name = source.u_c;&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; countryNew.company = 'a4e3e06a37014200cb18341643990e39'; // associate location to company in domain separated environment. simply comment it out if you dont have domain separation setup&lt;BR /&gt; var countrySysID = countryNew.insert(); // if does not exists, then insert new contry and store sys_id to variable, use it to set as parent for state&lt;BR /&gt; //gs.log('Deepak: new country inserted ' + countryNew.name + ' ' + countrySysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;if(source.u_st != '')&lt;BR /&gt;{&lt;BR /&gt; var state = new GlideRecord('cmn_location');&lt;BR /&gt; state.addQuery('name',source.u_st); &lt;BR /&gt; state.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; state.query();&lt;BR /&gt; var stateCount = 0;&lt;BR /&gt; if(state.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var stateSysID = state.sys_id;&lt;BR /&gt; &amp;nbsp; stateCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist state ' + stateCount + ' ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(stateCount == 0)&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; gs.log('Deepak: ' + 'We need to insert new state');&lt;BR /&gt; &amp;nbsp; var stateNew = new GlideRecord('cmn_location');&lt;BR /&gt; &amp;nbsp; stateNew.initialize();&lt;BR /&gt; &amp;nbsp; stateNew.name = source.u_st;&lt;BR /&gt; &amp;nbsp; stateNew.state = source.u_st;&lt;BR /&gt; &amp;nbsp; stateNew.parent = countrySysID;&lt;BR /&gt; &amp;nbsp; stateNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; &amp;nbsp; var stateSysID = stateNew.insert();&lt;BR /&gt; //gs.log('Deepak: new state inserted ' + stateNew.name + ' ' + stateSysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;if(source.u_physicaldeliveryofficename != '')&lt;BR /&gt;{&lt;BR /&gt; var city = new GlideRecord('cmn_location');&lt;BR /&gt; city.addQuery('name',source.u_physicaldeliveryofficename);&lt;BR /&gt; city.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; city.query();&lt;BR /&gt; var cityCount = 0;&lt;BR /&gt; if(city.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var citySysID = city.sys_id;&lt;BR /&gt; &amp;nbsp; cityCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist city ' + cityCount + ' ' + source.u_physicaldeliveryofficename);&lt;BR /&gt; }&lt;BR /&gt; else if(cityCount == 0)&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; gs.log('Deepak: ' + 'We need to insert new city');&lt;BR /&gt; &amp;nbsp; var cityNew = new GlideRecord('cmn_location');&lt;BR /&gt; &amp;nbsp; cityNew.initialize();&lt;BR /&gt; &amp;nbsp; cityNew.name = source.u_physicaldeliveryofficename;&lt;BR /&gt; &amp;nbsp; cityNew.city = source.u_physicaldeliveryofficename;&lt;BR /&gt; &amp;nbsp; cityNew.state = source.u_st;&lt;BR /&gt; &amp;nbsp; cityNew.parent = stateSysID;&lt;BR /&gt; &amp;nbsp; cityNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; &amp;nbsp; var citySysID = cityNew.insert();&lt;BR /&gt; //gs.log('Deepak: new city inserted ' + cityNew.name + ' ' + citySysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;if(!(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st == '')) // if all address related attributes are not blank, then evaluate other things.&lt;BR /&gt;{&lt;BR /&gt; var address = new GlideRecord('cmn_location');&lt;BR /&gt; if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_physicaldeliveryofficename + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; address.addQuery('name',source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress );&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_physicaldeliveryofficename );&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename );&lt;BR /&gt; }&lt;BR /&gt; address.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; address.query();&lt;BR /&gt; var addressCount = 0;&lt;BR /&gt; if(address.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var addressSysID = address.sys_id;&lt;BR /&gt; &amp;nbsp; target.location = addressSysID;&lt;BR /&gt; &amp;nbsp; target.company = 'a4e3e06a37014200cb18341643990e39' ;&lt;BR /&gt; &amp;nbsp; addressCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist address' + addressCount + ' ' + source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(addressCount == 0)&lt;BR /&gt; {&lt;BR /&gt; //gs.log('Deepak: ' + 'We need to insert new address');&lt;BR /&gt; var addressNew = new GlideRecord('cmn_location');&lt;BR /&gt; addressNew.initialize();&lt;BR /&gt; if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st ;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_physicaldeliveryofficename + ', ' + source.u_st;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_st;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress + ', ' + source.u_st;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress ;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_physicaldeliveryofficename;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename;&lt;BR /&gt; }&lt;BR /&gt; addressNew.street = source.u_streetaddress;&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; addressNew.parent = citySysID;&lt;BR /&gt; addressNew.city = source.u_physicaldeliveryofficename;&lt;BR /&gt; addressNew.state = source.u_st;&lt;BR /&gt; addressNew.zip = source.u_postalcode;&lt;BR /&gt; addressNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; var addressSysID = addressNew.insert();&lt;BR /&gt; target.location = addressSysID; // location field visisble in user record in combination of streetaddress, physicaldeliery address(city) and state&lt;BR /&gt; target.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; //gs.log('Deepak: new address inserted ' + addressNew.name + ' ' + addressSysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;//Load Department details also along with user records.&lt;BR /&gt;if(source.u_department != '') //if department is not null&lt;BR /&gt;{&lt;BR /&gt; var depart = new GlideRecord('cmn_department');&lt;BR /&gt; depart.addQuery('name',source.u_department);&lt;BR /&gt; depart.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; depart.query();&lt;BR /&gt; var departCount = 0;&lt;BR /&gt; if(depart.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var departSysID = depart.sys_id;&lt;BR /&gt; &amp;nbsp; target.department = departSysID;&lt;BR /&gt; &amp;nbsp; departCount++;&lt;BR /&gt; }&lt;BR /&gt; else if(departCount == 0)&lt;BR /&gt; {&lt;BR /&gt; //gs.log('Deepak: ' + 'We need to insert new depart');&lt;BR /&gt; &amp;nbsp; var departNew = new GlideRecord('cmn_department');&lt;BR /&gt; &amp;nbsp; departNew.initialize();&lt;BR /&gt; &amp;nbsp; departNew.name = source.u_department;&lt;BR /&gt; &amp;nbsp; departNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; &amp;nbsp; var departSysID = departNew.insert();&lt;BR /&gt; &amp;nbsp; target.department = departSysID;&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Aug 2015 11:39:13 GMT</pubDate>
    <dc:creator>Deepak Ingale1</dc:creator>
    <dc:date>2015-08-03T11:39:13Z</dc:date>
    <item>
      <title>LDAP Integration - Load Locations and Departments along with user records.</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/ba-p/2282819</link>
      <description>&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;Many a times we integrate LDAP with servicenow and does not get all the information required for reference fields like 'location' and 'department' on 'sys_user' table from LDAP itself. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;We are then left with the option to load these information from another spreadsheet and then associate it with user records which is sometime a painful task. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;Recently we happened to work on LDAP integration with one of the customer. Good thing &amp;nbsp; we noticed while doing this integration is that their user object attributes were really defined nicely and contained a lot of information rather than the basic attributes like samAccountName, firstName etc.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;We found user object was containing information related to locations (attributes like 'c' for country, 'st' for state, 'physicaldeliveryofficename' for city and 'streetaddress' for street address. Similar thing we noticed about department information also. So we thought to leverage those attributes, import location and department details to their respective tables and associate them to user record along with loading user information from LDAP. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;I had to write certain amount of code but it paid well and we could load locations and department details with no issue. So sharing the same with you, so that you can use it with &lt;STRONG&gt;little bit modification&lt;/STRONG&gt; if required after analyzing location attributes completely.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt;You will require to paste this code into 'onBefore' transform map of LDAP. Code will take care to import locations and department details.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_14386015725094908 jive_macro_code" jivemacro_uid="_14386015725094908"&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 12pt;"&gt; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;//gs.log('Deepak: xform User ' + source.u_givenname + ' ' + source.u_sn + ' in country: &amp;nbsp; ' + &lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; //source.u_c + ' With complete address ' + source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st + ', ' + source.u_c);&lt;BR /&gt;if(source.u_c != '')&lt;BR /&gt;{&lt;BR /&gt; var country = new GlideRecord('cmn_location');&lt;BR /&gt; country.addQuery('name',source.u_c); //look for country assoicated with current user record being imported&lt;BR /&gt; country.addQuery('company','a4e3e06a37014200cb18341643990e39');// query a record in domain separated environment associated with company&lt;BR /&gt; country.query();&lt;BR /&gt; var countryCount = 0;&lt;BR /&gt; if(country.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var countrySysID = country.sys_id; // if exists, then store sys_id to variable. Lateron, it will be used to set as parent for state&lt;BR /&gt; &amp;nbsp; countryCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist country' + ' ' &amp;nbsp; + countryCount + ' ' + source.u_c );&lt;BR /&gt; }&lt;BR /&gt; else if(countryCount == 0)&lt;BR /&gt; {&lt;BR /&gt; //gs.log('Deepak: ' + 'We need to insert new Country ' + source.u_c);&lt;BR /&gt; var countryNew = new GlideRecord('cmn_location');&lt;BR /&gt; countryNew.initialize();&lt;BR /&gt; countryNew.name = source.u_c;&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; countryNew.company = 'a4e3e06a37014200cb18341643990e39'; // associate location to company in domain separated environment. simply comment it out if you dont have domain separation setup&lt;BR /&gt; var countrySysID = countryNew.insert(); // if does not exists, then insert new contry and store sys_id to variable, use it to set as parent for state&lt;BR /&gt; //gs.log('Deepak: new country inserted ' + countryNew.name + ' ' + countrySysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;if(source.u_st != '')&lt;BR /&gt;{&lt;BR /&gt; var state = new GlideRecord('cmn_location');&lt;BR /&gt; state.addQuery('name',source.u_st); &lt;BR /&gt; state.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; state.query();&lt;BR /&gt; var stateCount = 0;&lt;BR /&gt; if(state.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var stateSysID = state.sys_id;&lt;BR /&gt; &amp;nbsp; stateCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist state ' + stateCount + ' ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(stateCount == 0)&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; gs.log('Deepak: ' + 'We need to insert new state');&lt;BR /&gt; &amp;nbsp; var stateNew = new GlideRecord('cmn_location');&lt;BR /&gt; &amp;nbsp; stateNew.initialize();&lt;BR /&gt; &amp;nbsp; stateNew.name = source.u_st;&lt;BR /&gt; &amp;nbsp; stateNew.state = source.u_st;&lt;BR /&gt; &amp;nbsp; stateNew.parent = countrySysID;&lt;BR /&gt; &amp;nbsp; stateNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; &amp;nbsp; var stateSysID = stateNew.insert();&lt;BR /&gt; //gs.log('Deepak: new state inserted ' + stateNew.name + ' ' + stateSysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;if(source.u_physicaldeliveryofficename != '')&lt;BR /&gt;{&lt;BR /&gt; var city = new GlideRecord('cmn_location');&lt;BR /&gt; city.addQuery('name',source.u_physicaldeliveryofficename);&lt;BR /&gt; city.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; city.query();&lt;BR /&gt; var cityCount = 0;&lt;BR /&gt; if(city.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var citySysID = city.sys_id;&lt;BR /&gt; &amp;nbsp; cityCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist city ' + cityCount + ' ' + source.u_physicaldeliveryofficename);&lt;BR /&gt; }&lt;BR /&gt; else if(cityCount == 0)&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; gs.log('Deepak: ' + 'We need to insert new city');&lt;BR /&gt; &amp;nbsp; var cityNew = new GlideRecord('cmn_location');&lt;BR /&gt; &amp;nbsp; cityNew.initialize();&lt;BR /&gt; &amp;nbsp; cityNew.name = source.u_physicaldeliveryofficename;&lt;BR /&gt; &amp;nbsp; cityNew.city = source.u_physicaldeliveryofficename;&lt;BR /&gt; &amp;nbsp; cityNew.state = source.u_st;&lt;BR /&gt; &amp;nbsp; cityNew.parent = stateSysID;&lt;BR /&gt; &amp;nbsp; cityNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; &amp;nbsp; var citySysID = cityNew.insert();&lt;BR /&gt; //gs.log('Deepak: new city inserted ' + cityNew.name + ' ' + citySysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;if(!(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st == '')) // if all address related attributes are not blank, then evaluate other things.&lt;BR /&gt;{&lt;BR /&gt; var address = new GlideRecord('cmn_location');&lt;BR /&gt; if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_physicaldeliveryofficename + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; address.addQuery('name',source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress );&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_physicaldeliveryofficename );&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; address.addQuery('name',source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename );&lt;BR /&gt; }&lt;BR /&gt; address.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; address.query();&lt;BR /&gt; var addressCount = 0;&lt;BR /&gt; if(address.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var addressSysID = address.sys_id;&lt;BR /&gt; &amp;nbsp; target.location = addressSysID;&lt;BR /&gt; &amp;nbsp; target.company = 'a4e3e06a37014200cb18341643990e39' ;&lt;BR /&gt; &amp;nbsp; addressCount++;&lt;BR /&gt; //gs.log('Deepak: Already exist address' + addressCount + ' ' + source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st);&lt;BR /&gt; }&lt;BR /&gt; else if(addressCount == 0)&lt;BR /&gt; {&lt;BR /&gt; //gs.log('Deepak: ' + 'We need to insert new address');&lt;BR /&gt; var addressNew = new GlideRecord('cmn_location');&lt;BR /&gt; addressNew.initialize();&lt;BR /&gt; if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename + ', ' + source.u_st ;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_physicaldeliveryofficename + ', ' + source.u_st;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_st;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st != '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress + ', ' + source.u_st;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename == '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress ;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress == '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_physicaldeliveryofficename;&lt;BR /&gt; }&lt;BR /&gt; else if(source.u_streetaddress != '' &amp;amp;&amp;amp; source.u_physicaldeliveryofficename != '' &amp;amp;&amp;amp; source.u_st == '')&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; addressNew.name = source.u_streetaddress + ', ' + source.u_physicaldeliveryofficename;&lt;BR /&gt; }&lt;BR /&gt; addressNew.street = source.u_streetaddress;&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; addressNew.parent = citySysID;&lt;BR /&gt; addressNew.city = source.u_physicaldeliveryofficename;&lt;BR /&gt; addressNew.state = source.u_st;&lt;BR /&gt; addressNew.zip = source.u_postalcode;&lt;BR /&gt; addressNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; var addressSysID = addressNew.insert();&lt;BR /&gt; target.location = addressSysID; // location field visisble in user record in combination of streetaddress, physicaldeliery address(city) and state&lt;BR /&gt; target.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; //gs.log('Deepak: new address inserted ' + addressNew.name + ' ' + addressSysID);&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;//Load Department details also along with user records.&lt;BR /&gt;if(source.u_department != '') //if department is not null&lt;BR /&gt;{&lt;BR /&gt; var depart = new GlideRecord('cmn_department');&lt;BR /&gt; depart.addQuery('name',source.u_department);&lt;BR /&gt; depart.addQuery('company','a4e3e06a37014200cb18341643990e39');&lt;BR /&gt; depart.query();&lt;BR /&gt; var departCount = 0;&lt;BR /&gt; if(depart.next())&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp; var departSysID = depart.sys_id;&lt;BR /&gt; &amp;nbsp; target.department = departSysID;&lt;BR /&gt; &amp;nbsp; departCount++;&lt;BR /&gt; }&lt;BR /&gt; else if(departCount == 0)&lt;BR /&gt; {&lt;BR /&gt; //gs.log('Deepak: ' + 'We need to insert new depart');&lt;BR /&gt; &amp;nbsp; var departNew = new GlideRecord('cmn_department');&lt;BR /&gt; &amp;nbsp; departNew.initialize();&lt;BR /&gt; &amp;nbsp; departNew.name = source.u_department;&lt;BR /&gt; &amp;nbsp; departNew.company = 'a4e3e06a37014200cb18341643990e39';&lt;BR /&gt; &amp;nbsp; var departSysID = departNew.insert();&lt;BR /&gt; &amp;nbsp; target.department = departSysID;&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Aug 2015 11:39:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/ba-p/2282819</guid>
      <dc:creator>Deepak Ingale1</dc:creator>
      <dc:date>2015-08-03T11:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: LDAP Integration - Load Locations and Departments along with user records.</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282820#M727</link>
      <description>&lt;P&gt;I am wondering if LDAP 'Departments' could be done separately &amp;nbsp; in a 'Scheduled Import/Load' like &amp;nbsp; 'LDAP User Import' and LDAP Group Import'. I know they have 'OU's defined. Is it possible or easy task to define an 'OU' for 'Department' in LDAP?. &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Mar 2016 22:15:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282820#M727</guid>
      <dc:creator>tantony</dc:creator>
      <dc:date>2016-03-03T22:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: LDAP Integration - Load Locations and Departments along with user records.</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282821#M728</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;Im trying to map the country field directly form the ldap source table to user (target table) through transform maps. But the country is not been set in the location table there by users have their country field empty.&lt;/P&gt;
&lt;P&gt;Can some one please help.&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;
&lt;P&gt;Sivaranjani.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 07:32:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282821#M728</guid>
      <dc:creator>sivaranjani3</dc:creator>
      <dc:date>2016-03-04T07:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: LDAP Integration - Load Locations and Departments along with user records.</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282822#M729</link>
      <description>&lt;P&gt;Hi Tessy,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I dont see any reason why you cannot load like users and groups if deparments are stored in other OU.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Solution posted here is applicable if "department" is listed as one of the attribute against User object.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Mar 2016 10:11:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282822#M729</guid>
      <dc:creator>Deepak Ingale1</dc:creator>
      <dc:date>2016-03-04T10:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: LDAP Integration - Load Locations and Departments along with user records.</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282823#M730</link>
      <description>&lt;P&gt;If I remember, country is presented by "c" attribute.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Check if the attribute name is same in your case or it is different.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Mar 2016 10:12:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282823#M730</guid>
      <dc:creator>Deepak Ingale1</dc:creator>
      <dc:date>2016-03-04T10:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: LDAP Integration - Load Locations and Departments along with user records.</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282824#M731</link>
      <description>&lt;P&gt;Can this be written as a series of Script Include scripts?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 18:39:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282824#M731</guid>
      <dc:creator>MGanon</dc:creator>
      <dc:date>2019-04-26T18:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: LDAP Integration - Load Locations and Departments along with user records.</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282825#M732</link>
      <description>&lt;P&gt;You can do it in LDAPUser import transform map scripts(like onBefore,onAfter etc)or in field map scripts for individual fields like Department or Location&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 19:45:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-blog/ldap-integration-load-locations-and-departments-along-with-user/bc-p/2282825#M732</guid>
      <dc:creator>tantony</dc:creator>
      <dc:date>2019-04-26T19:45:42Z</dc:date>
    </item>
  </channel>
</rss>

