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

Commit e18e87a

Browse files
committed
Working on more tutorials
1 parent 2dc94a8 commit e18e87a

File tree

1 file changed

+69
-5
lines changed

1 file changed

+69
-5
lines changed

docs/tutorials/basics.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,75 @@
11
# The Basics
22

3-
## Creating
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.
46

5-
## Updating
7+
## Searching
68

7-
## Deleting
9+
### Querying for your Base DN
810

9-
## Moving
1011

11-
## Renaming
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

0 commit comments

Comments
 (0)