Resetting user password

	
	
	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 resetUserPassword(String userName) {
		try {

			logger.debug("reset user password " + userName);

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

			// Retrieve the user and group
			boInfoObjects = boInfoStore
					.query("SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_PROGID='CrystalEnterprise.User' and SI_NAME = '"
							+ userName + "'");
			boCurUser = (IUser) boInfoObjects.get(0);
			boCurUser.setNewPassword("TESTPASS");
			boCurUser.setPasswordToChangeAtNextLogon(true);
			boInfoStore.commit(boInfoObjects);
		} catch (SDKException e) {
			logger.error("Exception to reset user password " + userName + e);
		}
	}

Leave a Reply

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