maya's blog

About programming, aws and ubuntu

OpenLDAP + phpLDAPadmin docker compose

LPIC 202のために環境作って動作確認したので忘れないよう書いておく

環境構築

docker-compose.yml

version: '3'
services:
  openldap:
    image: osixia/openldap:1.2.5
    ports:
      - 389:389
      - 639:639
    volumes:
      - 'slapd-db:/var/lib/ldap:'
      - 'slapd-config:/etc/ldap/slapd.d'
  phpldapadmin:
    image: osixia/phpldapadmin:0.8.0
    ports:
      - 8080:80
    environment:
      PHPLDAPADMIN_LDAP_HOSTS: openldap
      PHPLDAPADMIN_HTTPS: 'false'
    links:
      - openldap
volumes:
  slapd-db:
  slapd-config:
  1. docker-compose up -d
  2. access http://localhost:8080
  3. DN: cn=admin,dc=example,dc=org, Password: admin でログイン

phpLDAPadmin login

add

sample-ou.ldif

dn: ou=Suits,dc=example,dc=org
objectCLass: organizationalUnit
ou: Suits

dn: ou=othergroup,dc=example,dc=org
objectClass: organizationalUnit
ou: othergroup

sample-add.ldif

dn: uid=MikeRoss,ou=Suits,dc=example,dc=org
changetype: add
objectClass: inetOrgPerson
cn: Mike Ross
ou: Suits
sn: Ross
uid: MikeRoss

dn: uid=HarveySpecter,ou=Suits,dc=example,dc=org
changetype: add
objectClass: inetOrgPerson
cn: Harvey Specter
ou: Suits
sn: Specter
uid: HarveySpecter

上記ファイルを用いて追加

$ ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -H ldap:// -f sample-ou.ldif
adding new entry "ou=Suits,dc=example,dc=org"

adding new entry "ou=othergroup,dc=example,dc=org"

$ ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -H ldap:// -f sample-add.ldif
adding new entry "uid=MikeRoss,ou=Suits,dc=example,dc=org"

adding new entry "uid=HarveySpecter,ou=Suits,dc=example,dc=org"

phpLDAPadmin add

delete

sample-delete.ldif

dn: ou=othergroup,dc=example,dc=org
changetype: delete

上記ファイルを用いて削除

$ ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -H ldap:// -f sample-delete.ldif
deleting entry "ou=othergroup,dc=example,dc=org"

phpLDAPadmin delete

modify

sample-modify.ldif

dn: uid=MikeRoss,ou=Suits,dc=example,dc=org
changetype: modify
add: mail
mail: mikeross@example.com

上記ファイルを用いて修正

$ ldapmodify -x -D "cn=admin,dc=example,dc=org" -w admin -H ldap:// -f sample-modify.ldif
modifying entry "uid=MikeRoss,ou=Suits,dc=example,dc=org"

phpLDAPadmin modify

Reference