Checking user group existence

	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 boolean checkGroupExistence(String groupName) {
		try {

			logger.debug("check group existence " + groupName);

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

			// Retrieve the user and group
			boInfoObjects = boInfoStore
					.query("SELECT TOP 20000 SI_ID, SI_NAME, SI_USERGROUPS FROM CI_SYSTEMOBJECTS Where SI_PROGID='CrystalEnterprise.UserGroup' AND SI_NAME = '"
							+ groupName + "'");

			Iterator<IUserGroup> iterator = boInfoObjects.iterator();

			while (iterator.hasNext()) {
				IUserGroup iusrGroup = (IUserGroup) iterator.next();

				if (groupName.equals(iusrGroup.getTitle())) {
					return true;
				} else {
					return false;
				}
			}
		} catch (SDKException e) {
			logger.error("Exception to check group existence " + groupName + e);
			
		}
		return false;
	}

Leave a Reply

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