Hi All,
We have a requirement to obtain the groups associated with a particular set of users and I have found the following query:
Select SI_ID, SI_NAME From CI_SYSTEMOBJECTS Where PARENTS("SI_NAME='UserGroup-User'","SI_NAME='Administrator'")
but the number of users in question is large and running this query for each user would be extremely time consuming.
I have modified one of the existing script with this query and would be grateful if someone could help with printing the results:
Code I have is as below and I am skeptical about the part highlight in bold red font:
---------------------------------------------------------------------------------------
/*
* Path to file containing User names.
*/
final String USER_FILE_PATH = "C://Userlist.txt";
IEnterpriseSession enterpriseSession;
enterpriseSession = null;
try
{
IInfoStore infoStore;
IInfoObjects newInfoObjects;
IInfoObject oInfoObject;
BufferedReader fin;
enterpriseSession = CrystalEnterprise.getSessionMgr().logon(BO_USER_NAME, BO_PASSWORD, BO_CMS_NAME, BO_AUTH_TYPE);
infoStore = (IInfoStore) enterpriseSession.getService("", "InfoStore");
fin = new BufferedReader(new FileReader(USER_FILE_PATH));
for(;;)
{
String username;
/* Read file for user name */
username = fin.readLine();
if(username == null)
{
break;
}
username = username.trim(); // Trim surrounding spaces.
out.println("User: " + username + "<BR>");
// Query to see if the user exists.
String boQuery = "Select SI_ID, SI_NAME From CI_SYSTEMOBJECTS Where PARENTS(\"SI_NAME='UserGroup-User'\",\"SI_NAME='+username+"'\")"
IInfoObjects boResults = (IInfoObjects)infoStore.query(boQuery);
if (!boResults.isEmpty())
{
IUser user = (IUser)boResults.get(0);
out.print("Groups of user : " + username + " <BR>");
out.print("<br>SI_ID: "+boResults.SI_ID+"<BR>SI_NAME: "+boResults.SI_NAME);
}
else
{
out.print("User " + username + " does not exists.<BR>");
}
}
fin.close();
}
Thanks a lot!
Regards,
Mihir