LDAPをとりあえず動かすメモ
LDAPサーバーを構築する⌗
https://qiita.com/jca02266/items/bf00acf88fde8bc29775
https://www.slideshare.net/nobuyukisasaki165/ldap-389ds-250565944
大体このへんでわかる。
てか、LDAPさわらなさすぎる間にOpenLDAPじゃなくて389 Directory Serverというのを使うのがいい感じって言われてるのね。内部的にはOpenLDAPを使ってそうな雰囲気もあるけど…
メモ⌗
割と動かすだけなら簡単にできる。
$ sudo dscreate iteractive
として、対話的にサーバーのインスタンスを設定する。インスタンスを複数作ったことはないが、多分複数作ることで1台のサーバー上で複数のLDAPサーバーを容易に動かせるようになってるんだろうな。
selinux python module not found, will not relabel files.
Selinux support will be disabled, continue? [yes]:
Enter system's hostname [himapoyo]: himapoyo.net
Enter the instance name [himapoyo]: himapoyo
Enter port number [389]: 389
Create self-signed certificate database [yes]: yes
Enter secure port number [636]: 636
Enter Directory Manager DN [cn=Directory Manager]:
Enter the Directory Manager password: PASSWORD
Confirm the Directory Manager Password: PASSWORD
Enter the database suffix (or enter "none" to skip) [dc=himapoyo,dc=net]:
Create sample entries in the suffix [no]: no
Create just the top suffix entry [no]: yes
Do you want to start the instance after the installation? [yes]: no
Are you ready to install? [no]: yes
大体こんな感じ。注意すべきは、hostnameはFQDNにして、インスタンス名は任意な感じ。ポート等も全部デフォルトにして、Directory Manager DN(BindDN)はわかりやすいやつに変更。 suffixはFQDNからdcのツリーを作るようにして、top suffix entryは作成するようにする。サーバー起動はあとでsystemdで手動で設定、起動する。
これで、起動させたらすぐにldifでデータを投入できる状態にできる。
$ ldapsearch -x -H ldap://localhost -D [BIND_DN] -W -b cn=config
上で設定した、Directory Manager DNを[BIND_DN]に設定して、上のコマンドで設定情報を参照できれば、起動できている。
あとは、LDIFを書いてデータを入れていけばデータ投入ができる。
# 例えばこんな感じとか
dn: ou=Users,dc=himapoyo,dc=net
objectClass: organizationalUnit
ou: Users
$ ldapadd -D cn=Manager -W -f sample.ldif
終わりに⌗
とりあえず動かすだけならこれで。アクセスコントロールとか諸々ちゃんと設定もしたほうがいいとは思う。