- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 01:50 PM
Hi everyone,
I have a LDAP transform map to insert/update User records from AD. I need help with a script to not update Samaccountname field when the user is terminated (it may update any other fields if the user is terminated except Samaccountname). Please provide and ideas or script to acheive this scenario.
Thank you in advance,
Karthik
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 09:03 PM
Hello @Karthikpasikant
Please change the field mapping for Samaccountname to Script type like the one shown in below screenshot and use the script provided. If you have any different field names or logic to determine terminated accounts change the script accordingly.
answer = (function transformEntry(source, target, action) {
if (action === 'update') {
var ctrl = parseInt(source.u_useraccountcontrol, 10);
ctrl = ctrl.toString(16);
//Check if the user is terminated/disabled, if Yes, don not change the samaccount name
if (source.u_useraccountcontrol == '514' || ctrl.substr(-1) == "2") { //Generally this is how we identify terminated accounts, if you have any other conditions/logic you can use the same here.
return target.u_samaccountname;
}
return source.u_samaccountname;
}
return source.u_samaccountname;
})(source, target, action);
Please mark my answer helpful and accept as solution if it helped you ✔️👍
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 04:45 PM
Hi try like this
(function executeRule(current, previous /*, _source, _target*/) {
if (current.termination_status == 'terminated') {
current.setValue('samaccountname', previous.samaccountname);
} else {
current.setValue('displayname', 'New Display Name');
}
})(current, previous);
but please mention your field name correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 08:33 PM
Hi Harish,
Thanks for responding.
I am looking for something on the transform map itself.
If I write a BR then every 3 hours the LDAP schedule job runs and writes in to the field and again BR runs to set the value. This will go in loop and might not be a good idea. I hope you this make sense. Let me know if there is any way to do it on the transform map itself.
Thanks,
Karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 05:37 PM
What is the coalesce field you are using in field mapping?
In general, we map samaccountname to user_name field, are you mapping it to a different field?
Please let me know these 2, so that I can provide you a better solution.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 08:35 PM
Hi Anvesh,
Thanks for responding!
We are using Employee Number as coalesce field. Samaccoutname from AD is mapped to a custom field called Samaccountname on the User table.
Thanks,
Karthik