Choose your language

Choose your login

Support

How can we help?

Lightbulb icon
Lightbulb icon

Here’s your answer

Sources:

Lightbulb icon

Oops!

We currently don’t have an answer for this and our teams are working on resolving the issue. If you still need help,
User reading a resource

Popular resources

Conversation bubbles

Contact us

Example:Prevent access to devices out of business hours

This page applies to:

The Department of Social Services is a government department that is responsible for developing and implementing social policies. They deal with a lot of highly sensitive information so want to do everything they can to minimize the chances of private information being mishandled.

They already use PaperCut MF to track what is being copied and printed, which is great for monitoring after the fact, but they also want to limit their staff’s access to devices outside of standard business hours (8 a.m. - 6 p.m. weekdays).

Solution description

Using device scripting, the Department of Social Services will:

  • prevent users from logging in to a device between the hours of 6 p.m. and 8 a.m. on week days and all weekend

  • send an email to the IT manager if someone tries to access a device after hours.

Implementation

The best way to create a device script is to either start with a recipe or build your script using snippets. This example demonstrates how to create a script using snippets. All you need to do is specify your variable values.

To create this script, you will:

  1. Add the Device login hook stub .

  2. Add the deny login access snippet .

  3. Add the Send an email to one or many recipients. snippet

  4. Test your script and go live .

For more information about creating device scripts, see:

Add the Device login hook stub

Every script needs to start with a “hook”. This hook defines the event that triggers the script to run. To prevent access to a device, the event is a user’s attempt to log in, so use deviceLoginHook. For more information about the available hooks, see Device script API reference .

  1. Click the Devices tab.
    The External Device List page is displayed.

  2. Select a test device.
    The Device Details page is displayed.

  3. Click the Scripting tab.

  4. Select the Enable device script checkbox.

    By default, the deviceLoginHook is included in the script editor.

  5. Edit the script description so it captures what this script does.

Add the Deny login access snippet

The Deny login access snippet allows you to specify the:

  • hours/days that access to the device will be blocked

  • user groups whose access will be blocked.

For more information about snippets, see Using snippets .

  1. Select the line below the function ( // your script here).

  2. Click Insert Snippet at Cursor.

  3. Under Actions, select Deny login access.

  4. Click insert.

    In this example, the Department of Social Services wants to block access to all users between 6 p.m. and 8 a.m. on weeknights, and all Saturday and Sunday.

  5. Add variables to specify the device access block period. For more information about JavaScript methods, see JavaScript Functions Definitions . Specifically, you will add a variable to specify the:

    • time of the day before which device access will be blocked (var BEFORE_HOURS)

    • time of the day after which device access will be blocked (var AFTER_HOURS)

    • days on which device access will be blocked (var SATURDAY and var SUNDAY)

  6. Add a variable to get the current day date.getDay(). The snippet includes variables to get the date (new Date()) and time date.getHours() methods, but not the day date.getDay() method.

  7. Update the default if statement to remove the user group specification and check whether or not a user is accessing the device outside of work hours.

    if (inputs.user.isInGroup("Students") && (hours < 8 || hours >= 18)) { actions.login.denyLoginAccess(); }

Add the Send an email to one or many recipients snippet

The ‘Send an email to one or many recipients’ snippet sends a notification to one or more recipients when the action specified in the script occurs. In this case, the action is that device access has been denied.

  1. Select the line below the function ( // your script here).

  2. Click Insert Snippet at Cursor.

  3. Under Actions, select Send an email to one or many recipients.

  4. Click insert.

  5. Add your organization specific email details.

  6. Click Apply.

Test your script and go live

Before you copy your script to production devices, make sure you check that it works in on a test device.

  1. Check the following on a test device:

    • Try to log in between 6 p.m. and 8 a.m. on a weeknight.

    • Try to log in on a weekend.

    • Check that the appropriate email recipient received an email for each attempt.

    • Log in between 8 a.m. and 6 p.m. to make sure users can log in when they are allowed.

  2. Copy your device script to the required devices.

Comments