Find your dream job at PaperCut

Choose your language

Choose your login

Contact us

Help Center menu

PRODUCT MANUALS

PaperCut NG & PaperCut MF Manual

PRODUCTS FEATURED

Example: Prevent access to devices out of business hours

The Department of Social Services is a government department that is responsible for developing and implementing social policies. As such, 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 (8am-6pm weekdays).

Requirements

Using device scripting, the Department of Social Services will:

  • Prevent users from logging in to a device between the hours of 6pm and 8am 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 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

You can also download the script here and then copy it into the Script Editor.

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 6pm and 8am 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 6pm and 8am 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 8am and 6pm to make sure users can log in when they are allowed.

  2. Copy your device script to the required devices.

Comments