Setting user aliases

	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 void setUserAliases(String userName, boolean status) {
		try {

			logger.debug("set user aliases " + userName + status);

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

			IUserAliases allias = null;

			boInfoObjects = boInfoStore
					.query("Select * from CI_SYSTEMOBJECTS where SI_PROGID = 'CrystalEnterprise.User' and SI_NAME = '"
							+ userName + "'");

			allias = ((IUser) boInfoObjects.get(0)).getAliases();
			Iterator<IUserAlias> iterator = allias.iterator();
			while (iterator.hasNext()) {
				IUserAlias iUserAlias = (IUserAlias) iterator.next();
				iUserAlias.setDisabled(status);
				boInfoStore.commit(boInfoObjects);
			}
			
			

		} catch (SDKException e) {
			logger.error("Exception to set user aliases " + userName + status + e);
		}
	}

Leave a Reply

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