-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
429 lines (372 loc) · 17.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A feature-rich LDAP library for PHP 5.6+.">
<meta name="author" content="Chad Sikorra">
<link rel="canonical" href="http://www.phpldaptools.com/">
<link rel="shortcut icon" href="./img/favicon.ico">
<title>LdapTools</title>
<link href="./css/bootstrap-custom.min.css" rel="stylesheet">
<link href="./css/font-awesome-4.5.0.css" rel="stylesheet">
<link href="./css/base.css" rel="stylesheet">
<link rel="stylesheet" href="./css/highlight.css">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<script src="./js/jquery-1.10.2.min.js"></script>
<script src="./js/bootstrap-3.0.3.min.js"></script>
<script src="./js/highlight.pack.js"></script>
</head>
<body class="homepage">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=".">LdapTools</a>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li class="active">
<a href=".">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Cookbook <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="cookbook/Authenticating-a-User/">Authenticating a User</a>
</li>
<li >
<a href="cookbook/Common-LDAP-Queries/">Common LDAP Queries</a>
</li>
<li >
<a href="cookbook/Creating-Exchange-Mailboxes/">Creating Exchange Mailboxes</a>
</li>
<li >
<a href="cookbook/Creating-a-Custom-Repository/">Creating a Custom Repository</a>
</li>
<li >
<a href="cookbook/Getting-Your-LDAP-SSL-Certificate/">Getting Your LDAP SSL Certificate</a>
</li>
<li >
<a href="cookbook/Modifying-GPO-Links-on-OUs/">Modifying GPO Links on OUs</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Reference <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="reference/Attribute-Converters/">Attribute Converters</a>
</li>
<li >
<a href="reference/Default-Schema-Attributes/">Default Schema Attributes</a>
</li>
<li >
<a href="reference/Events/">Events</a>
</li>
<li >
<a href="reference/Logging/">Logging</a>
</li>
<li >
<a href="reference/Main-Configuration/">Main Configuration</a>
</li>
<li >
<a href="reference/Schema-Configuration/">Schema Configuration</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorials <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="tutorials/AD-Permissions/">AD Permissions</a>
</li>
<li >
<a href="tutorials/AD-User-Modification/">AD User Modification</a>
</li>
<li >
<a href="tutorials/Building-LDAP-Queries/">Building LDAP Queries</a>
</li>
<li >
<a href="tutorials/Creating-AD-Password-Settings-Objects/">Creating AD Password Settings Objects</a>
</li>
<li >
<a href="tutorials/Creating-LDAP-Objects/">Creating LDAP Objects</a>
</li>
<li >
<a href="tutorials/LDIF-Files/">LDIF Files</a>
</li>
<li >
<a href="tutorials/Modifying-LDAP-Objects/">Modifying LDAP Objects</a>
</li>
<li >
<a href="tutorials/Using-the-LDAP-Manager/">Using the LDAP Manager</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
<li class="disabled">
<a rel="next" >
<i class="fa fa-arrow-left"></i> Previous
</a>
</li>
<li >
<a rel="prev" href="cookbook/Authenticating-a-User/">
Next <i class="fa fa-arrow-right"></i>
</a>
</li>
<li>
<a href="https://github.com/ldaptools/ldaptools/">
<i class="fa fa-github"></i>GitHub
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
<ul class="nav bs-sidenav">
<li class="main active"><a href="#ldaptools">LdapTools</a></li>
<li><a href="#overview">Overview</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#getting-started">Getting Started</a></li>
<li><a href="#searching-ldap">Searching LDAP</a></li>
<li><a href="#modifying-ldap-objects">Modifying LDAP Objects</a></li>
<li><a href="#deleting-ldap-objects">Deleting LDAP Objects</a></li>
<li><a href="#creating-ldap-objects">Creating LDAP Objects</a></li>
<li><a href="#documentation">Documentation</a></li>
<li><a href="#todo">TODO</a></li>
</ul>
</div></div>
<div class="col-md-9" role="main">
<h1 id="ldaptools">LdapTools</h1>
<p>A feature-rich LDAP library for PHP 5.6+.</p>
<hr />
<h2 id="overview">Overview</h2>
<p>LdapTools is designed to be customizable for use with pretty much any directory service, but contains default attribute converters and schemas
for Active Directory and OpenLDAP. </p>
<ul>
<li>A fluent and easy to understand syntax for <a href="#searching-ldap">generating LDAP queries</a>.</li>
<li>Easily <a href="#creating-ldap-objects">create</a>/<a href="#modifying-ldap-objects">modify</a>/<a href="#deleting-ldap-objects">delete</a>/<a href="tutorials/Using-the-LDAP-Manager/#restoring-ldap-objects">restore</a> common LDAP objects (Users, Groups, Contacts, Computers, OUs).</li>
<li>Retrieve LDAP objects as either a simple array or an object with automagic setters/getters.</li>
<li>A <a href="reference/Logging/">logging mechanism</a> for all LDAP operations</li>
<li>An <a href="reference/Events/">event system</a> for further customization, extensibility, and integration.</li>
<li>Parse and create <a href="tutorials/LDIF-Files/">LDIF files</a>.</li>
<li>View and modify <a href="tutorials/AD-Permissions/">Active Directory permissions</a>.</li>
</ul>
<h2 id="installation">Installation</h2>
<p>The recommended way to install LdapTools is using <a href="http://getcomposer.org/download/">Composer</a>:</p>
<pre><code class="bash">composer require ldaptools/ldaptools
</code></pre>
<h2 id="getting-started">Getting Started</h2>
<p>The easiest way to get started is by creating a YAML config file. See the <a href="./resources/config/example.yml">example config</a> file for basic usage. See the
<a href="reference/Main-Configuration/">configuration file reference doc</a> for a list of all available options.</p>
<p>Once you have a configuration file defined, you can get up and running by doing the following:</p>
<pre><code class="php">use LdapTools\Configuration;
use LdapTools\LdapManager;
$config = (new Configuration())->load('/path/to/ldap/config.yml');
$ldap = new LdapManager($config);
</code></pre>
<h2 id="searching-ldap">Searching LDAP</h2>
<p>With the <code>LdapManager</code> up and going you can now easily build LDAP queries without having to remember all the special
syntax for LDAP filters. All values are also automatically escaped. Check the <a href="tutorials/Building-LDAP-Queries/">tutorial</a> for all
available methods and the <a href="cookbook/Common-LDAP-Queries/">cookbook</a> for more query examples.</p>
<pre><code class="php">// Get an instance of the query...
$query = $ldap->buildLdapQuery();
// Returns a LdapObjectCollection of all users whose first name
// starts with 'Foo' and last name is 'Bar' or 'Smith'.
// The result set will also be ordered by state name (ascending).
$users = $query->fromUsers()
->where($query->filter()->startsWith('firstName', 'Foo'))
->orWhere(['lastName' => 'Bar'])
->orWhere(['lastName' => 'Smith'])
->orderBy('state')
->getLdapQuery()
->getResult();
echo "Found ".$users->count()." user(s).";
foreach ($users as $user) {
echo "User: ".$user->getUsername();
}
// Get all OUs and Containers at the base of the domain, ordered by name.
$results = $ldap->buildLdapQuery()
->from(LdapObjectType::OU)
->from(LdapObjectType::CONTAINER)
->orderBy('name')
->setScopeOneLevel()
->getLdapQuery()
->getResult();
// Get a single LDAP object and select some specific attributes...
$user = $ldap->buildLdapQuery()
->select(['upn', 'guid', 'sid', 'passwordLastSet'])
->fromUsers()
->where(['username' => 'chad'])
->getLdapQuery()
->getSingleResult();
// Get a single attribute value from a LDAP object...
$guid = $ldap->buildLdapQuery()
->select('guid')
->fromUsers()
->where(['username' => 'chad'])
->getLdapQuery()
->getSingleScalarResult();
// It also supports the concepts of repositories...
$userRepository = $ldap->getRepository('user');
// Find all users whose last name equals Smith.
$users = $userRepository->findByLastName('Smith');
// Get the first user whose username equals 'jsmith'. Returns a `LdapObject`.
$user = $userRepository->findOneByUsername('jsmith');
echo "First name ".$user->getFirstName()." and last name ".$user->getLastName();
</code></pre>
<p>See <a href="tutorials/Building-LDAP-Queries/">the docs</a> for more information on building LDAP queries.</p>
<h2 id="modifying-ldap-objects">Modifying LDAP Objects</h2>
<p>Modifying LDAP is as easy as searching for the LDAP object as described above, then making changes directly to the object
and saving it back to LDAP using the <code>LdapManager</code>.</p>
<pre><code class="php">$user = $ldap->buildLdapQuery()
->select(['title', 'mobilePhone', 'disabled'])
->fromUsers()
->where(['username' => 'jsmith'])
->getLdapQuery()
->getSingleResult();
// Make some modifications to the user account.
// All these changes are tracked so it knows how to modify the object.
$user->setTitle('CEO');
if ($user->hasMobilePhone()) {
$user->resetMobilePhone();
}
// Set a field by a property instead...
if ($user->disabled) {
$user->disabled = false;
}
// Add a value to an attribute...
$user->addOtherIpPhones('#001-5555');
// Add a few values at one time...
$user->addOtherIpPhones('#001-4444', '#001-3333', '#001-2222');
// Now actually save the changes back to LDAP...
try {
$ldap->persist($user);
} catch (\Exception $e) {
echo "Error updating user! ".$e->getMessage();
}
</code></pre>
<p>See <a href="tutorials/Modifying-LDAP-Objects/">the docs</a> for more information on modifying LDAP objects.</p>
<h2 id="deleting-ldap-objects">Deleting LDAP Objects</h2>
<p>Deleting LDAP objects is a simple matter of searching for the object you want to remove, then passing it to the delete
method on the <code>LdapManager</code>:</p>
<pre><code class="php">// Decide they no longer work here and should be deleted?
$user = $userRepository->findOneByUsername('jsmith');
try {
$ldap->delete($user);
} catch (\Exception $e) {
echo "Error deleting user! ".$e->getMessage();
}
</code></pre>
<h2 id="creating-ldap-objects">Creating LDAP Objects</h2>
<p>Creating LDAP objects is easily performed by just passing what you want the attributes to be and what container/OU the
object should end up in:</p>
<pre><code class="php">$ldapObject = $ldap->createLdapObject();
// Creating a user account (enabled by default)
$ldapObject->createUser()
->in('cn=Users,dc=example,dc=local')
->with(['username' => 'jsmith', 'password' => '12345'])
->execute();
// Create a typical AD global security group...
$ldapObject->createGroup()
->in('dc=example,dc=local')
->with(['name' => 'Generic Security Group'])
->execute();
// Creates a contact user...
$ldapObject->createContact()
->in('dc=example,dc=local')
->with(['name' => 'Some Guy', 'emailAddress' => '[email protected]'])
->execute();
// Creates a computer object...
$ldapObject->createComputer()
->in('dc=example,dc=local')
->with(['name' => 'MYWOKRSTATION'])
->execute();
// Creates an OU object...
$ldapObject->createOU()
->in('dc=example,dc=local')
->with(['name' => 'Employees'])
->execute();
</code></pre>
<p>See <a href="tutorials/Creating-LDAP-Objects/">the docs</a> for more information on creating LDAP objects.</p>
<h2 id="documentation">Documentation</h2>
<ul>
<li><a href="reference/Main-Configuration/">Main Configuration Reference</a></li>
<li><a href="reference/Schema-Configuration/">Schema Configuration</a></li>
<li><a href="tutorials/Using-the-LDAP-Manager/">Using the LdapManager</a></li>
<li><a href="tutorials/Building-LDAP-Queries/">Building LDAP Queries</a></li>
<li><a href="tutorials/Creating-LDAP-Objects/">Creating LDAP Objects</a></li>
<li><a href="tutorials/Modifying-LDAP-Objects/">Modifying LDAP Objects</a></li>
<li><a href="tutorials/LDIF-Files/">LDIF files</a></li>
<li><a href="cookbook/Creating-Exchange-Mailboxes/">Creating Exchange Mailboxes</a></li>
<li><a href="tutorials/AD-Permissions/">Active Directory permissions</a></li>
<li><a href="reference/Default-Schema-Attributes/">Default Schema Attributes</a></li>
<li><a href="reference/Events/">The Event System</a></li>
</ul>
<h2 id="todo">TODO</h2>
<p>Things that still need to be implemented:</p>
<ul>
<li>Automatic generation of the schema based off of information in LDAP.</li>
<li>More work needed on the OpenLDAP schema.</li>
</ul></div>
</div>
<footer class="col-md-12">
<hr>
<p>Copyright © 2015, Chad Sikorra.</p>
<p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</p>
</footer>
<script>var base_url = '.';</script>
<script data-main="./mkdocs/js/search.js" src="./mkdocs/js/require.js"></script>
<script src="./js/base.js"></script><div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Search</h4>
</div>
<div class="modal-body">
<p>
From here you can search these documents. Enter
your search terms below.
</p>
<form role="form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
</div>
</form>
<div id="mkdocs-search-results"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
<!--
MkDocs version : 0.16.3
Build Date UTC : 2017-08-14 13:29:00
-->