7.19.2009

LDAP SERVER - OPENLDAP



1. Giới thiệu

Lightweight Directory Access Protocol - LDAP ( Trên Windows là Active Directory)
- là một giao thức giúp thiết kế và truy xuất dữ liệu dựa trên mô hình client-server.
-
là một loại hình database có tính mô tả cao, được tối ưu cho việc tìm kiếm.

2. Cài đặt package
openldap
openldap-clients
openldap-devel
nss-ldap
openldap-servers

3. Cấu hình LDAP Server (Máy 1)
- Tạo thư mục lưu database
#mkdir -p /var/lib/ldap/nhatnghe.com
#chown ldap:ldap /var/lib/ldap/nhatnghe.com

- tạo user ldap: tạo user hv1, hv2, hv3 và đặt password

- Cấu hình dòng 69 file /etc/openldap/slap.conf
suffix "dc=nhatnghe,dc=com"

- dòng 70
rootdn "cn=manager,dc=nhatnghe,dc=com"

- dòng 75
rootpn xxx
(xx là nội dung được tạo ra khi chạy lệnh #slappasswd)

- dòng 80
directory /var/lib/ldap/nhatnghe.com

(cn: common name; dc: domain companent)

4. Tạo LDAP Database
- Cấu hình file /usr/share/openldap/mỉgation/mỉgate_common.ph
- Gõ lệnh sau ở mode command
:%s/padl/nhatnghe/g

- tạo file cấu hình cho database
#cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/nhatnghe.com/DB_CONFIG

- Chuyển user hệ thống sang LDAP
#/usr/share/openldap/migration/migrate_all_offline.sh

- chown database ldap
#chown -R ldap:ldap /var/lib/ldap/nhatnghe.com

- Start service ldap
#chkconfig ldap on
#service ldap start

- Kiểm tra (port: 389)
#netstat -tln

- Truy vấn database
#ldapsearch -x-b "dc=nhatnghe,dc=com" '(objectclass=*)'

- truy vấn user
#ldapsearch -x-b "dc=nhatnghe,dc=com" '(uid=hv1)'


5. Cấu hình máy LDAP Client (máy 2)
#authconfig -tui

Sau đó chọn 2 ô có chữ LDAP, rồi chọn NEXT
Server: ldap://192.168.9.106
Base DN: dc=nhatnghe,dc=com

- Login với user của LDAP (hv2)