on 05-18-2016 11:39 AM
Hi Team,
We are currently on BI4.1 Sp3 and BI4.2, during our audit we found out 15K users(AD, SAP and enteprise users)who did not login in last 180 days, we would like to delete these users.
From the BI4.1 product we do not see any way to delete these users in bulk . Deleting users one by one is a very time consuming process.
Could you please let me know if there is already a Java script ( or .jar) which we can use a program object and schedule from BI4.x to delete these users in bulk ?
Regards,
Rohit Vamsi
You can use the attached code.
Change the query in the code to the one you have which gives you list of users who have not logged in for last 180 days. Currently the code has a query which brings all the users except Adminstrator and Guest, so make sure to change the query before you run it.
Save the file as .jsp extension and place it under AdminTools application.
Run the code by running the url
http://server:host/AdminTools/deleteUsers.jsp
Thanks,
Prithvi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prithvi,
When we are testing the code in test box we are getting http 500 error.
1. Modified the code to include user last logon condition, saved jsp in Admintools
2. Restarted tomcat and launched the URL https://xxxx:port/AdminTools/DeleteUsers.jsp
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prithviraj,
This is srini, part of rohit's team. We are trying to execute the below code and we are getting above error which rohit has mentioned.Can you please check the below code is correct or not. Please let us know if i miss any thing to add.
<%@ page import = "com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.exception.*,
com.crystaldecisions.sdk.occa.infostore.*,
com.crystaldecisions.sdk.plugin.desktop.user.*,
java.util.*";
%>
<%
IEnterpriseSession oEnterpriseSession=null
try
{
oEnterpriseSession = CrystalEnterprise.getSessionMgr().logon("username","wpassword","cms name","secEnterprise");
IInfoStore oInfoStore = (IInfoStore) oEnterpriseSession.getService("","InfoStore");
IInfoObjects userInfoObjects = oInfoStore.query ("select si_id,si_name from ci_systemobjects where si_kind='user' and SI_LASTLOGONTIME <=2015.01.01 and si_name not in ('Administrator','Guest')");
for(int i=0;i<userInfoObjects.size();i++)
{
IInfoObject userInfoObject=(IInfoObject)userInfoObjects.get(i);
IUser userObject=(IUser)userInfoObject;
userObject.deleteNow();
}
oInfoStore.commit(userInfoObjects);
}
catch(Exception e)
{
out.println(e);
}
finally
{
oEnterpriseSession.logoff();
}
%>
Appreciated for your prompt response.
Thanks & Regards
Srini
use below , in your code you have a ';' before closing the packages import statements.
<%@ page import = "com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.exception.*,
com.crystaldecisions.sdk.occa.infostore.*,
com.crystaldecisions.sdk.plugin.desktop.user.*,
java.util.*"
%>
Restart application server once and test.
Thanks,
Prithvi
Hi Prithvi,
Thanks for your prompt response.
The script is working fine.
When we are running with the https://xxxx:port/AdminTools/DeleteUsers.jsp. we are not getting any success or failed.
Is there any code to be implemented to show the the message like successfully completed..etc.
Thanks & Regards
Srini
You can put your comments in out.println().
In the code above if you want to display sucessful message, put and out.print after commint statement, something like
out.println("sucessfull");
Its best to write the name of all the users you are deleting in a log or print the usernames on the screen.
Hi Prithvi,
Thank you so much for your help on this script.
Could you please provide the code to display the deleted users and their deletion date in to excel or notepad..etc.?
I tried to put the below code however it seems to be not readable format.
out.println("userInfoObjects")
Thanks & Regards
Srini
You can do something like below.
for(int i=0;i<userInfoObjects.size();i++)
{
IInfoObject userInfoObject=(IInfoObject)userInfoObjects.get(i);
IUser userObject=(IUser)userInfoObject;
userObject.deleteNow();
out.println("User ID :"+userObject.getID()+"<br>User Name : "+ userObject.getTitle()+"<br>");
out.println("=====================================<br>");
}
Refer to the api guide for more details about the interfaces used. Guides available at help.sap.com
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.