LDAPUtils
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2012 10:17 AM
I came across the LDAPUtils script and the setManager function in there.
setManager: function(source, target) {
var ge = source.getElement(this.manager);
if (!ge || ge.isNil())
return;
this._getLdapUserUpdate();
var ldap = new Packages.com.glide.sys.ldap.LDAPUserUpdate();
var mid = this.ldapUserUpdate.getManagerValue(target, ge.toString());
if (mid == null)
return;
target.manager = mid;
},
Can anyone please help me in understand the the lines after this._getLdapUserUpdate()..
Thanks,
Ravali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2012 10:18 AM
Like I mentioned earlier, it's mapping the Distinguished Name (DN) of the manager from LDAP to an actual user on the ServiceNow sys_user table.
http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol
http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Directory_structure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2024 03:49 PM
Misleading how you wrote your comments
if (mid == null) return; // if manager id is null, then you cannot set target user's manager value so exit
target.manager = mid; // manager id will like be a string, whereas manager is a reference to a user, but by // default, SN will coalesce from the string value to a user reference into sys_user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2012 10:36 AM
YUp I understand that.. the only doubt I had was whats 'mid'?
I am trying to see if null values from LDAP are getting updated in the user record. If the user record has null value in manager field, is the LDAP update overriding that null value when manager value in the LDAP gets updated?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2012 01:58 AM
ravali
the user's manager's sys_id, as retrieved from [em]sys_user.manager[/em] (or, other field as specified)
There is an allowance for the entry being NULL (empty), just in case the user record of the manager hasn't yet been created. It adds it to a list of user records to fix-up later on (when the processManagers() method of LDAPUtils, gets called by the LDAP User Import "onComplete" sys_transform_script)
So, yes, if the record does exist at the end of the import then the sys_user.manager reference should get filled in, when the sys_transform_script "onComplete" executes:
// It is possible that the manager for a user did not exist in the database when
// the user was processed and therefore we could not locate and set the manager field.
// The processManagers call below will find all those records for which a manager could
// not be found and attempt to locate the manager again. This happens at the end of the
// import and therefore all users should have been created and we should be able to
// locate the manager at this point
ldapUtils.processManagers();