LoginSignup
2
2

More than 3 years have passed since last update.

LDAPで快適Linux環境 #2 LDAPサーバーの設定

Last updated at Posted at 2019-04-30

前回の続きで、LDAPを使った環境を実際に構築していきます。

まず、OpenLDAPをインストールします。パッケージは「slapd」と「ldap-utils」です。

root@deb:~# apt install slapd ldap-utils

インストール中、管理者パスワードの設定を求められるので任意のものを入力します。

次に、設定を確認します。

root@deb:~# slapcat

dn: dc=example,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: example.com
dc: example
structuralObjectClass: organization
entryUUID: 06569610-ee78-1036-9f61-215a0bc0a3ab
creatorsName: cn=admin,dc=exapmle,dc=com
createTimestamp: 20190426045948Z
entryCSN: 20190426045948.719889Z#000000#000#000000
modifiersName: cn=admin,dc=example,dc=com
modifyTimestamp: 20190426045948Z

dn: cn=admin,dc=example,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword:: e1NTSEF9d1ZKejV4RXZSZDF4aWtNOHJteitNdTBZWmlZM2Z0K0E=
structuralObjectClass: organizationalRole
entryUUID: 065cb18a-ee78-1036-9f62-215a0bc0a3ab
creatorsName: cn=admin,dc=example,dc=com
createTimestamp: 20190426045948Z
entryCSN: 20190426045948.759960Z#000000#000#000000
modifiersName: cn=admin,dc=example,dc=exapmle
modifyTimestamp: 20190426045948Z

環境に応じて、dnなどが変わるはずです。もし設定に間違いがあったら、

root@deb:~# dpkg-reconfigure slapd

で再設定できます。

次にユーザーとグループ用の組織単位を登録しておきます。

root@deb:~# vi base.ldif


dn: ou=people,dc=example,dc=com
objectClass: organizationalUnit
ou: people

dn: ou=groups,dc=exapmle,dc=com
objectClass: organizationalUnit
ou: groups 

root@deb:~# ldapadd -x -D cn=admin,dc=example,dc=com -W -f base.ldif

Enter LDAP Password:

adding new entry "ou=people,dc=example,dc=com"

adding new entry "ou=groups,dc=example,dc=com"

途中、パスワードを求められるのでインストール時に設定したものを入力します。dnは適宜置き換えてください。
ここでもう一手間加えます。部活で使う環境なので、学年ごとに分けて登録できるようにします。

root@deb:~# vi 1th.ldif


dn: ou=1th,ou=people,dc=example,dc=com
objectClass: organizationalUnit
ou: 1th

dn: ou=1th,ou=groups,dc=example,dc=com
objectClass: organizationalUnit
ou: 1th 

root@deb:~# ldapadd -x -D cn=admin,dc=example,dc=com -W -f 1th.ldif

Enter LDAP Password:

adding new entry "ou=1th,ou=people,dc=example,dc=com"

adding new entry "ou=1th,ou=groups,dc=exapmle,dc=com"

他の学年も数字を変えて同様にします。

続きはまた次回
令和になってLinuxがもっとメジャーになってほしいものです。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2