Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 02b6b2f

Browse files
authored
Added scheduled job example
1 parent ad3c2f9 commit 02b6b2f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/auth/importing.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,37 @@ After it has displayed all users, you will then be asked:
4949
Successfully imported / synchronized 2 user(s).
5050
```
5151

52+
## Scheduling the Command
53+
54+
To run the import as a scheduled job, place the following in your `app/Console/Kernel.php` in the command scheduler:
55+
56+
```php
57+
/**
58+
* Define the application's command schedule.
59+
*
60+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
61+
*
62+
* @return void
63+
*/
64+
protected function schedule(Schedule $schedule)
65+
{
66+
// Import LDAP users hourly.
67+
$schedule->command('adldap:import', [
68+
'--no-interaction',
69+
'--restore',
70+
'--delete',
71+
'--filter' => '(objectclass=user)',
72+
])->hourly();
73+
}
74+
```
75+
76+
The above scheduled import command will:
77+
78+
- Run without interaction and import new users as well as synchronize already imported users
79+
- Restore user models who have been re-activated in your LDAP directory (if you're using [SoftDeletes](https://laravel.com/docs/5.7/eloquent#soft-deleting))
80+
- Soft-Delete user models who have been deactived in your LDAP directory (if you're using [SoftDeletes](https://laravel.com/docs/5.7/eloquent#soft-deleting))
81+
- Only import users that have an `objectclass` equal to `user`
82+
5283
### Importing a Single User
5384

5485
To import a single user, insert one of their attributes and Adldap2 will try to locate the user for you:

0 commit comments

Comments
 (0)