パソコンやサーバの設定などのメモ - OpenLdap

Link

install

apt-get install openldap openldap-clients openldap-servers

/etc/openldap/sldap.conf

rootpw {crypt}
openssl passwd
で出たのをこぴぺ。下記追加。
access to attr=userPassword
  by anonymous auth
  by dn="cn=Admin,dc=example,dc=com" read
  by * none

access to *
  by self read
  by dn="cn=Admin,dc=example,dc=com" read
  by * none
chown root.ldap sldap.conf

初期設定

init.ldif
dn: dc=example,dc=com
objectClass: dcObject
objectClass: organization
o: myorganization
dc: aik

dn: cn=Manager,dc=example,dc=com
objectClass: organizationalRole
cn: Manager

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

dn: ou=Group,dc=example,dc=com
objectClass: organizationalUnit
ou: Group
ldapadd -x -D "cn=Admin,dc=example,dc=com" -W -f init.ldif
admin.ldif
dn: cn=Admin,dc=example,dc=com
objectClass: person
cn: Admin
sn: Admin
userPassword: {crypt}openssl passwd ででたやつ
ldapadd -x -D "cn=Admin,dc=example,dc=com" -W -f admin.ldif
ここまでやると phpLDAPadmin がうごくはず。

ユーザ認証

setup の ユーザ認証設定で、ユーザ情報と認証にLDAPチェックを追加。
/etc/pam.d/system-auth
session     required      /lib/security/$ISA/pam_mkhomedir.so skel=/etc/skel umask=0011
/etc/nsswitch.conf
passwd:     files ldap
shadow:     files ldap
group:      files ldap
/etc/ldap.conf
base dc=example,dc=com
binddn cn=Admin,dc=example,dc=com
bindpw hogefuga
・・・ nsswitch.conf に ldap を入れると、ldap の起動に異様に時間がかかる・・・なんだろう・・・
runuser: nss_ldap: failed to bind to LDAP server ldap://127.0.0.1: Can't contact LDAP server
とか。ldap が起動する前に ldap を見に行っているようなきがします。FAQな香りがしますが、ググれず・・・

逃げで、file ldap な nsswitch_ldap.conf と、file な nsswitch_file.conf をつくっておいて、/etc/initd.d/ldap を書き換えました。
起動前に command cp /etc/nsswitch_file.conf /etc/nsswitch.conf して、起動後に comnand cp /etc/nsswitch_ldap.conf /etc/nsswitch.conf してます。
/etc/nsswitch_file.conf
passwd:     files
shadow:     files
group:      files
/etc/nsswitch_ldap.conf
passwd:     files ldap
shadow:     files ldap
group:      files ldap
/etc/init.d/ldap
function start() {
        command cp -f /etc/nsswitch_file.conf /etc/nsswitch.conf
        # 省略
        command cp -f /etc/nsswitch_ldap.conf /etc/nsswitch.conf
        return $RETVAL
}