Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

users/groups having access to a BO universe

Hey,

How do i get the users/groups having access to a universe using BOXI3 SDK ?

I could list the universes using IUniverse class and

also users/groups using IUser and IUserGroups.

but i coudnt get the relation between the universe and groups/users ?

Thanks

A.

Tags:
Former Member
Former Member replied

Hi,

Below is the sample code to check rights of usergroups on universe using Java SDK:

<%@ page import="java.util.*,

com.crystaldecisions.sdk.exception.SDKException,

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

com.crystaldecisions.sdk.framework.*,

com.crystaldecisions.sdk.plugin.desktop.report.CeReportRightID,

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

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

java.sql.*"%>

<%@ page import="java.lang.*"%>

<%@ page import="com.crystaldecisions.sdk.plugin.desktop.universe.*"%>

<table border="1">
<th>Universe Name</th>
<th>UserGroup Name</th>
<th>Rights</th>
<%
    String userName = "Administrator";
    String password = "Secure09";
    String cmsName ="localhost:6400";
    String cmsAuthType ="secEnterprise";
    IInfoObject user;
    IEnterpriseSession  es = null;
    IInfoObject universe;
    String rights;
    try
    {
        es = CrystalEnterprise.getSessionMgr().logon( userName, password, cmsName, cmsAuthType);
   
        IInfoStore iStore = (IInfoStore)es.getService("", "InfoStore");
        //Code to query for the user to test access rights.
        String query = "SELECT  * FROM CI_SYSTEMOBJECTS WHERE  SI_kind='UserGroup'";
        IInfoObjects infoobjects = iStore.query(query);
        String uniQuery = "SELECT * FROM  CI_APPOBJECTS WHERE SI_Kind='Universe'";
        IInfoObjects universes = iStore.query(uniQuery);
        for(int i=0;i<universes.size();i++)
        {
       universe = (IInfoObject)universes.get(i);
     String universeName=universe.getTitle();
     out.println("<tr><td>" +universe.getTitle()+ "</td>");
     for(int j=0;j<infoobjects.size();j++)
     {
             user = (IInfoObject) infoobjects.get(j);
             String userGroupName=user.getTitle();
             out.println("<td>" +userGroupName + "</td>");
               
             ISecurityInfo2 universeSecInfo = universe.getSecurityInfo2();
             IEffectivePrincipal ePrincipal=universeSecInfo.getAnyPrincipal(user.getID());
                        IEffectiveRights eRights=ePrincipal.getRights();
                        Iterator it=eRights.iterator();
                        if((!it.hasNext()))
                        {
                         out.println("<td>False</td>");
                        }
                        else
                        {
              out.println("<td>True</td></tr>");
                        }
            out.print("<tr><td></td>");
            }
       }
    }
    catch(SDKException e)
    {
       out.println(e.getMessage());
    }
    finally
    {
        es.logoff();
   
    }
%>
</table>

For your reference, below is the sample code to list all users having access to universe using Java SDK:

<%@ page import="java.util.*,
com.crystaldecisions.sdk.exception.SDKException,
com.crystaldecisions.sdk.occa.infostore.*,
com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.plugin.desktop.report.CeReportRightID,
com.crystaldecisions.sdk.plugin.desktop.user.*,
com.crystaldecisions.sdk.plugin.desktop.usergroup.*,
java.sql.*"%>
<%@ 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"%>

<%

    String userName = "Administrator";
    String password = "";
    String cmsName ="localhost:6400";
    String cmsAuthType ="secEnterprise";

IInfoObject user;
IInfoObject folder;
String rights;


HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow rowhead = sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("User");
rowhead.createCell((short) 1).setCellValue("Universe Name");
rowhead.createCell((short) 2).setCellValue("Rights");
 
int index=1;

    try
    {
        IEnterpriseSession  es = CrystalEnterprise.getSessionMgr().logon( userName, password, cmsName, cmsAuthType);
        //session.setAttribute( "enterpriseSession", es );
     IInfoStore iStore = (IInfoStore)es.getService("", "InfoStore");

//Code to query for the user to test access rights.


/*

String query = "SELECT  * FROM CI_SYSTEMOBJECTS WHERE  SI_kind='User'";
  IInfoObjects infoobjects = iStore.query(query);
  String folderQuery = "SELECT  * FROM CI_INFOOBJECTS, ci_systemobjects, ci_appobjects WHERE SI_Kind='universe'";
 
  */

  String query = "SELECT  * FROM  ci_systemobjects WHERE  SI_kind='user'";
  IInfoObjects infoobjects = iStore.query(query);
  String folderQuery = "SELECT  * FROM ci_appobjects WHERE SI_Kind='universe'";
  IInfoObjects folders = iStore.query(folderQuery);
  // out.print(infoobjects.size() + "<br>" + folders.size());
  for(int i=0;i<infoobjects.size();i++)
  {
   for(int j=0;j<folders.size();j++)
   {
    user = (IInfoObject) infoobjects.get(i);
    String username=user.getTitle();
    out.println("<b>User :</b>" +username);
    out.println("<br>");
    folder = (IInfoObject)folders.get(j);
    String folderName=folder.getTitle();
    out.println("<b>Universe Name :</b>" +folder.getTitle());
    out.println("<br>");
   
    ISecurityInfo2 folderSecInfo = folder.getSecurityInfo2();
    IEffectivePrincipals ePrincipals=folderSecInfo.getEffectivePrincipals();
    IEffectivePrincipal ePrincipal=ePrincipals.get(user.getID());
    if(ePrincipal !=null)
    {
    IEffectiveRights eRights=ePrincipal.getRights();
    if(eRights != null)
    {
    Iterator it=eRights.iterator();
    out.println("<b>Rights :</b><br>");
    if((!it.hasNext()))
    {
     out.println("No Rights on this folder!!!!<br>");
    }
    else
    {
   
    HSSFRow row = sheet.createRow((short)index);
    row.createCell((short) 0).setCellValue(username);
    row.createCell((short) 1).setCellValue(folderName);
     while(it.hasNext())
     {
      rights=it.next().toString();
      out.print(rights);
      out.println("<br>");
      HSSFRow row1 = sheet.createRow((short)index);
      row1.createCell((short) 2).setCellValue(rights);
      index++;
     }
    }
   }
   }
   }
   out.println("<br>");
   out.println("****");
   out.println("<br>");
  }
}
catch(SDKException e)
    {
       out.println(e.getMessage());
    }
finally
{
  FileOutputStream fileOut = new FileOutputStream("c:\\Raj.xls");
  wb.write(fileOut);
  fileOut.close();
  out.println(" Excel file created successfully");

}
%>

Hope it helps.

Regards,

Anchal

2 View this answer in context
Not what you were looking for? View more on this topic or Ask a question