,

Ironside Tech Tip: Allow or Deny Access to a Report Based on the Time of Day

allow or deny access to a report chain barrier concept

clock graphicSecurity in Cognos is extremely robust, permitting or denying very precise access to data elements in a package, data source, or even to row level access in a database. Read & Execute permissions are usually applied to a report allowing certain Groups or Roles the ability to run a report. However, you can also allow or deny access to a report to only let it execute within specific hours of the day.

Situations in which you may want to allow or deny access to a report include:

  • Precluding access outside of business hours
  • Denying access during data warehouse or cube updates
  • Restricting access during system maintenance times
  • Preventing access to (perhaps long or resource intensive) reports during heavy system load times

Steps:

1. Create a report using Report Studio.

Example:list report

2. Create a data item named Current Time that contains the following function:

  Localtime

This will return the current time in a formatted as such: 10:24 AM

3. Create two data items in 2-digit format named Start Hour and End Hour. Hardcode your time periods in these data items.

data item expression

4. Create another data item named Current Hour that extracts the first two characters of the time (the 2-digit hour) and converts that to an integer. This will be evaluated numerically in a subsequent step below to see if it is within the authorized hours defined in step 3.

cast(substring(cast ([Current Time], VARCHAR(18)), 1,2), INT)

5. The query should look similar to the following:

start hour data item

6. Return to page 1 of the report.

7. Add a conditional block to the page.

8. From the Conditional Explorer, drag and drop a Boolean Variable into the Variables pane.

boolean variable

9. Add the following condition:

[Query1].[Current Hour] between [Query1].[Start Hour] and [Query1].[End Hour]

Note: The “between” function is inclusive

between function expression           

10. Return back to page 1 of the report.

11. Select the conditional block.

12. Assign the Boolean expression created in step 9 to the conditional block.

conditional block variable

13. The current value No of the conditional block is the “false” condition. That is, the hour that the report is run is not within the start and stop times.

current block setting

14. Add an end-user error message if desired as follows:

conditional text output

15. With the conditional block still selected do the following:

a)     Go to Properties > Current Block.

b)    From the pull-down menu, select Yes.

current block variable setting

16. Next, select the object(s) that you would like available during the open time period. (See step 1)

17. Drag and drop the object(s) into the conditional block.

18. Select the entire page and associate the Query property to the one you have been working on. (Query1 if you didn’t modify the name)

query selection

19. Select Properties and select Start Hour, End Hour, and Current Hour

select variable data items

20. Run the report. If it is run within the start and stop hours, the report will display, otherwise it will show the error message.

Implementing this workflow where appropriate will let you allow or deny access to a report depending on when users access it. This can help with processing loads in environments and can help enforce security.

 

Additional notes:

  • Security is not assured if other Report Studio users have permission on the report, as they would be able to view and change the start or stop times.
  • Consider variations of this report, perhaps running reports only during weekdays etc.