cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Java code for user-wise report access list

Former Member
0 Likes
525

Dear All,

I have a very big requirement and I have no idea where to begin. I only have a limited experience with SAP BI's Java SDK and has mostly used it for just generating list of all reports with their folder path or list of all users in a group.

This time though I have a big ambition (or at least I think it would be a difficult one to pull off)

What I need

Is a list of all reports with all users who has access to it and the access level they have.

It needs to have following columns

Report Name, Full Report Path, User ID (and Name if possible), Access level

I am also trying to write a code for list of reports and the user groups that has to it.


What I have

I know how to retrieve the list of all reports and I know how to retrieve list of users. But what I don't know is how to connect them or to get the access level they have.

So if anyone can help me out, it would be great. It would be even more great if I could have a ready to use code! I know it is too much to ask, but as I said I am a novice to Java part and if you give me pieces, it would take me days to stitch em up and make a full code.

So if there are any kind ones out there, please help!

Thanks.


View Entire Topic
Former Member
0 Likes

Hi All,

Thank you for your quick and helpful answers. I did a little research on my own and made a lot of progress. Let me share the code I am using


<%@ page import = "com.crystaldecisions.sdk.exception.SDKException,

com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException,

com.crystaldecisions.sdk.framework.*,

com.crystaldecisions.sdk.occa.infostore.*,

com.crystaldecisions.sdk.occa.report.*,

com.crystaldecisions.sdk.properties.*,

com.crystaldecisions.sdk.occa.report.application.*,

com.crystaldecisions.sdk.occa.managedreports.*,

com.crystaldecisions.sdk.occa.report.data.*,

com.crystaldecisions.sdk.plugin.desktop.user.*,

java.util.*,

java.io.*"

%>

<%

  // User Credentials

  String username = "";

  String password = "";

  String cmsname  = "";

  String authType = "";

  IEnterpriseSession enterpriseSession = null;

  writeToLog("ReportObjectID"+"%"+"ReportName"+"%"+"ReportPath"+"%"+"User/UserGroup Name"+"%"+"User/UserGroup ID"+"%"+"AccessLevel Title"+"%"+"AccessLevel ID"+"%"+"Inherited/Explicit");

  // Log onto Enterprise

  enterpriseSession = CrystalEnterprise.getSessionMgr().logon(username, password, cmsname, authType);

  IInfoStore boInfoStore = (IInfoStore)enterpriseSession.getService("", "InfoStore");

  IInfoObjects infoObjects = boInfoStore.query("Select SI_ID from CI_INFOOBJECTS where SI_KIND = 'CrystalReport' OR SI_KIND = 'Webi'");

  for(int j=0; j<infoObjects.size();j++)

  {

  IInfoObject report = (IInfoObject)infoObjects.get(j);

  String path = getInfoObjectPath(report);

  String title = report.getTitle();

  String ReportObjectID = String.valueOf(report.getID());

  ISecurityInfo2 securityInfo = report.getSecurityInfo2();

  IEffectivePrincipals effectivePrincipals = securityInfo.getEffectivePrincipals();

  Iterator CurrentObject = effectivePrincipals.iterator();

  while (CurrentObject.hasNext())

  {

  IEffectivePrincipal effectivePrincipal = (IEffectivePrincipal)CurrentObject.next();

  IEffectiveRoles effectiveRoles = effectivePrincipal.getRoles();

  Iterator roleIT = effectiveRoles.iterator();

  while (roleIT.hasNext())

  {

  IEffectiveRole effectiveRole = (IEffectiveRole)roleIT.next();

  writeToLog(String.valueOf(ReportObjectID)+"%"+title+"%"+path+"%"+effectivePrincipal.getName()+"%"+String.valueOf(effectivePrincipal.getID())+"%"+effectiveRole.getTitle()+"%"+String.valueOf(effectiveRole.getID())+"%"+Boolean.valueOf(effectiveRole.isInherited()));

  }

  }

  }

  out.println("All Done");

%>

<%!

  public static String getInfoObjectPath(IInfoObject infoobject) throws SDKException

  {

  String path = "";

  while (infoobject.getParentID() != 0)

  {

  infoobject=infoobject.getParent();

  path = "/" + infoobject.getTitle() + path;

  }

  return path;

  }

<%!

  public void writeToLog(String msg)

  {

  try

  {

  // Set up Logging File

  FileOutputStream FSout;

  PrintStream pStream; // declare a print stream object

  FSout = new FileOutputStream("C:\\TestOutput2.csv", true);  // Append

  pStream = new PrintStream(FSout);

  pStream.println(msg);

  pStream.close();

  }

  catch (IOException e)

  {

  //error writing to log

  }

  }

%>

This pretty much does all that I wanted to accomplish. Thank you again for the help.

Regards