LDAP Users Import to Update/Clear fields

Luiz Lucena
Mega Sage

Hi all, 

We are using LDAP to import users from AD into ServiceNow for a year now. Everything was looking fine.

We just released some service catalog items that requires manager approval and the issues are showing up now regarding LDAP user importing.

We have 2 different classes of users: regular employee and contractors. 
The manager field for contractors was always in blank for AD users, as they are managed in another internal system.

So, when we started using ServiceNow last year, a custom attribute was created in AD users account to have the approvals being directed correctly in ServiceNow to those contractor manager's.

The problem is that when a contractor is converted into regular employee, LDAP fills the Manager field with the current manager's name but is not clearing the custom field Contractor Manager. The approvals are being sent to the wrong person.

find_real_file.png

See above, both fields not empty. 

Below is the script to map the custom AD attribute to the custom field in ServiceNow:

find_real_file.png

 

Is there anything that could be done to have LDAP update users information correctly?

Was thinking in add the ELSE below, but not sure if will work.

Any clue?

answer = (function transformEntry(source) {
	if(source.u_atccontractormanager){
		var getManager = new GlideRecord('sys_user');
		if(getManager.get('user_name',source.u_atccontractormanager)){
			return getManager.sys_id;
		}else{
                   source.u_atccontractormanager = '';
                 }
	}
	return "";

})(source);
11 REPLIES 11

Coleton
Kilo Guru

I would probably just create a before BR (Business Rule) that says if the Manager field changes from empty, clear out the Contractor Manager field. Should be a simple fix since the AD object won't have a true value for the custom attribute.

Would you do that on the User [sys_user] table or the Ldap Import table?

The sys_user table since you're trying to clear the value from a user record when the import happens.

Not sure how to do that, the condition is waiting for user name and is not accepting the NULL as value when it changes from empty to anything else.

find_real_file.png

 

Don't know how to do this using script.