OpenLDAP備忘録

インストール

yum install openldap openldap-servers openldap-clients

slapd.d でやる場合

http://opensourcetech.hatenablog.jp/entry/2014/06/03/OpenLDAP_on_CentOS6

/etc/openldap/slapd.d/cn=config/olcDatabase={2}bdb.ldif に

olcRootPW: secret

を追加

sudo service slapd start
slapd.conf でやる場合

slapd.d いらない
mv /etc/openldap/slapd.d /etc/openldap/slapd.d.bk
slapd.conf 作る
cd /etc/openldap/
vi slapd.conf

include         /etc/openldap/schema/corba.schema
include         /etc/openldap/schema/core.schema
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/duaconf.schema
include         /etc/openldap/schema/dyngroup.schema
include         /etc/openldap/schema/inetorgperson.schema
include         /etc/openldap/schema/java.schema
include         /etc/openldap/schema/misc.schema
include         /etc/openldap/schema/nis.schema
include         /etc/openldap/schema/openldap.schema
include         /etc/openldap/schema/ppolicy.schema
include         /etc/openldap/schema/collective.schema

allow bind_v2

pidfile         /var/run/openldap/slapd.pid
argsfile        /var/run/openldap/slapd.args

#######################################################################
# ldbm and/or bdb database definitions
#######################################################################

database        bdb
suffix          "dc=my-domain,dc=com"
checkpoint      1024 15
rootdn          "cn=Manager,dc=my-domain,dc=com"
rootpw          secret


directory       /var/lib/ldap

index objectClass                       eq,pres
index ou,cn,mail,surname,givenname      eq,pres,sub
index uidNumber,gidNumber,loginShell    eq,pres
index uid,memberUid                     eq,pres,sub
index nisMapName,nisMapEntry            eq,pres,sub

database monitor

access to *
        by dn.exact="cn=Manager,dc=my-domain,dc=com" read
        by * none

access to attrs=userPassword
        by self write
        by dn="cn=Manager,dc=my-domain,dc=com" write
        by anonymous auth
        by * none

access to *
        by dn="cn=Manager,dc=my-domain,dc=com" write
        by self write
        by * read

service slapd start

とりあえず suffix と Manager を入れておく
ldapadd -x -D cn=Manager,dc=my-domain,dc=com -W -f suffix.ldif

dn: dc=my-domain,dc=com
objectClass: dcObject
objectClass: organization
dc: my-domain
o: Example Corporation

dn: cn=Manager,dc=my-domain,dc=com
objectClass: organizationalRole
cn: Manager

使う

cd /home/tkobayas/usr/exam/ldap

ldapsearch -x -h localhost -b dc=my-domain,dc=com -LLL

ldapadd -x -D cn=Manager,dc=my-domain,dc=com -W -f add.ldif

ldifはこんな感じ

dn: cn=AAAA,ou=Platform,o=portal,o=gatein,dc=my-domain,dc=com
objectClass: top
objectClass: groupOfNames
cn: AAAA
member: ou=placeholder,o=portal,o=gatein,dc=my-domain,dc=com

gatein の initial-openldap.ldif

dn: o=gatein,dc=my-domain,dc=com
objectclass: top
objectclass: organization
o: gatein

dn: o=portal,o=gatein,dc=my-domain,dc=com
objectclass: top
objectclass: organization
o: portal

dn: ou=placeholder,o=portal,o=gatein,dc=my-domain,dc=com
objectclass: top
objectclass: organizationalUnit
ou: placeholder
description: entry used to satisfy schmema restrictions for required member attribute in groupOfNames objectClass

ldapdelete -x -r -D cn=Manager,dc=my-domain,dc=com -W -f deletedn.txt

こっちは削除したいdnを並べる

ou=People,o=portal,o=gatein,dc=my-domain,dc=com
ou=Platform,o=portal,o=gatein,dc=my-domain,dc=com
ou=Organization,o=portal,o=gatein,dc=my-domain,dc=com

トラブルシューティング

GateIn 関連

GateInのopenldapサンプルは dc=my-domain,dc=com だ。 dc=example,dc=com じゃないぞ。気をつけろ!
あと、slapdはポート389を使うけど、サンプルの方は1389。サンプルを直せばいい
http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Portal_Platform/5.2/html-single/Reference_Guide/index.html#sect-Reference_Guide_eXo_JCR_1.14-LDAP_Integration
https://community.jboss.org/wiki/GateInWithLDAPInReadonlyMode
https://community.jboss.org/wiki/GateInwithLDAPasadefaultuserandgroupstore