Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member217391
Discoverer
0 Kudos
1,833

Note: Only for BO Administrators.

Removal and addition of BO users from BO groups can be lot easier if carried out using the SDK.

the code below can be used for JAVA SDK to remove multiple users from multiple/single group.

package com.deloitte.bo.GroupUserRemoval;

import com.crystaldecisions.sdk.exception.SDKException;

import com.crystaldecisions.sdk.framework.CrystalEnterprise;

import com.crystaldecisions.sdk.framework.IEnterpriseSession;

import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;

import com.crystaldecisions.sdk.occa.infostore.IInfoStore;

import com.crystaldecisions.sdk.plugin.desktop.user.IUser;

import com.crystaldecisions.sdk.plugin.desktop.usergroup.IUserGroup;

public class UserRemovalFromGroupAPI {

  public static void main(String[] args) throws Exception {

  // Set the logon information

  String boUser = "Administrator";

  String boPassword = "*****";

  String boCmsName = "SYSTEM";

  String boAuthType = "secEnterprise";

  // Declare Variables

  IInfoStore boInfoStore = null;

  IInfoObjects boInfoObjects = null;

  IEnterpriseSession boEnterpriseSession = null;

  try {

  // Logon and obtain an Enterprise Session

  boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(

  boUser, boPassword, boCmsName, boAuthType);

  boInfoStore = (IInfoStore) boEnterpriseSession.getService("",

  "InfoStore");

  boInfoObjects = boInfoStore

  .query("SELECT * FROM CI_SYSTEMOBJS WHERE SI_PROGID='CrystalEnterprise.USERGROUP' AND SI_NAME in('GROUP_NAME','GROUP_NAME_2')");

  IInfoObjects boInfoObjectUsers =  

  boInfoStore

  .query("SELECT SI_ID From CI_SYSTEMOBJECTS Where SI_PROGID='CrystalEnterprise.User' and SI_NAME in ('USER_1','USER_2')");

  for(int boGroupIterator =0; boGroupIterator < boInfoObjects.size(); boGroupIterator++){

  IUserGroup boGroup = (IUserGroup)boInfoObjects.get(boGroupIterator);

  for(int boUserIterator =0; boUserIterator< boInfoObjectUsers.size(); boUserIterator++){

  IUser boCurUser = (IUser) boInfoObjectUsers.get(boUserIterator);

  System.out.println("Removing user " + boCurUser.getTitle() +  " from group " + boGroup.getTitle());

  boGroup.getUsers().remove(new Integer(boCurUser.getID()));

  }

  }

  // Commit the changes to the InfoStore.

  boInfoStore.commit(boInfoObjects);

  } catch (SDKException e) {

  System.out.println(e.getMessage());

  } finally {

  boEnterpriseSession.logoff();

  }

  }

}

Labels in this area