TSF – Giải pháp IT toàn diện cho doanh nghiệp SMB | HCM

P5 – Automate LDAP Sync SnipeIT Using Windows Task Scheduler

🖥️ Snipe-IT P5 – How to Automate LDAP Sync Using Windows Task Scheduler

In enterprise environments, manual LDAP synchronization can become inefficient and error-prone. Automating LDAP sync ensures your Snipe-IT asset management system stays up-to-date with Active Directory users without manual intervention.

In this guide, we will configure automatic LDAP synchronization using Windows Task Scheduler and a simple batch script.

This tutorial is based on:

  • Snipe-IT Server IP: 192.168.16.134

  • Environment: XAMPP on Windows

  • Automation Method: Windows Task Scheduler

Let’s begin.


📌 Why Automate LDAP Sync in Snipe-IT?

Automating LDAP sync provides several benefits:

✔ Automatically updates users from Active Directory
✔ Reduces administrative workload
✔ Prevents missing or outdated user records
✔ Ensures consistency in asset assignments

For IT administrators managing multiple systems, automation is essential.


⚙️ Environment Information

Before starting, confirm:

  • Snipe-IT is working properly

  • LDAP integration is already configured and tested

  • XAMPP is installed

  • PHP CLI is accessible

Snipe-IT Location:

 
C:\xampp\htdocs\snipe-it

🗂️ Step 1 – Create Script Folder

First, create a folder in Drive C to store the automation script.

📁 Create a new folder:

 
C:\Script

This folder will contain the batch file responsible for triggering LDAP sync.


📝 Step 2 – Create the Batch File

Inside the C:\Script folder, create a new file:

 
ldap-sync.bat

Edit the file and insert the following content:

 
cd C:\xampp\htdocs\snipe-it php artisan snipeit:ldap-sync

🔎 What This Script Does

  • Changes directory to the Snipe-IT installation path

  • Executes the Laravel Artisan command to trigger LDAP synchronization

This is the exact same command used when running LDAP sync manually via command prompt — now we’re simply automating it.

💡 Save the file after adding the content.


🧪 Optional – Test the Script Manually

Before scheduling, it is recommended to test the script manually.

  1. Double-click ldap-sync.bat

  2. Verify that the command runs successfully

  3. Confirm user synchronization inside Snipe-IT

If it works manually, it will work with Task Scheduler.


⏰ Step 3 – Create Scheduled Task

Now we configure Windows Task Scheduler to automate the process.

Open Task Scheduler

  1. Press Windows + R

  2. Type:

     
    taskschd.msc
  3. Press Enter


Create a New Task

  1. Click Create Task

  2. Name the task:

     
    SnipeIT LDAP Sync

Configure Trigger

  1. Go to the Triggers tab

  2. Click New

  3. Choose schedule type:

    • Daily

    • Or based on your business requirement

  4. Set execution time

  5. Click OK


Configure Action

  1. Go to the Actions tab

  2. Click New

  3. Choose:

     
    Start a Program
  4. Browse and select:

     
    C:\Script\ldap-sync.bat
  5. Click OK


Advanced Settings (Recommended)

Under the General tab:

✔ Run whether user is logged on or not
✔ Run with highest privileges

This ensures the task executes properly even if no user is logged in.


🔐 Best Practices for Production

For production environments:

  • Schedule sync every 1–4 hours (depending on organization size)

  • Monitor task history for errors

  • Ensure PHP path environment variables are correctly configured

  • Use service account if needed


📊 How It Works Behind the Scenes

When the scheduled time is triggered:

  1. Windows launches the .bat file

  2. The script switches to the Snipe-IT directory

  3. Laravel Artisan executes:

     
    php artisan snipeit:ldap-sync
  4. Snipe-IT communicates with Active Directory

  5. User records are synchronized automatically

No manual login required.


🎯 Final Result

After completing these steps:

✅ LDAP sync runs automatically
✅ Active Directory users stay updated
✅ No manual command execution required
✅ Enterprise-level automation implemented

You have successfully automated LDAP synchronization in Snipe-IT using Windows Task Scheduler.

See also related articles

P13 – Ultimate QR Code SnipeIT Setup Made Easy

P13 – Ultimate QR Code SnipeIT Setup Made Easy SnipeIT – P13 QR Code Setup Guide | Create and Print Asset QR Codes Managing IT assets without proper labeling can quickly become chaotic.When devices move between departments, employees leave, or audits happen, identifying assets manually wastes time and increases errors....

Read More

P12 – Ultimate Bulk Method to Check In Check Out Assets in SnipeIT

P12 – Ultimate Bulk Method to Check In Check Out Assets in SnipeIT SnipeIT – P12 The Fastest Way to Check-In & Check-Out Assets in Snipe-IT (Bulk Method) Managing a few devices manually is easy. Managing 100–500 assets during onboarding, offboarding, or department transfers? That’s a different story. If you...

Read More

P11 – Ultimate Guide to Check In Check Out in SnipeIT

P11 – Ultimate Guide to Check In Check Out in SnipeIT SnipeIT – P11 How to Manage Check In Check Out in SnipeIT (Step-by-Step) Efficient asset tracking is the backbone of every IT department. If you cannot accurately manage Check In check Out in SnipeIT, your asset database quickly becomes...

Read More