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

Commit 2f857cf

Browse files
authored
Added another example rule.
1 parent de20323 commit 2f857cf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/auth/rules.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,26 @@ To implement your new rule, you just need to insert it into your `config/adldap_
5252

5353
Now when you try to authenticate, you will either need to be logging in with an LDAP user with the last name of `Doe` or
5454
with a local database record that was created after 2016.
55+
56+
## Example Rules
57+
58+
### Group Validation
59+
60+
To validate that an authenticating user is apart of one or more LDAP groups, we can perform this with a `Rule`:
61+
62+
```php
63+
namespace App\Rules;
64+
65+
use Adldap\Models\User as LdapUser;
66+
use Adldap\Laravel\Validation\Rules\Rule;
67+
68+
class AccountingRule extends Rule
69+
{
70+
public function isValid(LdapUser $ldapUser)
71+
{
72+
return $ldapUser->inGroup('Accounting');
73+
}
74+
}
75+
```
76+
77+
Once you've implemented the above rule, only LDAP users that are apart of the `Accounting` group, will be allowed to authenticate.

0 commit comments

Comments
 (0)