Scheduled Sync with AD
- Generate an API key. Sign in as an admin, then go Tools > Project > Project Settings and click create in the API Key field.
2. Generate a fieldmap URL. You can do this by initiating a manual sync. When the import completes, the fieldmap URL will be visible in your browser URL bar.
e.g.
http://mysite.com/Project1/#sync_ad_adminkey_{"username":"samaccountname","firstname":"givenname","lastname":"sn"}
3. Create a new fieldmap URL by combining the original with the API key generated in Step 1 (bolded below), replacing the 'adminkey' text.
e.g.
http://mysite.com/Project1/#sync_empad_1Eg1sAqRXJ9dJ3TPI_{%22username%22:%22username%22,%22firstname%22:%22firstname%22,%22lastname%22:%22lastname%22,%22email%22:%22email%22}
4. Open the new fieldmap URL in a browser to initiate the AD Sync.
Scheduled Syncs
With the fieldmap URL it's possible to use Windows Task Scheduler to schedule times to open a browser to the URL, enabling timed syncs.
Task Scheduler
1. Open Task Scheduler.
2. Go to Action > Create Basic Task.
3. Step through the creation wizard, giving a name and designating the time the task will run.
4. On the Action step, select Start a program.
5. Click on Browse and select your preferred web browser.
6. Paste the fieldmap URL into the Add arguments box.
7. Click Finish.
PowerShell Script + Task Scheduler
The benefit of using a PowerShell or other type of script is that you can close the browser after initiating the sync.
Start-Process -FilePath Chrome -ArgumentList 'http://localhost/staffmap4/ADSync/#sync_ad_LWnvcQZ5GOgyxS4hjG_{%22username%22:%22samaccountname%22,%22firstname%22:%22givenname%22,%22lastname%22:%22sn}'
Start-Sleep -Seconds 10
Stop-Process -Name Chrome
1. Create a PowerShell script (example above) to open the URL, pause, then close the browser.
2. Open Task Scheduler.
3. Go to Action > Create Basic Task.
4. Step through the creation wizard, giving a name and designating the time the task will run.
5. On the Action step, select Start a program.
6. Click on Browse and select PowerShell (usually C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe).
7. Paste the navigation path of the script file into the Add arguments box e.g. "C:\Users\Administrator\Desktop\Scripts\SyncStaffmap.ps1"
8. Click Finish.