- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2015 09:32 AM
Greetings All,
I have written a script to delete those users whose Email, User ID, Ldap-Server is blank. Please let me know if it is ok.
var encodedQuery="emailISEMPTY^user_nameISEMPTY^ldap_serverISEMPTY"; // semicolon added
var gr = new GlideRecord("sys_user"); //error here " needed to be closed
gr.addEncodedQuery(encodedQuery);
gr.deleteMultiple();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2015 10:29 AM
If you do go with deactivating, rather than deleting, I'd do it through the UI:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2015 10:04 AM
Hi Shikha,
One step I would take would be to run this first, and check the rowcount printed out was the same as the number found in the list view.
var encodedQuery="emailISEMPTY^user_nameISEMPTY^ldap_serverISEMPTY"; // semicolon added
var gr = new GlideRecord("sys_user"); //error here " needed to be closed
gr.addEncodedQuery(encodedQuery);
//gr.deleteMultiple();
gs.log("row count = " + gr.getRowCount());
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2015 02:36 AM
Hi Tony,
I did check the row count before deleting the users with below script:
var encodedQuery="emailISEMPTY^user_nameISEMPTY^ldap_serverISEMPTY";
var gr = new GlideRecord("sys_user");
gr.addEncodedQuery(encodedQuery);
gr.query();
gs.print('total rows=='+gr.getRowCount());
and i got the same count 2083 users that i got while applying filters to user table.
I tried this on DEV instance and found everything okay. but i have 1 query, that some people on this post have suggested e to make those users deactive and not delete them. i need to understand, why i should not delete them.
my snow is integrated with AD through LDAP and in AD we have near about 5000 users and in SNOW we are having 9000 users through which it is obvious that 4000 users are those which we don't need.
So, i ran a filter and checked that there are 2083 users whose Emial, User-Id, Ldap-server is null as these three attributes are mapped with attributes of AD. So, i thought to delete these users as they are of no use.
Please suggest what shall i do?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2015 02:44 AM
Hey Shikha,
You can go and delete the users but any idea how they got in snow in the first place?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2015 02:57 AM
Hi Mujtaba,
Actually when our SNOW was not integrated with AD, the team added the users manually.
When it got integrated with AD users came from AD to SNOW on the basis of mapping of some attributes of AD and SNOW(e.g. Email, User ID, Location etc). so the team didn't delete the users that were added manually which caused the issue of Double profiles of users in SNOW.
That is why i wanted to remove these users.