Skip to content

Commit 26fc57d

Browse files
working LDAP w/ one admin and one dev
1 parent 31dd2bb commit 26fc57d

File tree

8 files changed

+146
-2
lines changed

8 files changed

+146
-2
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# inspired by https://github.com/larrycai/docker-openldap
2+
# it is based on https://github.com/rackerlabs/dockerstack/blob/master/keystone/openldap/Dockerfile
3+
# also the files/more.ldif from http://www.zytrax.com/books/ldap/ch14/#ldapsearch
4+
ARG DOCKER_REGISTRY=docker.io
5+
FROM ${DOCKER_REGISTRY}/qnib/plain-openldap@sha256:ed3bcf8045dbc22207d7b521b446cd2b5f035e39ee02bacedb0f75b90f967ec7
6+
7+
COPY files /ldap
8+
9+
RUN service slapd start \
10+
&& cd /ldap \
11+
&& ldapadd -Y EXTERNAL -H ldapi:/// -f back.ldif \
12+
&& ldapadd -Y EXTERNAL -H ldapi:/// -f sssvlv_load.ldif \
13+
&& ldapadd -Y EXTERNAL -H ldapi:/// -f sssvlv_config.ldif \
14+
&& ldapadd -x -D cn=admin,dc=qnib,dc=inc -w password -c -f front.ldif \
15+
&& ldapadd -x -D cn=admin,dc=qnib,dc=inc -w password -c -f users.ldif

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
1-
# plain-openldap-qniborg
2-
OpenLDAP server holding examplary QNIB organization (do not use in PROD!)
1+
# plain-openldap-qnibinc
2+
OpenLDAP server holding examplary QNIB Inc organization (do not use in PROD!)
3+
4+
## Fire up
5+
6+
```bash
7+
$ docker stack deploy -c docker-compose.yml openldap
8+
Creating network openldap_default
9+
Creating service openldap_slapd
10+
```
11+
12+
### Query User/Admins
13+
14+
```bash
15+
$ docker exec -ti $(docker ps -qf label=com.docker.swarm.service.name=openldap_slapd) ldapsearch -H ldap://localhost -LL -b ou=Users,dc=qnib,dc=inc -x
16+
version: 1
17+
18+
dn: ou=Users,dc=qnib,dc=inc
19+
objectClass: organizationalUnit
20+
ou: Users
21+
22+
dn: cn=Bob Developer,ou=Users,dc=qnib,dc=inc
23+
objectClass: inetOrgPerson
24+
cn: Bob Developer
25+
sn: Bob
26+
uid: bdev
27+
mail: bob.developer@qnib.inc
28+
description: frontend developer
29+
ou: Dev
30+
$ docker exec -ti $(docker ps -qf label=com.docker.swarm.service.name=openldap_slapd) ldapsearch -H ldap://localhost -LL -b ou=Admins,dc=qnib,dc=inc -x
31+
version: 1
32+
33+
dn: ou=Admins,dc=qnib,dc=inc
34+
objectClass: organizationalUnit
35+
ou: Admins
36+
37+
dn: cn=Alice Operation,ou=Admins,dc=qnib,dc=inc
38+
objectClass: inetOrgPerson
39+
cn: Alice Operation
40+
sn: Alice
41+
uid: aops
42+
mail: alice.ops@qnib.inc
43+
description: Administrator
44+
ou: Ops
45+
```

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: '3'
2+
services:
3+
slapd:
4+
image: qnib/plain-openldap-qnibinc@sha256:10321d39fd4e482b1bed28ae9e1331f63db608a0de3bf0588e1fd599a1495568

files/back.ldif

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 1
2+
changeType: add
3+
dn: olcDatabase=hdb,cn=config
4+
objectClass: olcDatabaseConfig
5+
objectClass: olcHdbConfig
6+
olcDatabase: {2}hdb
7+
olcDbDirectory: /var/lib/ldap
8+
olcSuffix: dc=qnib,dc=inc
9+
olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymous auth by dn="cn=admin,dc=qnib,dc=inc" write by * none
10+
olcAccess: {1}to dn.base="" by * read
11+
olcAccess: {2}to * by self write by dn="cn=admin,dc=qnib,dc=inc" write by * read
12+
olcLastMod: TRUE
13+
olcRootDN: cn=admin,dc=qnib,dc=inc
14+
olcRootPW: password
15+
olcDbCheckpoint: 512 30
16+
olcDbConfig: {0}set_cachesize 0 2097152 0
17+
olcDbConfig: {1}set_lk_max_objects 1500
18+
olcDbConfig: {2}set_lk_max_locks 1500
19+
olcDbConfig: {3}set_lk_max_lockers 1500
20+
olcDbIndex: objectClass eq
21+
olcDbIndex: uid eq
22+
olcDbIndex: cn eq

files/front.ldif

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
dn: dc=qnib,dc=inc
2+
dc: qnib
3+
objectClass: dcObject
4+
objectClass: organizationalUnit
5+
ou: qnib
6+
7+
dn: ou=UserGroups,dc=qnib,dc=inc
8+
objectClass: organizationalUnit
9+
ou: UserGroups
10+
11+
dn: ou=Users,dc=qnib,dc=inc
12+
objectClass: organizationalUnit
13+
ou: Users
14+
15+
dn: ou=Admins,dc=qnib,dc=inc
16+
objectClass: organizationalUnit
17+
ou: Admins
18+
19+
dn: ou=Roles,dc=qnib,dc=inc
20+
objectClass: organizationalUnit
21+
ou: Roles
22+
23+
dn: ou=Projects,dc=qnib,dc=inc
24+
objectClass: organizationalUnit
25+
ou: Projects
26+
27+
dn: cn=9fe2ff9ee4384b1894a90878d3e92bab,ou=Roles,dc=qnib,dc=inc
28+
objectClass: organizationalRole
29+
ou: _member_
30+
cn: 9fe2ff9ee4384b1894a90878d3e92bab

files/sssvlv_config.ldif

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dn: olcOverlay={0}sssvlv,olcDatabase={2}hdb,cn=config
2+
changeType: add
3+
objectClass: olcOverlayConfig
4+
objectClass: olcSssVlvConfig
5+
olcOverlay: {0}sssvlv
6+
olcSssVlvMax: 8
7+
olcSssVlvMaxKeys: 5

files/sssvlv_load.ldif

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dn: cn=module{0},cn=config
2+
changeType: modify
3+
add: olcModuleLoad
4+
olcModuleLoad: sssvlv.la

files/users.ldif

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
dn: cn=Alice Operation,ou=Admins,dc=qnib,dc=inc
2+
objectclass: inetOrgPerson
3+
cn: Alice Operation
4+
sn: Alice
5+
uid: aops
6+
userpassword: aops
7+
mail: alice.ops@qnib.inc
8+
description: Administrator
9+
ou: Ops
10+
11+
dn: cn=Bob Developer,ou=Users,dc=qnib,dc=inc
12+
objectclass: inetOrgPerson
13+
cn: Bob Developer
14+
sn: Bob
15+
uid: bdev
16+
userpassword: bdev
17+
mail: bob.developer@qnib.inc
18+
description: frontend developer
19+
ou: Dev

0 commit comments

Comments
 (0)