ldap

ディレクトリ

アカウント一元管理

LDAP

ユーザ認証の統一

パッケージを調べる

#rpm -qa | grep ldap
python-ldap-2.2.0-2.1
openldap-2.3.43-3.el5
openldap-servers-2.3.43-3.el5
nss_ldap-253-17.el5
openldap-clients-2.3.43-3.el5
openldap-devel-2.3.43-3.el5
#yum -y install openldap
#chkconfig ldap on

ファイルの配置を調べる

# rpm -ql openldap
/etc/openldap
/etc/openldap/cacerts
/etc/openldap/ldap.conf
/usr/lib/liblber-2.3.so.0
/usr/lib/liblber-2.3.so.0.2.31
/usr/lib/libldap-2.3.so.0
/usr/lib/libldap-2.3.so.0.2.31
/usr/lib/libldap_r-2.3.so.0
/usr/lib/libldap_r-2.3.so.0.2.31
/usr/share/doc/openldap-2.3.43
/usr/share/doc/openldap-2.3.43/ANNOUNCEMENT
/usr/share/doc/openldap-2.3.43/CHANGES
/usr/share/doc/openldap-2.3.43/COPYRIGHT
/usr/share/doc/openldap-2.3.43/LICENSE
/usr/share/doc/openldap-2.3.43/README
/usr/share/man/man5/ldap.conf.5.gz
/usr/share/man/man5/ldif.5.gz
/usr/share/openldap

LDAPのインストール

# yum -y install openldap-servers
# yum -y install openldap-devel
# yum -y install openldap-clients
パスワードの取得
$ slappasswd -s  -h {MD5}
{MD5}fjSADpfjpwNMhg=sdg
 (こんなカンジの文字列が出力される。あとでコピペ利用します。)
# vi /etc/openldap/slap.conf

suffix    "dc=exsample,dc=com"

rootdn    "cn=Manager,dc=exsample,dc=com"

rootpw {MD5}sz8aHSDdahdi7aydD...
# vi /etc/openldap/sldap.conf

BASE dc=exsample,dc=com
# vi /etc/ldap.conf

base dc=exsample,dc=com

# cp /etc/openldap/DB_CONFIG.exsample /var/lib/ldap/DB_CONFIG
LDAPの起動と自動起動
# service ldap start
# chkconfig ldap on
# vi /usr/share/openldap/migration/migrate_common.ph
$NAMINGCONTET{'passwd'} = "Group01";


# vi /usr/share/openldap/migration/migrate_common.ph


$NAMINGCONTET{'passwd'} = "Group01"; (元がPeopleのほう)
$DEFAULT_MAIL_DOMAIN = "exsample.com"; (元がpadl.com)
$DEFAULT_BASE = "dc=exsample,dc=com";

# cd /usr/share/openldap/
# vi base.ldif




dn:     dc=exsample, dc=com
objectClass: dcObject
objectClass: organization
o: exsample   organization
dc:     exsample

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

dn:     ou=Group01,dc=exsample,dc=com
objectClass:    organizationalUnit
ou:     Group01

dn:     ou=Group02,dc=exsample,dc=com
objectClass:    organizationalUnit
ou:     Group02

# ldapadd -h localhost -x -D "cn=Manager,dc=exsample,dc=com" -W -f base.ldif
Enter LDAP Password:
adding new entry "dc=exsample, dc=com"

adding new entry "cn=Manager, dc=exsample, dc=com"

adding new entry "ou=Group01,dc=exsample,dc=com"

adding new entry "ou=Group02,dc=exsample,dc=com"

エントリの確認

slapcat

エントリの検索

ldapsearch -x -D 'cn=Manager,dc=exsample,dc=com' -W '(objectClass=*)'

グループ・ユーザーの作成

# groupadd -g 600 ldapgroup
# useradd -u 600 -g ldapgroup ldapuser

# passwd ldapuser
Changing password for user ldapuser.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

ファイアウォールの設定

LDAPに使用するポート389を許可する

LDAPコマンド

ldapadd
LDAPディレクトリにエントリ追加する
ldapmodify
エントリのデータを修正する
ldapmodrdn
エントリのRDNを変更する
ldapdelete
エントリを削除する
ldapsearch
エントリを検索する
ldapcompare
エントリに登録されている属性値と値を比較する
ldappasswd
エントリに登録されているパスワードを変更する/dd>
ldapdelete
エントリを削除する

ApacheDirectoryStudio

ApacheDirectoryStudioでLDAP設定

ApacheDirectoryServer,ApacheDirectoryStudioで直感的にLDAP操作できる。

ldapmodrdn

RDN(エントリの位置)を変更する

子エントリを持つ場合は変更できない

ldapmodrdn -x -r -D 'cn=Manager,dc=exsample,dc=com' -W  "uid=ldapuser3,ou=Group01,dc=exsample,dc=com" "uid=ldapuser,ou=Group02"

LDIF

ldapaddのとき、-f オプションで読み込む.ldifファイルの記述例

dn:uid=ldapuser2,ou=Group01,dc=exsample,dc=com
objectClass:account
objectClass:posixAccount
objectClass:shadowAccount
objectClass:top
gidNumber:601
uid: ldapuser2
uidNumber: 601
cn:ldapuser2
userPassword: {SSHA}2j3KPsi6dvRmeNTOIdg/I0WmdAgj/0LC
homeDirectory:/home/ldapuser2
loginShell:/bin/bash

エラーログ

RDN変更をしようとしたが、子エントリがあって失敗した

Rename Result: Operation not allowed on non-leaf (66)