@@ -43,7 +43,7 @@ keyid=foo
43
43
44
44
Let's say we wanted to look at the record cn=john:
45
45
46
- ``` sh
46
+ ``` shell
47
47
dn: cn=john, ou=users, o=example
48
48
cn: john
49
49
sn: smith
@@ -114,7 +114,7 @@ If you don't already have node.js and npm, clearly you need those, so follow
114
114
the steps at [ nodejs.org] ( http://nodejs.org ) and [ npmjs.org] ( http://npmjs.org ) ,
115
115
respectively. After that, run:
116
116
117
- ``` sh
117
+ ``` shell
118
118
$ npm install ldapjs
119
119
```
120
120
@@ -139,7 +139,7 @@ server.listen(1389, () => {
139
139
And run that. Doing anything will give you errors (LDAP "No Such Object")
140
140
since we haven't added any support in yet, but go ahead and try it anyway:
141
141
142
- ``` sh
142
+ ``` shell
143
143
$ ldapsearch -H ldap://localhost:1389 -x -b " o=myhost" objectclass=*
144
144
```
145
145
@@ -205,7 +205,7 @@ add another handler in later you won't get bit by it not being invoked.
205
205
206
206
Blah blah, let's try running the ldap client again, first with a bad password:
207
207
208
- ``` sh
208
+ ``` shell
209
209
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w foo -b " o=myhost" objectclass=*
210
210
211
211
ldap_bind: Invalid credentials (49)
@@ -215,7 +215,7 @@ ldap_bind: Invalid credentials (49)
215
215
216
216
And again with the correct one:
217
217
218
- ``` sh
218
+ ``` shell
219
219
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b " o=myhost" objectclass=*
220
220
221
221
No such object (32)
@@ -252,7 +252,7 @@ oriented, so we check that the connection remote user was indeed our `cn=root`
252
252
We said we wanted to allow LDAP operations over /etc/passwd, so let's detour
253
253
for a moment to explain an /etc/passwd record.
254
254
255
- ``` sh
255
+ ``` shell
256
256
jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh
257
257
```
258
258
@@ -331,7 +331,7 @@ server.search('o=myhost', pre, (req, res, next) => {
331
331
332
332
And try running:
333
333
334
- ``` sh
334
+ ``` shell
335
335
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b " o=myhost" cn=root
336
336
dn: cn=root, ou=users, o=myhost
337
337
cn: root
@@ -345,7 +345,7 @@ objectclass: unixUser
345
345
346
346
Sweet! Try this out too:
347
347
348
- ``` sh
348
+ ``` shell
349
349
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b " o=myhost" objectclass=*
350
350
...
351
351
```
@@ -357,7 +357,7 @@ What all did we do here? A lot. Let's break this down...
357
357
358
358
Let's start with looking at what you even asked for:
359
359
360
- ``` sh
360
+ ``` shell
361
361
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b " o=myhost" cn=root
362
362
```
363
363
@@ -420,7 +420,7 @@ shell set to `/bin/false` and whose name starts with `p` (I'm doing this
420
420
on Ubuntu). Then, let's say we only care about their login name and primary
421
421
group id. We'd do this:
422
422
423
- ``` sh
423
+ ``` shell
424
424
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b " o=myhost" " (&(shell=/bin/false)(cn=p*))" cn gid
425
425
dn: cn=proxy, ou=users, o=myhost
426
426
cn: proxy
@@ -502,7 +502,7 @@ Then, you'll need to be root to have this running, so start your server with
502
502
` sudo ` (or be root, whatever). Now, go ahead and create a file called
503
503
` user.ldif ` with the following contents:
504
504
505
- ``` sh
505
+ ``` shell
506
506
dn: cn=ldapjs, ou=users, o=myhost
507
507
objectClass: unixUser
508
508
cn: ldapjs
@@ -512,14 +512,14 @@ description: Created via ldapadd
512
512
513
513
Now go ahead and invoke with:
514
514
515
- ``` sh
515
+ ``` shell
516
516
$ ldapadd -H ldap://localhost:1389 -x -D cn=root -w secret -f ./user.ldif
517
517
adding new entry " cn=ldapjs, ou=users, o=myhost"
518
518
```
519
519
520
520
Let's confirm he got added with an ldapsearch:
521
521
522
- ``` sh
522
+ ``` shell
523
523
$ ldapsearch -H ldap://localhost:1389 -LLL -x -D cn=root -w secret -b " ou=users, o=myhost" cn=ldapjs
524
524
dn: cn=ldapjs, ou=users, o=myhost
525
525
cn: ldapjs
@@ -626,7 +626,7 @@ is the 'standard' LDAP attribute for passwords; if you think it's easier to use
626
626
command (which lets you change a user's password over stdin). Next, go ahead
627
627
and create a ` passwd.ldif ` file:
628
628
629
- ``` sh
629
+ ``` shell
630
630
dn: cn=ldapjs, ou=users, o=myhost
631
631
changetype: modify
632
632
replace: userPassword
@@ -636,7 +636,7 @@ userPassword: secret
636
636
637
637
And then run the OpenLDAP CLI:
638
638
639
- ``` sh
639
+ ``` shell
640
640
$ ldapmodify -H ldap://localhost:1389 -x -D cn=root -w secret -f ./passwd.ldif
641
641
```
642
642
@@ -679,7 +679,7 @@ server.del('ou=users, o=myhost', pre, (req, res, next) => {
679
679
680
680
And then run the following command:
681
681
682
- ``` sh
682
+ ``` shell
683
683
$ ldapdelete -H ldap://localhost:1389 -x -D cn=root -w secret " cn=ldapjs, ou=users, o=myhost"
684
684
```
685
685
0 commit comments