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

Commit 9ab0f4b

Browse files
committed
2 parents df1b636 + e18e87a commit 9ab0f4b

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

docs/auth/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ however you will still need to publish the configuration file using the
5656
command below:
5757

5858
```bash
59-
php artisan vendor:publish --provdier="Adldap\Laravel\AdldapAuthServiceProvider"
59+
php artisan vendor:publish --provider="Adldap\Laravel\AdldapAuthServiceProvider"
6060
```
6161

6262
Then, open your `config/auth.php` configuration file and change the `driver`
@@ -71,4 +71,4 @@ value inside the `users` authentication provider to `ldap`:
7171
],
7272
```
7373

74-
Now that you've completed the basic installation, let's move along to the [setup guide](setup.md).
74+
Now that you've completed the basic installation, let's move along to the [setup guide](setup.md).

docs/tutorials/basics.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# The Basics
2+
3+
Lets get down to the basics. This guide will help you get a quick understanding of
4+
using Adldap2 and cover some use cases you might want to learn how to
5+
perform before trying to work it out on your own.
6+
7+
## Searching
8+
9+
### Querying for your Base DN
10+
11+
12+
13+
### Querying for Enabled / Disabled Users
14+
15+
To locate enabled / disabled users in your directory, call the `whereEnabled()`
16+
and `whereDisabled()` methods on a query:
17+
18+
```php
19+
$enabledUsers = Adldap:search()->users()->whereEnabled()->get();
20+
21+
$disabledUsers = Adldap:search()->users()->whereDisabled()->get();
22+
```
23+
24+
### Querying for Group Membership
25+
26+
To locate records in your directory that are apart of a group, use the `whereMemberOf()` query method:
27+
28+
```php
29+
// First, locate the group we want to retrieve the members for:
30+
$accounting = Adldap::search()->groups()->find('Accounting');
31+
32+
// Retrieve the members that belong to the above group.
33+
$results = Adldap::search()->whereMemberOf($accounting)->get();
34+
35+
// Iterate through the results:
36+
foreach ($results as $model) {
37+
$model->getCommonName(); // etc.
38+
}
39+
```
40+
41+
### Escaping Input Manually
42+
43+
If you'd like to execute raw filters, it's best practice to escape any input you receive from a user.
44+
45+
You can do this in a couple ways, so use whichever feels best to you.
46+
47+
Each escape method below will escape all characters inputted unless an **ignore** parameter or **flag**
48+
parameter have been given (such as `LDAP_ESCAPE_FITLER` or `LDAP_ESCAPE_DN`).
49+
50+
```php
51+
// Escaping using the query builder:
52+
$escaped = Adldap::search()->escape($input, $ignore = '', $flags = 0);
53+
54+
// Escaping using the `Utilities` class:
55+
$escaped = \Adldap\Utilities::escape($input, $ignore = '', $flags = 0);
56+
57+
// Escaping with the native PHP:
58+
$escaped = ldap_escape($input, $ignore = '', $flags = 0);
59+
60+
$rawFilter = `(samaccountname=$escaped)`
61+
62+
$results = Adldap::search()->rawFilter($rawFilter)->get();
63+
```
64+
65+
## Models
66+
67+
### Creating
68+
69+
### Updating
70+
71+
### Deleting
72+
73+
### Moving
74+
75+
### Renaming

docs/tutorials/users.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,48 @@ $jdoe->userAccountControl = $uac->getValue();
120120

121121
$jdoe->save();
122122
```
123+
124+
You can also use 'setter' methods to perform the same task.
125+
126+
```php
127+
$jdoe = Adldap::search()->users()->find('jdoe');
128+
129+
$uac = new Adldap\Models\Attributes\AccountControl();
130+
131+
$uac->accountIsNormal();
132+
133+
$jdoe
134+
->setDepartment('Accounting');
135+
->setTelephoneNumber('555 555-5555')
136+
->setMobileNumber('555 555-5555')
137+
->setUserAccountControl($uac);
138+
139+
$jdoe->save();
140+
```
141+
142+
Using setter methods offer a little bit of benefit, for example you can see above that
143+
`$uac->getValue()` does not need to be called as the `setUserAccountControl()` method
144+
will automatically convert an `AccountControl` object to its integer value.
145+
146+
Setter methods are also chainable (if you prefer that syntax).
147+
148+
## Deleting Users
149+
150+
As any other returned model in Adldap2, you can call the `delete()` method
151+
to delete a user from your directory:
152+
153+
```php
154+
$user = Adldap::search()->find('jdoe');
155+
156+
$user->delete();
157+
```
158+
159+
Once you `delete()` a user (successfully), the `exists` property on their model is set to `false`:
160+
161+
```php
162+
$user = Adldap::search()->find('jdoe');
163+
164+
$user->delete();
165+
166+
var_dump($user->exists); // Returns 'bool(false)'
167+
```

0 commit comments

Comments
 (0)