การติดตั้ง OpenLDAP Server และ OpenLDAP Client พร้อมการคอนฟิก
บทความนี้ผมจะแสดงการติดตั้งและคอนฟิก OpenLDAP Server และ Client ส่วนข้อมูลเบื้องต้นผมแสดงไว้ดังด้านล่างแล้วครับ
Software: OS-Cent OS 4.4, openldap
2.2.13-6.4E
System name: ldap.linuxgray.com
Domain name: linuxgray.com
System IP: 192.168.1.212
หมายเหตุ ชื่อ Domain และ IP คุณสามารถเปลี่ยนตามการใช้งานของแต่ละองค์กรได้
Step #1. เตรียมพร้อม Package ครับต้องมีตามนี้ครับ
compat-openldap.i386 0:2.1.30-6.4E
openldap-clients.i386
0:2.2.13-6.4E
openldap-devel.i386
0:2.2.13-6.4E
openldap-servers.i386
0:2.2.13-6.4E
openldap-servers-sql.i386
0:2.2.13-6.4E
คุณสามารถติดตั้งพวกมันได้ตามคำสั่งนี้ครับ
yum install *openldap* -y
Step #2. ทำการ Start Service ด้วยคำสั่ง
[root@ldap ~]# chkconfig --levels 235 ldap on
[root@ldap
~]# service ldap start
Step #3. ทำการสร้าง LDAP root user password
[root@ldap ~]# slappasswd
New
password:
Re-enter
new password:
{SSHA}cWB1VzxDXZLf6F4pwvyNvApBQ8G/DltW
[root@ldap
~]#
Step #4. Update /etc/openldap/slapd.conf ให้กับ root password
[root@ldap ~]# vi /etc/openldap/slapd.conf
#68 database bdb
#69 suffix "dc=linuxgray,dc=com"
#70 rootdn "cn=Manager,dc=linuxgray,dc=com"
#71 rootpw {SSHA}cWB1VzxDXZLf6F4pwvyNvApBQ8G
Step #5. Start Service ด้วยคำสั่ง
[root@ldap ~]# service ldap restart
Step #6. สร้างuser ขึ้นมา Test
[root@ldap ~]# useradd test1
[root@ldap
~]# passwd test1
Changing password for user test1.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@ldap
~]# useradd test2
[root@ldap
~]# passwd test2
Changing password for user test2.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@ldap
~]#
Step #7. ทำการเปลี่ยน local users ให้เป็น LDAP
[root@ldap ~]# grep root /etc/passwd > /etc/openldap/passwd.root
[root@ldap
~]# grep test1 /etc/passwd > /etc/openldap/passwd.test1
[root@ldap
~]# grep test2 /etc/passwd > /etc/openldap/passwd.test2
Step #8. Update ไฟล์ /usr/share/openldap/migration/migrate_common.ph
#71 $DEFAULT_MAIL_DOMAIN = "linuxgray.com";
#74 $DEFAULT_BASE = "dc=linuxgray,dc=com";
Step #9. ทำการเปลี่ยน passwd.ให้เป็นไฟล์ ldif (LDAP
Data Interchange Format)
[root@ldap ~]# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd.root
/etc/openldap/root.ldif
[root@ldap
~]# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd.test1
/etc/openldap/test1.ldif
[root@ldap
~]# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd.test2
/etc/openldap/test2.ldif
Step #10. Update ไฟล์ root.ldif ให้กับ "Manager"
LDAP Server
[root@ldap ~]# vi /etc/openldap/root.ldif
#1 dn:
uid=root,ou=People,dc=linuxgray,dc=com
#2 uid:
root
#3 cn:
Manager
#4 objectClass:
account
Step #11. สร้าง domain ldif (/etc/openldap/linuxgray.com.ldif)
[root@ldap ~]# cat /etc/openldap/linuxgray.com.ldif
dn: dc=linuxgray,dc=com
dc: linuxgray
description: LDAP Admin
objectClass: dcObject
objectClass: organizationalUnit
ou: rootobject
dn: ou=People, dc=linuxgray,dc=com
ou: People
description: Users of linuxgray
objectClass: organizationalUnit
Step #12. ทำการ Import users เข้าไปใน LDAP ด้วยคำสั่ง
[root@ldap ~]# ldapadd -x -D "cn=Manager,dc=linuxgray,dc=com" -W
- f /etc/openldap/linuxgray.com.ldif
Enter LDAP Password:
adding new entry "dc=linuxgray,dc=com"
adding new entry "ou=People, dc=linuxgray,dc=com"
[root@ldap
~]#
Step #13. ให้ทำการ Restart Service อีกครั้งครับ
[root@ldap ~]# service ldap restart
Step #14. จากนั้นลองมา Test LDAP Server กันครับ ด้วยคำสั่ง
[root@ldap ~]# ldapsearch -x -b 'dc=linuxgray,dc=com' '(objectclass=*)'
เป็นอันเสร็จเรียบร้อยครับสำหรับ OpenLDAP Server เห็นไหมครับว่าไม่ได้ยากอย่าที่หลายๆท่านคิดเลบครับ
เดี๋ยวต่อไปก็จะเป็นการติดตั้ง OpenLDAP Client บ้างครับ ว่าแล้วอย่าเสียเวลาครับ
ไปดูวิธีทำกันเลยครับแบบทีละขั้นตอนเลย
Step #1. ก่อนอื่นก็ต้องมีติดตั้ง Package กันก่อนครับเราจะใช้ YUM ครับ
[root@ldapclient ~]# yum install authconfig
Step #2. จากนั้นใช้คำสั่ง
[root@ldapclient ~]# authconfig
Step #3. จากนั้นมาทำการตั้งค่าต่างๆ ให้ตรงกับค่าที่อยู่บน OpenLDAP
Server
[*] Use LDAP [*] Use LDAP Authentication
[Both should be
checked]
Click "Next".
[ ] Use TLS
Server: ldap.linuxgray.com
Base DN: dc=linuxgray,dc=com
Click "Ok" to confirm.
เรียบร้อยครับสำหรับ OpenLDAP Client ลองทำดูครับได้ผลยังไงอย่าลืมส่งอีเมล์มาแจ้งด้วยนะครับ
โปรดติดตามบทความเรื่องต่อไปครับ
ขอบคุณครับ
|