Hello Experts,
The following code pulls User Name and Authentication Type from CI_SYSTEMOBJECTS. I want to add three more fields in to it, but I've not been successful. I need expert help to add these 3 fields in this script, those fields are:
si_creation_time, si_lastlogontime, si_update_ts
and I'm expecting the data in this order in excel:
si_name, type, si_creation_time, si_lastlogontime, si_update_ts
Also, I wanted this script to dynamically pull all users (in above format) who are disabled and have not logged in to BOEXI for more than 365 days. Is that even possible? The dynamic query that I'm expecting should look like this:
users = infoStore.query("SELECT TOP 10000 STATIC " + " FROM CI_SYSTEMOBJECTS " + " WHERE SI_KIND='User' " + " AND SI_UPDATE_TS > '1 year'")
Below is the working script which pulls user name and authentication type:
<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@ page import="java.io.*" %>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFPrintSetup"%>
<%@ page import = "com.businessobjects.sdk.plugin.desktop.common.*,
com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.plugin.*,
com.crystaldecisions.sdk.plugin.desktop.user.*,
com.crystaldecisions.sdk.occa.infostore.*,
com.crystaldecisions.sdk.exception.SDKException,
java.util.*"%>
<%
String cmsname = null;
String username = null;
String password = null;
cmsname = "bocms:6400";
username = "boadmin";
password = "bo@dmin";
out.println("<b><u><h1><center>Disabled Report</h1></u></b></center> </br></br>");
if(username == null) {
%>
<html>
<body>
<form method=post>
<h4>Enter BusinessObjects Enterprise Administrator credentials</h4>
<table>
<tr><td>CMS Name:</td><td><input type="text" name="cmsname" /></td></tr>
<tr><td>User:</td><td><input type="text" name="username" value="Administrator" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="password" /></td></tr>
<tr><td></td><td><input type="Submit" value="Logon" ></td></tr>
</table>
</form>
</body>
</html>
<%
} else {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Disabled users");
HSSFRow rowhead = sheet.createRow((short)2);
rowhead.createCell((short) 0).setCellValue("#");
rowhead.createCell((short) 1).setCellValue("User name");
rowhead.createCell((short) 2).setCellValue("Type");
int index=3;
int j =1;
IEnterpriseSession boSession = null;
try {
IInfoStore infoStore;
/*
* Log onto Enterprise and retrieve the InfoStore CMS query service
*/
boSession = CrystalEnterprise.getSessionMgr().logon(username, password, cmsname, "secEnterprise");
infoStore = (IInfoStore)boSession.getService("", "InfoStore");
for(int i=0;i<1;i++){
int x=1;
IInfoObjects users;
users = infoStore.query("SELECT TOP 10000 STATIC " + " FROM CI_SYSTEMOBJECTS " + " WHERE SI_KIND='User' "
/* I want to change the query to something like this one: */
/*users = infoStore.query("SELECT TOP 10000 STATIC " + " FROM CI_SYSTEMOBJECTS " + " WHERE SI_KIND='User' " + " AND SI_UPDATE_TS > '1 year'");*/
if(users.size() == 0)
{ break; }
for(Iterator iuser = users.iterator() ; iuser.hasNext() ; )
{
IUser user;
IUserAliases userAliases;
boolean isdis;
user = (IUser) iuser.next();
userAliases = user.getAliases();
isdis=false;
for(Iterator ialias = userAliases.iterator() ; ialias.hasNext() ; )
{
IUserAlias userAlias;
userAlias = (IUserAlias) ialias.next();
String authtype= userAlias.getAuthentication();
if(userAlias.isDisabled())
{
out.println(x + "- <b>" + user.getTitle() + " = Disabled" + " Authentication=" + authtype + "</br></b>");
HSSFRow row = sheet.createRow((short)index);
row.createCell((short) 0).setCellValue(j);
row.createCell((short) 1).setCellValue(user.getTitle());
row.createCell((short) 2).setCellValue(authtype);
j++;
index++;
}
x++;
}
}
}
}
finally {
/*
* Ensure Enterprise logoff on exit.
*/
FileOutputStream fileOut = new FileOutputStream("C:\\tmp\\report.xls");
wb.write(fileOut);
fileOut.close();
out.println(" Excel file created successfully");
if(boSession != null) {
try{
boSession.logoff();
}catch(Exception e_ignore_logoff_exceptions) {}
} //if
} //finally
} //else
%>
Thanks for your great help!