List users in a group

	

	IInfoStore boInfoStore = null;
	IInfoStore boInfoStore2 = null;
	IInfoObject boIInfoObject = null;
	IInfoObject boIInfoObject2 = null;
	IInfoObjects boInfoObjects = null;
	IInfoObjects boInfoObjects2 = null;
	SDKException sdkException = null;
	IEnterpriseSession boEnterpriseSession = null;
	IPluginMgr boPluginMgr;
	IPluginInfo boPluginInfo;
	IUser boCurUser = null;
	IUserGroup boGroup = null;
	IUserAliases allias = null;

boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(
					USERNAME, PASSWORD, SERVER, AUTHTYPE);
			boInfoStore = (IInfoStore) boEnterpriseSession.getService("",
					"InfoStore");
	boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(
					USERNAME, PASSWORD, SERVER, AUTHTYPE);
			boInfoStore = (IInfoStore) boEnterpriseSession.getService("",
					"InfoStore");

public String[] listUsersinGroup(String groupName) {
		String[] userList = new String[1000];
		int arrLoc = 0;
		try {

			logger.debug("list users in group  " + groupName);

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

			boInfoObjects = boInfoStore
					.query("Select TOP 20000 SI_NAME, SI_ID, SI_GROUP_MEMBERS from CI_SYSTEMOBJECTS where SI_PROGID = 'CrystalEnterprise.UserGroup' and SI_NAME = '"
							+ groupName + "'");
			
			boGroup = (IUserGroup) boInfoObjects.get(0);
			java.util.Set users = (java.util.Set) boGroup.getUsers();

			for (int i = 0; i < users.size(); i++) {
				boInfoObjects2 = boInfoStore
						.query("Select TOP 20000 SI_ID, SI_NAME, SI_USERFULLNAME, SI_EMAIL_ADDRESS From "
								+ "CI_SYSTEMOBJECTS Where SI_PROGID='CrystalEnterprise.User' AND SI_ID="
								+ users.toArray()[i] + "");
				boIInfoObject2 = (IInfoObject) boInfoObjects2.get(0);
				boCurUser = (IUser) boIInfoObject2;
				
				userList[arrLoc] = boCurUser.getTitle();
				
				arrLoc++;
			}
			return userList;

		} catch (SDKException e) {
			logger.error("Exception to list users in group  " + groupName + e);
		}
		return userList;
	}

Leave a Reply

Your email address will not be published. Required fields are marked *