# How to configure VPN access time restrictions

**URL:** <https://forum.pritunl.com/t/how-to-configure-vpn-access-time-restrictions/3570>\
**Category:** Pritunl\
**Created:** [October 6, 2025, 5:00pm UTC](https://forum.pritunl.com/t/how-to-configure-vpn-access-time-restrictions/3570 "2025-10-06T17:00:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipe](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/f/90db22/32.png) [@Felipe](https://forum.pritunl.com/u/Felipe)\
**Post date:** [October 6, 2025, 5:00pm UTC](https://forum.pritunl.com/t/how-to-configure-vpn-access-time-restrictions/3570/1 "2025-10-06T17:00:35Z")

</div>

Hello everyone,

We are currently evaluating the **Pritunl Enterprise** solution for our company and plan to start testing it soon.  
Before proceeding, I would like to clarify one point regarding **time-based VPN access control**.

Our current environment

- We use a **local Active Directory** synchronized with **Azure AD**.

- VPN authentication is integrated via **SSO (Single Sign-On)**.

- Our current VPN solution includes a **time-based access policy** — for example:

What I would like to know

In **Pritunl** , what would be the best approach to configure this kind of **time-based access restriction**?

- Is there a **native feature or policy** that can handle connection schedules?

- Or would it be necessary to integrate with an **external access management or automation system** (for example, via API or directory-based rules)?

Any guidance, best practices, or references from the documentation would be very helpful as we design our Pritunl deployment.

Thanks

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [October 7, 2025, 6:30pm UTC](https://forum.pritunl.com/t/how-to-configure-vpn-access-time-restrictions/3570/2 "2025-10-07T18:30:13Z")

</div>

This can be done with a plugin.

```auto
sudo tee /var/lib/pritunl/plugins/auth.py << 'EOF'
from datetime import datetime

def user_connect(host_id, server_id, org_id, user_id, host_name,
        server_name, org_name, user_name, remote_ip, mac_addr, mac_addrs,
        platform, device_id, device_name, bypass_secondary, has_token,
        password, **kwargs):
    current_hour = datetime.now().hour
    if current_hour >= 20 or current_hour < 7:
        return False, 'Access denied: Outside allowed hours'
    return True, None
EOF

sudo systemctl restart pritunl

```
