on 02-07-2011 10:26 AM
Hello,
is there a Crystal Reports function that would return list of BusinessObjects groups logged user belongs to ? (I mean the BusinessObjects groups assigned to user in CMC).
Example: I need to conditionally supress objects based on user's groups - if he belongs to group AAA, he can see certain object on a report, otherwise he can't.
If there's by default no such a function (which I'm afraid is the case), can a custom Java based function be created using BusinessObjects SDK ? Anyone did that, has the code and is willing to share it ? Or, is there a better workaround ?
Thanks,
Jakub
JSP code continued from previous post:
if (setUserGroups.size() == 0)
{
out.println("There are no user groups that the user " + retrieveUserName + " belongs to.<br \\>");
}
else
{
Iterator iter = setUserGroups.iterator();
// To store the group ID.
Object groupID = null;
// To store the group name.
String groupName = null;
while (iter.hasNext())
{
groupID = iter.next();
// Get the name of the group.
queryGroupString = "SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_KIND = 'UserGroup' AND SI_ID = '" + groupID + "'";
// Execute the query of the InfoStore.
boGroupInfoObjects = boInfoStore.query(queryGroupString);
// Retrieve the first entry.
boGroupInfoObject = (IInfoObject) boGroupInfoObjects.get(0);
// Get the group name.
groupName = boGroupInfoObject.getTitle();
// Print out the ID aqnd name of the group.
out.println("The ID of the group is " + groupID + " and the name of the group is " + groupName + ".<br \\>");
}
}
}
else
{
out.println("A query of the InfoStore for the user returned 0 InfoObjects.<br \\>");
}
}
else
{
out.println("A query of the InfoStore for the user returned null.<br \\>");
}
}
catch (Exception ex)
{
// Set the message to be displayed to the user to indicate that an
// error has occurred and display the error message.
out.println("An error was encountered. A description of the error"
+ " is as follows: " + ex.toString());
// Log the error and the stack trace to the system out log file
System.out.println("An error was encountered. A description of the "
+ "error is written below:");
System.out.println(ex);
System.out.println("The stack trace for the error is written below:");
ex.printStackTrace(System.out);
}
// If the logon was previously successful, then logoff.
if (boEnterpriseSession != null)
{
boEnterpriseSession.logoff();
}
%>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is an undocumented Business Objects query function that may help you with this, too. But again, this is undocumented, so use at your own risk. It does work, I just can't gurantee that it'll be around in future versions of BOE, and this may be unsupported by SAP support.
The relevant query is:
SELECT SI_ID, SI_NAME FROM CI_SYSTEMOBJECTS WHERE SI_KIND='UserGroup' AND SELECTUSINGPROPERTY(<SI_ID of user>,SI_ID,SI_USERGROUPS,SI_ID)
This query will return the names and SI_IDs of all groups to which the user belongs.
HTH.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot, gonna try.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am attaching the contents of a jsp file here that will log a user onto the Enterprise and for an enter user name, will retrieve and display the Group IDs and Group Names that the user belongs to. I will attach the contents of the jsp over the next two posts because all of the contents will not fit into a single post.
Here is the contents;
<%
/*************************** GetUserGroups.jsp ********************************
*
* This jsp will log the user onto the Enterprise, retrieve a user InfoObject
* based on a user name, then retrieve the groups that the user belongs
* to, and then print out the group IDs and names.
*
*****************************************************************************/
%>
<%@ page import = "com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.occa.infostore.IInfoStore,
com.crystaldecisions.sdk.occa.infostore.IInfoObject,
com.crystaldecisions.sdk.occa.infostore.IInfoObjects,
com.crystaldecisions.sdk.framework.IEnterpriseSession,
com.crystaldecisions.sdk.plugin.desktop.user.*,
java.util.*"
%>
<%
// Declarations
// Business Object Declarations.
IEnterpriseSession boEnterpriseSession = null;
ISessionMgr boSessionMgr = null;
IInfoStore boInfoStore = null;
IInfoObjects boUserInfoObjects = null;
IInfoObject boUserInfoObject = null;
IUser boUser = null;
IInfoObjects boGroupInfoObjects = null;
IInfoObject boGroupInfoObject = null;
// To store the collection of user groups that the user is a part of.
Set setUserGroups = null;
// To store the ID of the report that we are querying for
String retrieveUserName = "<Enter the name of the user that you want to determine the groups that the user belongs to here>";
// Logon Information
String logonUserName = "<Enter Enterprise logon User Name here>";
String password = "<Enter Password Here>";
String cmsName = "<Enter CMS Name Here>";
String authType = "<Enter Authentication Type Here - eg. secEnterprise>";
String queryUserString = null;
String queryGroupString = null;
// Try block that will catch an Exception.
try
{
// Initialize the Session Manager by getting it from the Crystal Enterprise
// class's getSessionMgr function.
boSessionMgr = CrystalEnterprise.getSessionMgr();
// Logon to the Session Manager to create a new BOE session. Pass in the
// user name, password, the CMS name, and the authentication
// type.
boEnterpriseSession = boSessionMgr.logon(logonUserName, password, cmsName, authType);
//Retrieve the InfoStore object
boInfoStore = (IInfoStore) boEnterpriseSession.getService("", "InfoStore");
// Set up the query string.
queryUserString = "SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_KIND = 'User' AND SI_NAME = '" + retrieveUserName + "'";
// Execute the query of the InfoStore.
boUserInfoObjects = boInfoStore.query(queryUserString);
if (boUserInfoObjects != null)
{
// A query of the InfoStore did not return null.
if (boUserInfoObjects.size() != 0)
{
// A query of the InfoStore returned at least one InfoObject.
// Retrieve the first entry.
boUserInfoObject = (IInfoObject) boUserInfoObjects.get(0);
// Cast the User Info Object to IUser so that we can retrieve the groups that the
// user is a part of.
boUser = (IUser) boUserInfoObject;
// Retrieve the collection of user groups that the user belongs to.
setUserGroups = boUser.getGroups();
// Print out the user groups that the user belongs to.
out.println("The IDs and names of the user groups that the user " + retrieveUserName + " belongs to are:<br \\>");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the Java Enterprise SDK, there is a class called IUserBase that has a function called getGroups() that returns a collection of groups that the user belongs to. So if you wrote a custom java application that returns you the user that you are interested in, you could use the getGroups() function to return you the Groups that the user belongs to.
Regards.
- Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.