<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SpaLinux.com &#187; Authentication</title>
	<atom:link href="http://spalinux.com/category/authentication/feed" rel="self" type="application/rss+xml" />
	<link>http://spalinux.com</link>
	<description>Resources for Relaxing Linux System Administrators</description>
	<lastBuildDate>Mon, 26 Jul 2010 09:51:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>ติดตั้ง OpenLDAP Server บน Fedora 13</title>
		<link>http://spalinux.com/2010/07/install_openldap_server_on_fedora_13</link>
		<comments>http://spalinux.com/2010/07/install_openldap_server_on_fedora_13#comments</comments>
		<pubDate>Fri, 16 Jul 2010 08:19:45 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Server]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[fedora 13]]></category>
		<category><![CDATA[openldap]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1126</guid>
		<description><![CDATA[การเปลี่ยนแปลงอย่างหนึ่งใน Fedora เวอร์ชั่นหลังๆ คือการเปลี่ยนวิธีการคอนฟิก OpenLDAP ซึ่งจะเป็นรูปแบบใหม่ที่มีมาตั้งแต่ OpenLDAP เวอร์ชั่น 2.3 เป็นต้นมา แต่ทาง Fedora เพิ่งเริ่มนำมาใช้ แบบเก่าไฟล์คอนฟิกหลักจะอยู่ในไฟล์ /etc/openldap/slapd.conf แต่แบบใหม่คอนฟิกจะถูกเก็บแยกเป็นไฟล์ LDIF เป็นโครงสร้างอยู่ในไดเร็คทอรี /etc/openldap/slapd.d/ และเมื่อรันเซอร์วิส ไฟล์เหล่านี้จะถูกอ่านเข้าไปใน LDAP เลย ซึ่งทำให้เราสามารถแก้ไขคอนฟิกเซิร์ฟเวอร์ ได้ เหมือนกับการแก้ไขข้อมูลอื่นๆ ใน LDAP รายละเอียดเพิ่มเติมหาอ่านได้จาก ข้อมูลอ้างอิง Configuring slapd เพื่อความสะดวก ทางทีมพัฒนา OpenLDAP ได้สร้างคำสั่ง slaptest เพื่อใช้ในการเปลี่ยนคอนฟิกแบบเก่าไฟล์เดียว ให้เป็นรูปแบบใหม่ได้ ในบทความนี้จะแสดงขั้นตอนการติดตั้งและคอนฟิก OpenLDAP บนเครื่อง Fedora 13 (x86_64) ติดตั้ง openldap ใช้คำสั่ง rpm เพื่อตรวจสอบการติดตั้ง openldap ว่ามีอยู่แล้วหรือไม่ [root@fc13-64a ~]# rpm [...]]]></description>
			<content:encoded><![CDATA[<p>การเปลี่ยนแปลงอย่างหนึ่งใน Fedora เวอร์ชั่นหลังๆ คือการเปลี่ยนวิธีการคอนฟิก OpenLDAP ซึ่งจะเป็นรูปแบบใหม่ที่มีมาตั้งแต่ OpenLDAP เวอร์ชั่น 2.3 เป็นต้นมา แต่ทาง Fedora เพิ่งเริ่มนำมาใช้</p>
<p>แบบเก่าไฟล์คอนฟิกหลักจะอยู่ในไฟล์ /etc/openldap/slapd.conf แต่แบบใหม่คอนฟิกจะถูกเก็บแยกเป็นไฟล์ LDIF เป็นโครงสร้างอยู่ในไดเร็คทอรี /etc/openldap/slapd.d/ และเมื่อรันเซอร์วิส ไฟล์เหล่านี้จะถูกอ่านเข้าไปใน LDAP เลย ซึ่งทำให้เราสามารถแก้ไขคอนฟิกเซิร์ฟเวอร์ ได้ เหมือนกับการแก้ไขข้อมูลอื่นๆ ใน LDAP</p>
<p>รายละเอียดเพิ่มเติมหาอ่านได้จาก ข้อมูลอ้างอิง Configuring slapd</p>
<p>เพื่อความสะดวก ทางทีมพัฒนา OpenLDAP ได้สร้างคำสั่ง slaptest เพื่อใช้ในการเปลี่ยนคอนฟิกแบบเก่าไฟล์เดียว ให้เป็นรูปแบบใหม่ได้</p>
<p>ในบทความนี้จะแสดงขั้นตอนการติดตั้งและคอนฟิก OpenLDAP บนเครื่อง Fedora 13 (x86_64)</p>
<p><span id="more-1126"></span></p>
<h4>ติดตั้ง openldap</h4>
<p>ใช้คำสั่ง rpm เพื่อตรวจสอบการติดตั้ง openldap ว่ามีอยู่แล้วหรือไม่</p>
<pre>[root@fc13-64a ~]# <strong>rpm -qa | grep openldap
</strong>openldap-2.4.21-4.fc13.x86_64</pre>
<p>เพื่อจะคอนฟิกเป็นเซิร์ฟเวอร์ได้ ต้องติดตั้งไฟล์ rpm เพิ่มเติม บางไฟล์หาได้จากแผ่นดีวีดีติดตั้ง</p>
<pre>[root@fc13-64a ~]# <strong>mount /dev/scd0 /media
</strong>mount: block device /dev/sr0 is write-protected, mounting read-only
[root@fc13-64a ~]# <strong>cd /media/Packages/</strong></pre>
<pre>[root@fc13-64a Packages]# <strong>rpm -i libtool-ltdl-2.2.6-20.fc13.x86_64.rpm
</strong>[root@fc13-64a Packages]# <strong>rpm -i openldap-clients-2.4.21-4.fc13.x86_64.rpm</strong></pre>
<p>ดาวน์โหลดไฟล์เพิ่มเติมจาก fc13 Everything แล้วติดตั้ง</p>
<pre>[root@fc13-64a Everything]# <strong>rpm -i openldap-servers-2.4.21-4.fc13.x86_64.rpm</strong></pre>
<p>ไฟล์คอนฟิกดีฟอลต์ของ OpenLDAP จะถูกติดตั้งอยู่ใน /etc/openldap/</p>
<pre>[root@fc13-64a ~]# <strong>cd /etc/openldap/</strong></pre>
<pre>[root@fc13-64a openldap]# <strong>ls -l
</strong>total 24
drwxr-xr-x. 2 root root 4096 Feb 24 16:19 cacerts
-rw-r--r--. 1 root root  245 Feb 24 16:19 ldap.conf
drwxr-xr-x  3 root root 4096 Jul 16 20:37 schema
-rw-r-----  1 root ldap 4153 Feb 24 16:19 slapd.conf.bak
drwx------  3 ldap ldap 4096 Jul 16 20:37 slapd.d</pre>
<h4>รันเซอร์วิส</h4>
<p>ใช้คำสั่ง service เพิ่มรัน slapd (OpenLDAP server)</p>
<pre>[root@fc13-64a ~]# <strong>service slapd start
</strong>/var/lib/ldap/__db.004<span style="color: #ff0000;"> is not owned by "ldap" </span>             [WARNING]
/var/lib/ldap/__db.001 is not owned by "ldap"              [WARNING]
/var/lib/ldap/__db.002 is not owned by "ldap"              [WARNING]
/var/lib/ldap/__db.006 is not owned by "ldap"              [WARNING]
/var/lib/ldap/__db.005 is not owned by "ldap"              [WARNING]
/var/lib/ldap/alock is not owned by "ldap"                 [WARNING]
/var/lib/ldap/__db.003 is not owned by "ldap"              [WARNING]
ln: accessing `/var/run/openldap/slapd.pid': No such file or directory</pre>
<p>มีข้อผิดพลาดฟ้องเรื่อง permission ไม่ถูกต้อง</p>
<pre>[root@fc13-64a ~]# <strong>ls -l /var/lib/ldap/
</strong>total 884
-rw------- 1 <span style="color: #ff0000;">root root</span>   2048 Jul 16 20:37 alock
-rw------- 1 root root  24576 Jul 16 20:37 __db.001
-rw------- 1 root root 212992 Jul 16 20:37 __db.002
-rw------- 1 root root 270336 Jul 16 20:37 __db.003
-rw------- 1 root root 163840 Jul 16 20:37 __db.004
-rw------- 1 root root 802816 Jul 16 20:37 __db.005
-rw------- 1 root root  32768 Jul 16 20:37 __db.006</pre>
<p>ใช้คำสัง chown เพื่อเปลี่ยนเจ้าของไฟล์ (owner)</p>
<pre>[root@fc13-64a ldap]# <strong>chown ldap.ldap *
</strong>[root@fc13-64a ldap]# <strong>ls -l
</strong>total 884
-rw------- 1 <span style="color: #0000ff;">ldap ldap   </span>2048 Jul 16 20:37 alock
-rw------- 1 ldap ldap  24576 Jul 16 20:37 __db.001
-rw------- 1 ldap ldap 212992 Jul 16 20:37 __db.002
-rw------- 1 ldap ldap 270336 Jul 16 20:37 __db.003
-rw------- 1 ldap ldap 163840 Jul 16 20:37 __db.004
-rw------- 1 ldap ldap 802816 Jul 16 20:37 __db.005
-rw------- 1 ldap ldap  32768 Jul 16 20:37 __db.006</pre>
<p>ใช้คำสั่ง service เพื่อรันเซอร์วิสอีกครั้ง</p>
<pre>[root@fc13-64a ldap]# <strong>service slapd start
</strong>Starting slapd:                                            [  OK  ]</pre>
<p>ใช้คำสั่ง ps เพื่อตรวจสอบ process</p>
<pre>[root@fc13-64a ldap]# <strong>ps -ef | grep ldap
</strong>ldap     22636     1  0 21:18 ?        00:00:00 /usr/sbin/slapd -h  ldap:/// -u ldap</pre>
<p>ใช้คำสั่ง service เพื่อปิดเซอร์วิส</p>
<pre>[root@fc13-64a ldap]# <strong>service slapd stop
</strong>Stopping slapd:                                            [  OK  ]</pre>
<p>แล้วทดลองรันเซอร์วิสอีกครั้ง จะมีข้อความฟ้องเรื่อง performance</p>
<pre>[root@fc13-64a ldap]# <strong>service slapd start
</strong>Checking configuration files for slapd:                    [WARNING]
<span style="color: #ff0000;">bdb_db_open: warning - no DB_CONFIG file found in directory /var/lib/ldap: (2).
Expect poor performance for suffix "dc=my-domain,dc=com".
</span>config file testing succeeded
Starting slapd:                                            [  OK  ]</pre>
<p>ปิดเซอร์วิสอีกครั้ง</p>
<pre>[root@fc13-64a ldap]# <strong>service slapd stop
</strong>Stopping slapd:                                            [  OK  ]</pre>
<p>เพื่อปรับปรุงเรื่อง performance ต้องสร้างไฟล์ DB_CONFIG  จากตัวอย่างไฟล์ใน /usr/share/doc/openldap-servers-2.4.21/</p>
<pre>[root@fc13-64a ldap]# <strong>cp /usr/share/doc/openldap-servers-2.4.21/DB_CONFIG.example DB_CONFIG
</strong>[root@fc13-64a ldap]# <strong>chown ldap.ldap DB_CONFIG
</strong>[root@fc13-64a ldap]# <strong>chmod 600 DB_CONFIG</strong></pre>
<p>ทดสอบการเปิด/ปิด เซอร์วิส ครั้งแรกจะมีฟ้องว่า มีการปรับเปลี่ยนคอนฟิก แล้วหลังจากนั้นก็สามารถรันได้ตามปกติ</p>
<pre>[root@fc13-64a ldap]# <strong>service slapd start
</strong>Checking configuration files for slapd:                    [WARNING]
<span style="color: #0000ff;">bdb_db_open: DB_CONFIG for suffix "dc=my-domain,dc=com" has changed.
Performing database recovery to activate new settings.
</span>bdb_db_open: database "dc=my-domain,dc=com": recovery skipped in read-only mode. Run manual recovery if errors are encountered.
config file testing succeeded
Starting slapd:                                            [  OK  ]</pre>
<pre>[root@fc13-64a ldap]# <strong>service slapd stop</strong>
Stopping slapd:                                            [  OK  ]</pre>
<pre>[root@fc13-64a ldap]# <strong>service slapd start</strong>
Starting slapd:                                            [  OK  ]</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/05/install_openldap_server_on_fedora_10">ติดตั้ง OpenLDAP Server บน Fedora 10</a></li>
<li><a href="http://www.openldap.org/doc/admin24/slapdconf2.html" target="_blank">OpenLDAP Software 2.4 Administrator&#8217;s Guide: Configuring slapd</a></li>
<li><a href="http://www.mirror.in.th/osarchive/fedora/releases/13/Everything/x86_64/os/Packages/" target="_blank">Fedora 13 x86_64 Everything</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/07/install_openldap_server_on_fedora_13/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ปัญหาการใช้ SSH Public Key Authentication บน Solaris</title>
		<link>http://spalinux.com/2010/06/ssh_public_key_authentication_problem_on_solaris</link>
		<comments>http://spalinux.com/2010/06/ssh_public_key_authentication_problem_on_solaris#comments</comments>
		<pubDate>Sat, 05 Jun 2010 10:40:51 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[secure shell]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1110</guid>
		<description><![CDATA[พยายามคอนฟิก Public Key Authentication เพื่อ login เข้าสู่เครื่องที่ติดตั้ง Solaris อยู่นาน ก็ไม่สามารถทำได้ แต่ในที่สุดก็สามารถหาปัญหาได้ เลยมาแชร์ประสบการณ์เผื่อจะเป็นประโยชน์ ทดสอบปัญหา เริ่มต้นเพิ่ม user บนเครื่องที่ติดตั้ง Solaris 10 สมมติว่าชื่อ user1 [root@solaris ~]# useradd user1 [root@solaris ~]# id user1 uid=502(user1) gid=1(other) groups=1(other) แก้ไข home ของ user1 ให้อยู่ใน /export/home/ และสร้างไดเร็คทอรี [root@solaris ~]# cat /etc/passwd ... user1:x:502:1::/export/home/user1:/bin/sh [root@solaris ~]# cd /export/home [root@solaris home]# mkdir user1 [root@solaris home]# chown [...]]]></description>
			<content:encoded><![CDATA[<p>พยายามคอนฟิก Public Key Authentication เพื่อ login เข้าสู่เครื่องที่ติดตั้ง Solaris อยู่นาน ก็ไม่สามารถทำได้ แต่ในที่สุดก็สามารถหาปัญหาได้ เลยมาแชร์ประสบการณ์เผื่อจะเป็นประโยชน์</p>
<p><span id="more-1110"></span></p>
<h4>ทดสอบปัญหา</h4>
<p>เริ่มต้นเพิ่ม user บนเครื่องที่ติดตั้ง Solaris 10 สมมติว่าชื่อ user1</p>
<pre>[root@solaris ~]# <strong>useradd user1
</strong>[root@solaris ~]# <strong>id user1
</strong>uid=502(user1) gid=1(other) groups=1(other)</pre>
<p>แก้ไข home ของ user1 ให้อยู่ใน /export/home/ และสร้างไดเร็คทอรี</p>
<pre>[root@solaris ~]# <strong>cat /etc/passwd
</strong>...
user1:x:502:1::<span style="color: #0000ff;">/export/home/user1</span>:/bin/sh</pre>
<pre>[root@solaris ~]# <strong>cd /export/home
</strong>[root@solaris home]# <strong>mkdir user1
</strong>[root@solaris home]# <strong>chown user1 user1/
</strong>[root@solaris home]# <strong>su - user1
</strong>[user1@solaris ~]$ <strong>pwd
</strong>/export/home/user1</pre>
<p>ต้องการให้ admin1 จากเครื่องที่ติดตั้ง linux สามารถ ssh ด้วย public key authentication เป็น user1 บนเครื่อง Solaris ได้</p>
<p>สร้าง public, private key ของ admin1</p>
<pre>[admin1@linux ~]$ <strong>ssh-keygen -t rsa
</strong>Generating public/private rsa key pair.
Enter file in which to save the key (/home/admin1/.ssh/id_rsa):
Created directory '/home/admin1/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/admin1/.ssh/id_rsa.
Your public key has been saved in /home/admin1/.ssh/id_rsa.pub.</pre>
<pre>[admin1@linux ~]$ <strong>cat .ssh/id_rsa.pub
</strong><span style="color: #0000ff;">ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtMbbgeFnn6vEo3IAVh... admin1@linux</span></pre>
<p>copy ไฟล์ id_rsa.pub ของ admin1 ไปใส่ไว้ในไฟล์ authorized_keys ของ user1 บนเครื่อง Solaris</p>
<pre>[user1@solaris ~]$ <strong>cat .ssh/authorized_keys
</strong><span style="color: #0000ff;">ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtMbbgeFnn6vEo3IAVh... admin1@linux</span></pre>
<p>ทดสอบ ssh จากเครื่อง linux</p>
<pre>[admin1@linux ~]$ <strong>ssh -l user1 solaris
</strong>The authenticity of host 'solaris (192.168.1.2)' can't be established.
RSA key fingerprint is ...
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'solaris' (RSA) to the list of known hosts.
Password:</pre>
<p>ขึ้นให้ใส่ password ไม่สามารถ login ด้วย public key authentication ได้</p>
<h4>วิธีการแก้ไขปัญหา</h4>
<p>หลังจากพยายามอยู่นาน ก็พบว่า ssh จะตรวจสอบสถานะ password ของผู้ใช้ด้วย ซึ่งถ้าดูในไฟล์ /etc/shadow จะเห็นว่า user1 จะถูก lock อยู่</p>
<pre>[root@solaris ~]# <strong>cat /etc/shadow
</strong>...
user1:<span style="color: #ff0000;"><strong>*LK*</strong></span>:::::::</pre>
<p>ฟิลด์ที่สองในไฟล์ /etc/shadow คือ encrypted password คำอธิบายจาก man ของ shadow คือ</p>
<pre># <strong>man shadow
</strong>...
     password        An encrypted password for the user generated
                     by crypt(3C), a lock string to indicate that
                     the login is not accessible, or  no  string,
                     which  shows  that  there is no password for
                     the login.</pre>
<pre>                     The lock string is defined as <span style="color: #ff0000;"> *LK*</span>  in  the
                     first four characters of the password field.
...</pre>
<p>การแก้ไขคือ ลบตัวอักษร LK ออก เช่นให้เหลือแต่เครื่องหมาย *</p>
<pre>[root@solaris ~]# <strong>cat /etc/shadow
</strong>...
user1:<span style="color: #ff0000;">*</span>:::::::</pre>
<p>ทดสอบ ssh จากเครื่อง linux อีกครั้ง ก็จะได้ตามที่ต้องการ</p>
<pre>[admin1@linux ~]$ <strong>ssh -l user1 solaris
</strong>[user1@solaris ~]$</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/10/ssh_secure_shell_login_using_public_key_authentication">SSH – Secure Shell ล็อกอินด้วย Public Key Authentication</a></li>
<li><a href="http://forums.sun.com/thread.jspa?threadID=5229706" target="_blank">Sun Networking Services and Protocols &#8211; SSH PermitEmptyPasswords with PASSREQ</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/06/ssh_public_key_authentication_problem_on_solaris/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>รันโปรเซสเป็น user อื่น</title>
		<link>http://spalinux.com/2010/03/run_process_as_another_user</link>
		<comments>http://spalinux.com/2010/03/run_process_as_another_user#comments</comments>
		<pubDate>Sat, 06 Mar 2010 05:52:51 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Linux Shell]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Users]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[unix process]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1088</guid>
		<description><![CDATA[เป็นวิธีง่ายๆ เพื่อให้ผู้ใช้ root สามารถรันโปรเซสหรือโปรแกรมบน Linux/UNIX ภายใต้สิทธิหรือ permission ผู้ใช้ user อื่นบนเครื่องเดียวกัน คำสั่งที่ใช้คือ su ตามด้วยออปชั่น &#8216;-c&#8217; รูปแบบการใช้คำสั่งคือ # su - &#60;user_name&#62; -c "&#60;command&#62;" ตัวอย่าง root รันคำสั่ง id ภายใต้สิทธิผู้ใช้ชื่อ user1 # su - user1 -c "id" uid=501(user1) gid=100(users) groups=100(users) ข้อมูลอ้างอิง &#8216;su&#8217; man page]]></description>
			<content:encoded><![CDATA[<p>เป็นวิธีง่ายๆ เพื่อให้ผู้ใช้ root สามารถรันโปรเซสหรือโปรแกรมบน Linux/UNIX ภายใต้สิทธิหรือ permission ผู้ใช้ user อื่นบนเครื่องเดียวกัน</p>
<p><span id="more-1088"></span>คำสั่งที่ใช้คือ su ตามด้วยออปชั่น &#8216;-c&#8217; รูปแบบการใช้คำสั่งคือ</p>
<pre># su - &lt;user_name&gt; -c "&lt;command&gt;"</pre>
<p>ตัวอย่าง root รันคำสั่ง id ภายใต้สิทธิผู้ใช้ชื่อ user1</p>
<pre># <strong>su - user1 -c "id"
</strong>uid=501(user1) gid=100(users) groups=100(users)</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li>&#8216;su&#8217; man page</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/03/run_process_as_another_user/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้งและทดสอบ FreeRADIUS เบื้องต้น</title>
		<link>http://spalinux.com/2009/11/basic_install_freeradius</link>
		<comments>http://spalinux.com/2009/11/basic_install_freeradius#comments</comments>
		<pubDate>Sat, 28 Nov 2009 07:44:09 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[RADIUS]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=974</guid>
		<description><![CDATA[FreeRADIUS เป็นโปรแกรมที่ทำหน้าที่ RADIUS แบบฟรี ที่คนใช้งานกันมากที่สุด โดยมีคุณสมบัติเทียบเท่ากับ commercial RADIUS หลายๆ ตัว บทความนี้จะกล่าวถึงวิธีการติดตั้ง และทดสอบ FreeRADIUS ในเบื้องต้น เพื่อจะสามารถต่อยอด และคอนฟิกอื่นๆ เพิ่มเติมได้ ติดตั้งไฟล์ rpm ในที่นี้จะทดสอบบน Fedora 11 (x86_64) โดยใช้ไฟล์ rpm ในส่วน updates เพื่อติดตั้งและใช้งาน ใช้คำสั่ง rpm เพื่อติดตั้งไฟล์ ต่างๆ ดังนี้ [root@fc11-64a ~]# rpm -i freeradius-libs-2.1.7-1.fc11.x86_64.rpm [root@fc11-64a ~]# rpm -i freeradius-2.1.7-1.fc11.x86_64.rpm [root@fc11-64a ~]# rpm -i freeradius-utils-2.1.7-1.fc11.x86_64.rpm หมายเหตุ การติดตั้ง freeradius-utils จำเป็นต้องมี perl(DBI) ติดตั้งอยู่ก่อนแล้ว ตัวอย่าง [...]]]></description>
			<content:encoded><![CDATA[<p>FreeRADIUS เป็นโปรแกรมที่ทำหน้าที่ RADIUS แบบฟรี ที่คนใช้งานกันมากที่สุด โดยมีคุณสมบัติเทียบเท่ากับ commercial RADIUS หลายๆ ตัว</p>
<p>บทความนี้จะกล่าวถึงวิธีการติดตั้ง และทดสอบ FreeRADIUS ในเบื้องต้น เพื่อจะสามารถต่อยอด และคอนฟิกอื่นๆ เพิ่มเติมได้</p>
<h4><span id="more-974"></span><br />
ติดตั้งไฟล์ rpm</h4>
<p>ในที่นี้จะทดสอบบน Fedora 11 (x86_64) โดยใช้ไฟล์ rpm ในส่วน updates เพื่อติดตั้งและใช้งาน</p>
<p>ใช้คำสั่ง rpm เพื่อติดตั้งไฟล์ ต่างๆ ดังนี้</p>
<pre>[root@fc11-64a ~]# <strong>rpm -i freeradius-libs-2.1.7-1.fc11.x86_64.rpm
</strong>[root@fc11-64a ~]# <strong>rpm -i freeradius-2.1.7-1.fc11.x86_64.rpm
</strong>[root@fc11-64a ~]# <strong>rpm -i freeradius-utils-2.1.7-1.fc11.x86_64.rpm</strong></pre>
<p>หมายเหตุ การติดตั้ง freeradius-utils จำเป็นต้องมี perl(DBI) ติดตั้งอยู่ก่อนแล้ว</p>
<p>ตัวอย่าง error หากไม่มี perl(DBI) ติดตั้งอยู่</p>
<pre>[root@fc11-64a ~]# <strong>rpm -i freeradius-utils-2.1.7-1.fc11.x86_64.rpm
</strong>error: Failed dependencies:
        perl(DBI) is needed by freeradius-utils-2.1.7-1.fc11.x86_64</pre>
<p>วิธีการแก้ไขปัญหา</p>
<pre>[root@fc11-64a ~]# <strong>rpm -i perl-DBI-1.607-2.fc11.x86_64.rpm</strong></pre>
<h4>รันเซอร์วิส radiusd</h4>
<p>หลังจากการติดตั้ง ใช้คำสั่ง service เพื่อรันเซอร์วิส radiusd</p>
<pre>[root@fc11-64a ~]# <strong>service radiusd start
</strong>Starting RADIUS server:                                    [<strong><span style="color: #ff0000;">FAILED</span></strong>]</pre>
<p>หากยังไม่แก้ไขไฟล์คอนฟิกเลย จะไม่สามารถรันเซอร์วิส radiusd ได้ ขึ้น [FAILED]</p>
<p>เมื่อเกิดปัญหาในการใช้งาน radiusd ไฟล์หนึ่งที่สามารถตรวจสอบปัญหาได้คือไฟล์ /var/log/radius/radius.log</p>
<pre>[root@fc11-64a ~]# <strong>tail /var/log/radius/radius.log
</strong>Sat Nov 28 12:15:09 2009 : Error: rlm_eap: SSL error error:02001002:system library:fopen:<span style="color: #ff0000;">No such file or directory
</span>Sat Nov 28 12:15:09 2009 : Error: rlm_eap_tls: <span style="color: #ff0000;">Error reading certificate file /etc/raddb/certs/server.pem
</span>Sat Nov 28 12:15:09 2009 : Error: rlm_eap: Failed to initialize type tls
Sat Nov 28 12:15:09 2009 : Error: /etc/raddb/eap.conf[17]: Instantiation failed for module "eap"
Sat Nov 28 12:15:09 2009 : Error: /etc/raddb/sites-enabled/inner-tunnel[223]: Failed to find module "eap".
Sat Nov 28 12:15:09 2009 : Error: /etc/raddb/sites-enabled/inner-tunnel[176]: Errors parsing authenticate section.
Sat Nov 28 12:15:09 2009 : Error: Failed to load virtual server inner-tunnel</pre>
<p>ปัญหานี้คือไม่มีไฟล์ /etc/raddb/certs/server.pem ซึ่งเป็น certificate สำหรับการทำ EAP</p>
<p>วิธีการแก้ไขคือสร้างไฟล์ server.pem โดยเข้าไปในไดเร็คทอรี /etc/raddb/certs/ แล้วรันคำสั่ง bootstrap ซึ่งจะสร้างไฟล์ certificate ขึ้นมา</p>
<p>หมายเหตุ เพื่อความง่าย ในที่นี้จะสร้าง certificate ไฟล์ เพื่อทดสอบการใช้งาน radiusd เท่านั้น ในการใช้งานจริงก่อนที่จะสร้าง ควรจะแก้ไขคอนฟิก เพื่อระบุ Certificate Details เพื่อแสดงชื่อหน่วยงานให้ถูกต้อง</p>
<pre>[root@fc11-64a ~]# c<strong>d /etc/raddb/certs/
</strong>[root@fc11-64a certs]# <strong>./bootstrap
</strong>openssl dhparam -out dh 1024
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
.................+......................................................................................................+...+.........+.....+.......................+...................................................................................................+......................................+........................................................................................................+.................................................................+....................+...................................................................................+...................+.......................................+............................................................................+..........................................+.............+....................................+..............................................+...+.....................+...+.....+...............+.............................+..................+...................................................+.....+.................+............................................+.......+................................................................................................+....+.....+............................................................................................................................................................................................................................................+......................+........................................................................................................................................................................................................................................+............+............................+..................+.............................................................................................................................+.....................................................++*++*++*
openssl req -new  -out server.csr -keyout server.key -config ./server.cnf
Generating a 2048 bit RSA private key
.......................+++
.....+++
writing new private key to 'server.key'
-----
openssl req -new -x509 -keyout ca.key -out ca.pem \
                -days `grep default_days ca.cnf | sed 's/.*=//;s/^ *//'` -config ./ca.cnf
Generating a 2048 bit RSA private key
....................................+++
........+++
writing new private key to 'ca.key'
-----
openssl ca -batch -keyfile ca.key -cert ca.pem -in server.csr  -key `grep output_password ca.cnf | sed 's/.*=//;s/^ *//'` -out server.crt -extensions xpserver_ext -extfile xpextensions -config ./server.cnf
Using configuration from ./server.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Nov 28 05:20:32 2009 GMT
            Not After : Nov 28 05:20:32 2010 GMT
        Subject:
            countryName               = FR
            stateOrProvinceName       = Radius
            organizationName          = Example Inc.
            commonName                = Example Server Certificate
            emailAddress              = admin@example.com
        X509v3 extensions:
            X509v3 Extended Key Usage:
                TLS Web Server Authentication
Certificate is to be certified until Nov 28 05:20:32 2010 GMT (365 days)</pre>
<pre>Write out database with 1 new entries
Data Base Updated
openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12  -passin pass:`grep output_password server.cnf | sed 's/.*=//;s/^ *//'` -passout pass:`grep output_password server.cnf | sed 's/.*=//;s/^ *//'`
openssl pkcs12 -in server.p12 -out <span style="color: #3366ff;">server.pem </span>-passin pass:`grep output_password server.cnf | sed 's/.*=//;s/^ *//'` -passout pass:`grep output_password server.cnf | sed 's/.*=//;s/^ *//'`
MAC verified OK
openssl x509 -inform PEM -outform DER -in ca.pem -out ca.der</pre>
<p>หลังจากสร้างแล้ว ใช้คำสั่ง service เพื่อรันเซอร์วิส radiusd อีกครั้ง</p>
<pre>[root@fc11-64a certs]# <strong>service radiusd start
</strong>Starting RADIUS server:                                    [<span style="color: #ff0000;">FAILED</span>]</pre>
<p>รันครั้งนี้ ก็ยัง [FAILED] อยู่ ถ้าตรวจสอบดูไฟล์ radius.log มีข้อความ &#8220;Permission denied&#8221; ขึ้น ซึ่งหมายถึง radiusd ไม่สามารถอ่านไฟล์ server.pem ได้</p>
<pre>[root@fc11-64a ~]# <strong>tail /var/log/radius/radius.log
</strong>...
Sat Nov 28 12:21:38 2009 : Error: rlm_eap: SSL error error:0200100D:system library:fopen:<span style="color: #ff0000;">Permission denied
</span>Sat Nov 28 12:21:38 2009 : Error: rlm_eap_tls: <span style="color: #ff0000;">Error reading certificate file /etc/raddb/certs/server.pem
</span>Sat Nov 28 12:21:38 2009 : Error: rlm_eap: Failed to initialize type tls
Sat Nov 28 12:21:38 2009 : Error: /etc/raddb/eap.conf[17]: Instantiation failed for module "eap"
Sat Nov 28 12:21:38 2009 : Error: /etc/raddb/sites-enabled/inner-tunnel[223]: Failed to find module "eap".
Sat Nov 28 12:21:38 2009 : Error: /etc/raddb/sites-enabled/inner-tunnel[176]: Errors parsing authenticate section.
Sat Nov 28 12:21:38 2009 : Error: Failed to load virtual server inner-tunnel</pre>
<p>ปัญหานี้เกิดจากเราใช้ root เพื่อรันคำสั่ง bootstrap แล้วไฟล์ที่ถูกสร้างขึ้น owner, group จะเป็น root ทั้งหมด แต่ radiusd รันภายใต้ owner, group ที่ชื่อ radiusd ทำให้ไม่สามารถอ่านไฟล์ ที่ root สร้างขึ้นได้</p>
<p>ใช้คำสั่ง ls เพื่อตรวจสอบไฟล์ที่ root สร้างขึ้น</p>
<pre>[root@fc11-64a certs]# <strong>ls -lrt
</strong>total 108
-rw-r----- 1 root radiusd  578 2009-09-15 22:29 xpextensions
-rw-r----- 1 root radiusd 1123 2009-09-15 22:29 server.cnf
-rw-r----- 1 root radiusd 7819 2009-09-15 22:29 README
-rw-r----- 1 root radiusd 4302 2009-09-15 22:29 Makefile
-rw-r----- 1 root radiusd 1109 2009-09-15 22:29 client.cnf
-rw-r----- 1 root radiusd 1288 2009-09-15 22:29 ca.cnf
-rwxr-x--- 1 root radiusd 2072 2009-09-15 22:29 bootstrap
-rw-r----- 1 root root     245 2009-11-28 12:20 dh
-rw-r----- 1 root root    5120 2009-11-28 12:20 random
-rw-r----- 1 root root    1751 2009-11-28 12:20 server.key
-rw-r----- 1 root root    1062 2009-11-28 12:20 server.csr
-rw-r----- 1 root root    1743 2009-11-28 12:20 ca.key
-rw-r----- 1 root root    1675 2009-11-28 12:20 ca.pem
-rw-r----- 1 root root       0 2009-11-28 12:20 index.txt.old
-rw-r----- 1 root root       3 2009-11-28 12:20 serial.old
-rw-r----- 1 root root       3 2009-11-28 12:20 serial
-rw-r----- 1 root root      21 2009-11-28 12:20 index.txt.attr
-rw-r----- 1 root root     120 2009-11-28 12:20 index.txt
-rw-r----- 1 root root    4210 2009-11-28 12:20 server.crt
-rw-r----- 1 root root    4210 2009-11-28 12:20 01.pem
-rw-r----- 1 root root    2533 2009-11-28 12:20 server.p12
<span style="color: #ff0000;">-rw-r----- 1 root root    3503 2009-11-28 12:20 server.pem
</span>-rw-r----- 1 root root    1195 2009-11-28 12:20 ca.der</pre>
<p>การแก้ไขปัญหา ทำได้โดยการเปลี่ยน permission ของไฟล์ เพื่อให้ radiusd สามารถอ่านไฟล์ได้ ในที่นี้เปลี่ยนแค่ group ของไฟล์ก็เพียงพอแล้ว และเพื่อความปลอดภัยของระบบด้วย</p>
<p>ใช้คำสั่ง chgrp เพื่อเปลี่ยน group ของไฟล์</p>
<pre>[root@fc11-64a certs]# <strong>chgrp radiusd *
</strong>[root@fc11-64a certs]# <strong>ls -lrt
</strong>total 108
-rw-r----- 1 root radiusd  578 2009-09-15 22:29 xpextensions
-rw-r----- 1 root radiusd 1123 2009-09-15 22:29 server.cnf
-rw-r----- 1 root radiusd 7819 2009-09-15 22:29 README
-rw-r----- 1 root radiusd 4302 2009-09-15 22:29 Makefile
-rw-r----- 1 root radiusd 1109 2009-09-15 22:29 client.cnf
-rw-r----- 1 root radiusd 1288 2009-09-15 22:29 ca.cnf
-rwxr-x--- 1 root radiusd 2072 2009-09-15 22:29 bootstrap
-rw-r----- 1 root radiusd  245 2009-11-28 12:20 dh
-rw-r----- 1 root radiusd 5120 2009-11-28 12:20 random
-rw-r----- 1 root radiusd 1751 2009-11-28 12:20 server.key
-rw-r----- 1 root radiusd 1062 2009-11-28 12:20 server.csr
-rw-r----- 1 root radiusd 1743 2009-11-28 12:20 ca.key
-rw-r----- 1 root radiusd 1675 2009-11-28 12:20 ca.pem
-rw-r----- 1 root radiusd    0 2009-11-28 12:20 index.txt.old
-rw-r----- 1 root radiusd    3 2009-11-28 12:20 serial.old
-rw-r----- 1 root radiusd    3 2009-11-28 12:20 serial
-rw-r----- 1 root radiusd   21 2009-11-28 12:20 index.txt.attr
-rw-r----- 1 root radiusd  120 2009-11-28 12:20 index.txt
-rw-r----- 1 root radiusd 4210 2009-11-28 12:20 server.crt
-rw-r----- 1 root radiusd 4210 2009-11-28 12:20 01.pem
-rw-r----- 1 root radiusd 2533 2009-11-28 12:20 server.p12
<span style="color: #0000ff;">-rw-r----- 1 root radiusd 3503 2009-11-28 12:20 server.pem
</span>-rw-r----- 1 root radiusd 1195 2009-11-28 12:20 ca.der</pre>
<p>ใช้คำสั่ง service เพื่อรันเซอร์วิส radiusd อีกครั้ง</p>
<pre>[root@fc11-64a certs]# <strong>service radiusd start
</strong>Starting RADIUS server:                                    [  OK  ]</pre>
<p>ครั้งนี้จะสามารถรันได้ [ OK ] หากดูในไฟล์ radius.log จะมีข้อความดังนี้เกิดขึ้น</p>
<pre>[root@fc11-64a ~]# <strong>tail /var/log/radius/radius.log
</strong>...
Sat Nov 28 12:23:10 2009 : Info: Loaded virtual server inner-tunnel
Sat Nov 28 12:23:11 2009 : Info: Loaded virtual server &lt;default&gt;
Sat Nov 28 12:23:11 2009 : Info: Ready to process requests.</pre>
<p>ใช้คำสั่ง ps เพื่อ ตรวจสอบ process ของ radiusd</p>
<pre>[root@fc11-64a certs]# <strong>ps -ef | grep radiusd
</strong>radiusd   1772     1  0 12:23 ?        00:00:00 /usr/sbin/radiusd
root      1783  1393  0 12:23 pts/0    00:00:00 grep radiusd</pre>
<p>ใช้คำสั่ง netstat เพื่อตรวจสอบพอร์ตของ radiusd ที่ใช้</p>
<pre>[root@fc11-64a raddb]# <strong>netstat -a | grep udp
</strong>...
udp        0      0 *:radius                    *:*
udp        0      0 *:radius-acct               *:*
udp        0      0 *:tdp-suite                 *:*</pre>
<p>โดยดีฟอลต์ของ FreeRADIUS จะใช้พอร์ต UDP 1812, 1813, 1814 ในการทำงาน</p>
<p>ดูการ map ชื่อพอร์ตและเลขหมายของพอร์ตในไฟล์ /etc/services</p>
<pre>[root@fc11-64a ~]# <strong>cat /etc/services
</strong>...
radius          1812/udp                        # Radius
radius-acct     1813/udp        radacct         # Radius Accounting
tdp-suite       1814/udp                # TDP Suite</pre>
<h4>ทดสอบด้วย radtest</h4>
<p>จากการติดตั้ง freeradius-utils จะมีโปรแกรม radius client มาให้ด้วย คำสั่งหนึ่งที่ใช้ในการทดสอบอย่างง่ายๆ คือ radtest</p>
<pre>[root@fc11-64a ~]# <strong>radtest</strong>
Usage: radtest user passwd radius-server[:port] nas-port-number secret [ppphint] [nasname]</pre>
<p>พารามิเตอร์ที่ต้องระบุในการใช้คำสั่ง radtest คือ</p>
<ul>
<li>user                              ชื่อ username ที่ต้องการ authenticate</li>
<li>passwd                        รหัสผ่าน password สำหรับ username</li>
<li>radius-server            เป็น IP Address ของเครื่องที่รัน radiusd ทำหน้าที่เป็น RADIUS Server</li>
<li>nas-port-number    ระบุหมายเลขพอร์ต สำหรับการทดสอบจะใช้เป็นตัวเลขอะไรก็ได้</li>
<li>secret                           เป็น shared secret เพื่อต้องระบุใน RADIUS Server เพื่อเป็นการอนุญาตว่า เครื่อง RADIUS Client ใดสามารถมา authenticate ได้บ้าง</li>
</ul>
<p>ทดสอบการส่ง user, password ไปยัง radius server ที่ติดตั้ง ในที่นนี้ทดสอบบนเครื่องเดียวกัน ระบุเป็น 127.0.0.1</p>
<pre>[root@fc11-64a ~]# <strong>radtest user1 password1 127.0.0.1 1 secret1
</strong>Sending Access-Request of id 207 to 127.0.0.1 port 1812
        User-Name = "user1"
        User-Password = "password1"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: <strong><span style="color: #ff0000;">Access-Reject</span></strong> packet from host 127.0.0.1 port 1812, id=207, length=20
rad_verify: Received Access-Reject packet from client 127.0.0.1 port 1812 with invalid signature (err=2)!  (<span style="color: #ff0000;">Shared secret is incorrect.</span>)
Sending Access-Request of id 207 to 127.0.0.1 port 1812
        User-Name = "user1"
        User-Password = "password1"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=207, length=20
rad_verify: Received Access-Reject packet from client 127.0.0.1 port 1812 with invalid signature (err=2)!  (Shared secret is incorrect.)
Sending Access-Request of id 207 to 127.0.0.1 port 1812
        User-Name = "user1"
        User-Password = "password1"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=207, length=20
rad_verify: Received Access-Reject packet from client 127.0.0.1 port 1812 with invalid signature (err=2)!  (Shared secret is incorrect.)
radclient: no response from server for ID 207 socket 3</pre>
<p>ผลจากการรันคำสั่ง radtest จะฟ้อง &#8220;Access-Reject&#8221; เนื่องจาก &#8220;Shared secret is incorrect&#8221;</p>
<p>การแก้ไข คือต้องระบุ shared secret ให้ถูกต้อง</p>
<p>ในไฟล์ /etc/raddb/clients.conf จะมีคอนฟิกระบุ เครื่อง client ที่สามารถส่งข้อมูลมา authenticate ได้ แต่ต้องระบุ shared secret ให้ถูกต้อง</p>
<p>หากตัดส่วน comment &#8221;#&#8221; ออก ดีฟอลต์จากการติดตั้ง จะมีคอนฟิกสำหรับเครื่อง localhost ดังนี้</p>
<pre>client localhost {
    ipaddr = 127.0.0.1
    secret      = testing123
    require_message_authenticator = no
    nastype     = other
}</pre>
<p>จากคอนฟิก แปลว่าหากมีการส่ง request จากเครื่อง localhost หรือ 127.0.01 ต้องระบุ shared secret เป็น testing123 จึงจะใช้ server ได้</p>
<p>ทดสอบคำสั่ง radtest ด้วย shared secret ที่ถูกต้อง</p>
<pre>[root@fc11-64a ~]# <strong>radtest user1 password1 127.0.0.1 1 testing123
</strong>Sending Access-Request of id 58 to 127.0.0.1 port 1812
        User-Name = "user1"
        User-Password = "password1"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: <span style="color: #ff0000;">Access-Reject packet</span> from host 127.0.0.1 port 1812, id=58, length=20</pre>
<p>ผลการรันยังคงได้เป็น &#8220;Access-Reject&#8221; อยู่ เนื่องจาก ไม่มี username ที่ใช้ใน Server</p>
<p>ดีฟอลต์คอนฟิกเบื้องต้น จะเก็บไฟล์ username, password ไว้ในไฟล์ /etc/raddb/users โดยมีบรรทัดสุดท้ายอธิบายว่า ถ้าไม่ match หรือไม่มี username, password ที่คอนฟิกไว้ จะ denied การใช้งาน</p>
<p># On no match, the user is denied access.</p>
<p>แก้ไขไฟล์ /etc/raddb/users โดยเพิ่ม username, password ที่ต้องการ</p>
<pre>...
<span style="color: #0000ff;">user1  Cleartext-Password := "password1"
       Reply-Message = "Hello, %{User-Name}"</span></pre>
<pre># On no match, the user is denied access.</pre>
<p>ใช้คำสั่ง service เพื่อรีโหลดคอนฟิกของ radius ใหม่</p>
<pre>[root@fc11-64a ~]# <strong>service radiusd reload
</strong>Reloading RADIUS server:                                   [  OK  ]</pre>
<p>ทดสอบคำสั่ง radtest โดยระบุ user, password ที่ถูกต้องจากไฟล์ /etc/raddb/users จะได้รับ &#8220;Access-Accept&#8221;</p>
<pre>[root@fc11-64a raddb]# <strong>radtest user1 password1 127.0.0.1 1 testing123
</strong>Sending Access-Request of id 49 to 127.0.0.1 port 1812
        User-Name = "user1"
        User-Password = "password1"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: <strong><span style="color: #0000ff;">Access-Accept</span></strong> packet from host 127.0.0.1 port 1812, id=49, length=34
<span style="color: #0000ff;">        Reply-Message = "Hello, user1"</span></pre>
<p>ทดสอบด้วย user ที่มีอยู่ในไฟล์ /etc/raddb/users แต่ระบุ password ผิด จะได้รับ &#8220;Access-Reject&#8221; แต่จะได้ &#8220;Reply-Message&#8221; ของ username นั้น กลับมาด้วย</p>
<pre>[root@fc11-64a raddb]# <strong>radtest user1 password2 127.0.0.1 1 testing123
</strong>Sending Access-Request of id 76 to 127.0.0.1 port 1812
        User-Name = "user1"
        User-Password = "password2"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: <span style="color: #ff0000;"><strong>Access-Reject</strong></span> packet from host 127.0.0.1 port 1812, id=76, length=34
<span style="color: #0000ff;">        Reply-Message = "Hello, user1"</span></pre>
<p>ทดสอบด้วย user ที่ไม่มีอยู่ในไฟล์ /etc/raddb/users  จะได้รับ &#8220;Access-Reject&#8221;</p>
<pre>[root@fc11-64a raddb]# <strong>radtest user2 password2 127.0.0.1 1 testing123
</strong>Sending Access-Request of id 91 to 127.0.0.1 port 1812
        User-Name = "user2"
        User-Password = "password2"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: <span style="color: #ff0000;"><strong>Access-Reject </strong></span>packet from host 127.0.0.1 port 1812, id=91, length=20</pre>
<h4>รัน radiusd ในโหมด debug</h4>
<p>เมื่อเกิดปัญหาการคอนฟิกหรือการทำงานของ FreeRADIUS สิ่งหนึ่งที่ช่วยทำให้สามารถตรวจสอบรายละเอียดและแก้ไขปัญหาที่เกิดขึ้นได้ คือรัน radiusd ในโหมด debug ซึ่งหน้าจอจะแสดงขั้นตอนการทำงานของ radiusd อย่างละเอียด ทำให้เราสามารถทราบได้ว่า ปัญหาเกิดขึ้นที่จุดไหน</p>
<p>ใช้คำสั่ง service เพื่อหยุดรัน radiusd ในโหมดปกติ</p>
<pre>[root@fc11-64a ~]# <strong>service radiusd stop
</strong>Stopping RADIUS server:                                    [  OK  ]</pre>
<p>รันคำสั่ง radiusd ตามด้วย ออปชั่น &#8216;-X&#8217; เพื่อรันในโหมด debug หน้าจอจะแสดงรายละเอียดในการทำงานของ radiusd สังเกตว่าเมื่อรันโหมด debug จะไม่กลับคืนสู่ prompt</p>
<p>หากต้องการหยุดรันในโหมด debug สามารถทำได้โดยกด [Ctrl-C]</p>
<p>ตัวอย่างการรัน radiusd ในโหมด debug</p>
<pre>[root@fc11-64a ~]# <strong>radiusd -X
</strong>FreeRADIUS Version 2.1.7, for host x86_64-redhat-linux-gnu, built on Sep 15 2009 at 11:29:29
Copyright (C) 1999-2009 The FreeRADIUS server project and contributors.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
You may redistribute copies of FreeRADIUS under the terms of the
GNU General Public License v2.
Starting - reading configuration files ...
including configuration file /etc/raddb/radiusd.conf
including configuration file /etc/raddb/proxy.conf
including configuration file /etc/raddb/clients.conf
including files in directory /etc/raddb/modules/
including configuration file /etc/raddb/modules/acct_unique
including configuration file /etc/raddb/modules/always
including configuration file /etc/raddb/modules/attr_filter
including configuration file /etc/raddb/modules/attr_rewrite
including configuration file /etc/raddb/modules/chap
including configuration file /etc/raddb/modules/checkval
including configuration file /etc/raddb/modules/counter
including configuration file /etc/raddb/modules/cui
including configuration file /etc/raddb/modules/detail
including configuration file /etc/raddb/modules/detail.example.com
including configuration file /etc/raddb/modules/detail.log
including configuration file /etc/raddb/modules/digest
including configuration file /etc/raddb/modules/echo
including configuration file /etc/raddb/modules/etc_group
including configuration file /etc/raddb/modules/exec
including configuration file /etc/raddb/modules/expiration
including configuration file /etc/raddb/modules/expr
including configuration file /etc/raddb/modules/files
including configuration file /etc/raddb/modules/inner-eap
including configuration file /etc/raddb/modules/ippool
including configuration file /etc/raddb/modules/linelog
including configuration file /etc/raddb/modules/logintime
including configuration file /etc/raddb/modules/mac2ip
including configuration file /etc/raddb/modules/mac2vlan
including configuration file /etc/raddb/modules/mschap
including configuration file /etc/raddb/modules/otp
including configuration file /etc/raddb/modules/pam
including configuration file /etc/raddb/modules/pap
including configuration file /etc/raddb/modules/passwd
including configuration file /etc/raddb/modules/perl
including configuration file /etc/raddb/modules/policy
including configuration file /etc/raddb/modules/preprocess
including configuration file /etc/raddb/modules/radutmp
including configuration file /etc/raddb/modules/realm
including configuration file /etc/raddb/modules/smbpasswd
including configuration file /etc/raddb/modules/smsotp
including configuration file /etc/raddb/modules/sql_log
including configuration file /etc/raddb/modules/sqlcounter_expire_on_login
including configuration file /etc/raddb/modules/sradutmp
including configuration file /etc/raddb/modules/unix
including configuration file /etc/raddb/modules/wimax
including configuration file /etc/raddb/eap.conf
including configuration file /etc/raddb/policy.conf
including files in directory /etc/raddb/sites-enabled/
including configuration file /etc/raddb/sites-enabled/control-socket
including configuration file /etc/raddb/sites-enabled/default
including configuration file /etc/raddb/sites-enabled/inner-tunnel
group = radiusd
user = radiusd
including dictionary file /etc/raddb/dictionary
main {
        prefix = "/usr"
        localstatedir = "/var"
        logdir = "/var/log/radius"
        libdir = "/usr/lib64/freeradius"
        radacctdir = "/var/log/radius/radacct"
        hostname_lookups = no
        max_request_time = 30
        cleanup_delay = 5
        max_requests = 1024
        allow_core_dumps = no
        pidfile = "/var/run/radiusd/radiusd.pid"
        checkrad = "/usr/sbin/checkrad"
        debug_level = 0
        proxy_requests = yes
 log {
        stripped_names = no
        auth = no
        auth_badpass = no
        auth_goodpass = no
 }
 security {
        max_attributes = 200
        reject_delay = 1
        status_server = yes
 }
}
radiusd: #### Loading Realms and Home Servers ####
 proxy server {
        retry_delay = 5
        retry_count = 3
        default_fallback = no
        dead_time = 120
        wake_all_if_all_dead = no
 }
 home_server localhost {
        ipaddr = 127.0.0.1
        port = 1812
        type = "auth"
        secret = "testing123"
        response_window = 20
        max_outstanding = 65536
        require_message_authenticator = no
        zombie_period = 40
        status_check = "status-server"
        ping_interval = 30
        check_interval = 30
        num_answers_to_alive = 3
        num_pings_to_alive = 3
        revive_interval = 120
        status_check_timeout = 4
        irt = 2
        mrt = 16
        mrc = 5
        mrd = 30
 }
 home_server_pool my_auth_failover {
        type = fail-over
        home_server = localhost
 }
 realm example.com {
        auth_pool = my_auth_failover
 }
 realm LOCAL {
 }
radiusd: #### Loading Clients ####
 client localhost {
        ipaddr = 127.0.0.1
        require_message_authenticator = no
        secret = "testing123"
        nastype = "other"
 }
radiusd: #### Instantiating modules ####
 instantiate {
 Module: Linked to module rlm_exec
 Module: Instantiating exec
  exec {
        wait = no
        input_pairs = "request"
        shell_escape = yes
  }
 Module: Linked to module rlm_expr
 Module: Instantiating expr
 Module: Linked to module rlm_expiration
 Module: Instantiating expiration
  expiration {
        reply-message = "Password Has Expired  "
  }
 Module: Linked to module rlm_logintime
 Module: Instantiating logintime
  logintime {
        reply-message = "You are calling outside your allowed timespan  "
        minimum-timeout = 60
  }
 }
radiusd: #### Loading Virtual Servers ####
server inner-tunnel {
 modules {
 Module: Checking authenticate {...} for more modules to load
 Module: Linked to module rlm_pap
 Module: Instantiating pap
  pap {
        encryption_scheme = "auto"
        auto_header = no
  }
 Module: Linked to module rlm_chap
 Module: Instantiating chap
 Module: Linked to module rlm_mschap
 Module: Instantiating mschap
  mschap {
        use_mppe = yes
        require_encryption = no
        require_strong = no
        with_ntdomain_hack = no
  }
 Module: Linked to module rlm_unix
 Module: Instantiating unix
  unix {
        radwtmp = "/var/log/radius/radwtmp"
  }
 Module: Linked to module rlm_eap
 Module: Instantiating eap
  eap {
        default_eap_type = "md5"
        timer_expire = 60
        ignore_unknown_eap_types = no
        cisco_accounting_username_bug = no
        max_sessions = 2048
  }
 Module: Linked to sub-module rlm_eap_md5
 Module: Instantiating eap-md5
 Module: Linked to sub-module rlm_eap_leap
 Module: Instantiating eap-leap
 Module: Linked to sub-module rlm_eap_gtc
 Module: Instantiating eap-gtc
   gtc {
        challenge = "Password: "
        auth_type = "PAP"
   }
 Module: Linked to sub-module rlm_eap_tls
 Module: Instantiating eap-tls
   tls {
        rsa_key_exchange = no
        dh_key_exchange = yes
        rsa_key_length = 512
        dh_key_length = 512
        verify_depth = 0
        pem_file_type = yes
        private_key_file = "/etc/raddb/certs/server.pem"
        certificate_file = "/etc/raddb/certs/server.pem"
        CA_file = "/etc/raddb/certs/ca.pem"
        private_key_password = "whatever"
        dh_file = "/etc/raddb/certs/dh"
        random_file = "/etc/raddb/certs/random"
        fragment_size = 1024
        include_length = yes
        check_crl = no
        cipher_list = "DEFAULT"
        make_cert_command = "/etc/raddb/certs/bootstrap"
    cache {
        enable = no
        lifetime = 24
        max_entries = 255
    }
   }
 Module: Linked to sub-module rlm_eap_ttls
 Module: Instantiating eap-ttls
   ttls {
        default_eap_type = "md5"
        copy_request_to_tunnel = no
        use_tunneled_reply = no
        virtual_server = "inner-tunnel"
        include_length = yes
   }
 Module: Linked to sub-module rlm_eap_peap
 Module: Instantiating eap-peap
   peap {
        default_eap_type = "mschapv2"
        copy_request_to_tunnel = no
        use_tunneled_reply = no
        proxy_tunneled_request_as_eap = yes
        virtual_server = "inner-tunnel"
   }
 Module: Linked to sub-module rlm_eap_mschapv2
 Module: Instantiating eap-mschapv2
   mschapv2 {
        with_ntdomain_hack = no
   }
 Module: Checking authorize {...} for more modules to load
 Module: Linked to module rlm_realm
 Module: Instantiating suffix
  realm suffix {
        format = "suffix"
        delimiter = "@"
        ignore_default = no
        ignore_null = no
  }
 Module: Linked to module rlm_files
 Module: Instantiating files
  files {
        usersfile = "/etc/raddb/users"
        acctusersfile = "/etc/raddb/acct_users"
        preproxy_usersfile = "/etc/raddb/preproxy_users"
        compat = "no"
  }
 Module: Checking session {...} for more modules to load
 Module: Linked to module rlm_radutmp
 Module: Instantiating radutmp
  radutmp {
        filename = "/var/log/radius/radutmp"
        username = "%{User-Name}"
        case_sensitive = yes
        check_with_nas = yes
        perm = 384
        callerid = yes
  }
 Module: Checking post-proxy {...} for more modules to load
 Module: Checking post-auth {...} for more modules to load
 Module: Linked to module rlm_attr_filter
 Module: Instantiating attr_filter.access_reject
  attr_filter attr_filter.access_reject {
        attrsfile = "/etc/raddb/attrs.access_reject"
        key = "%{User-Name}"
  }
 } # modules
} # server
server {
 modules {
 Module: Checking authenticate {...} for more modules to load
 Module: Checking authorize {...} for more modules to load
 Module: Linked to module rlm_preprocess
 Module: Instantiating preprocess
  preprocess {
        huntgroups = "/etc/raddb/huntgroups"
        hints = "/etc/raddb/hints"
        with_ascend_hack = no
        ascend_channels_per_line = 23
        with_ntdomain_hack = no
        with_specialix_jetstream_hack = no
        with_cisco_vsa_hack = no
        with_alvarion_vsa_hack = no
  }
 Module: Checking preacct {...} for more modules to load
 Module: Linked to module rlm_acct_unique
 Module: Instantiating acct_unique
  acct_unique {
        key = "User-Name, Acct-Session-Id, NAS-IP-Address, Client-IP-Address, NAS-Port"
  }
 Module: Checking accounting {...} for more modules to load
 Module: Linked to module rlm_detail
 Module: Instantiating detail
  detail {
        detailfile = "/var/log/radius/radacct/%{Client-IP-Address}/detail-%Y%m%d"
        header = "%t"
        detailperm = 384
        dirperm = 493
        locking = no
        log_packet_header = no
  }
 Module: Instantiating attr_filter.accounting_response
  attr_filter attr_filter.accounting_response {
        attrsfile = "/etc/raddb/attrs.accounting_response"
        key = "%{User-Name}"
  }
 Module: Checking session {...} for more modules to load
 Module: Checking post-proxy {...} for more modules to load
 Module: Checking post-auth {...} for more modules to load
 } # modules
} # server
radiusd: #### Opening IP addresses and Ports ####
listen {
        type = "auth"
        ipaddr = *
        port = 0
}
listen {
        type = "acct"
        ipaddr = *
        port = 0
}
listen {
        type = "control"
 listen {
        socket = "/var/run/radiusd/radiusd.sock"
 }
}
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on command file /var/run/radiusd/radiusd.sock
Listening on proxy address * port 1814
Ready to process requests.</pre>
<p>ตัวอย่างการรัน radtest และ ข้อความในหน้าจอโหมด debug ที่แสดง</p>
<pre>[root@fc11-64a raddb]# <strong>radtest user1 password1 127.0.0.1 1 testing123
</strong>Sending Access-Request of id 118 to 127.0.0.1 port 1812
        User-Name = "user1"
        User-Password = "password1"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=118, length=34
        Reply-Message = "Hello, user1"</pre>
<p>หน้าจอโหมด debug ที่แสดง พร้อมเน้นข้อความที่เกี่ยวข้องกับการทำงานของ radiusd เมื่อได้รับการ request จากการรันคำสั่ง radtest แบบคร่าวๆ</p>
<pre>rad_recv: <span style="color: #0000ff;">Access-Request </span>packet from host 127.0.0.1 port 53435, id=118, length=57
<span style="color: #0000ff;">        User-Name = "user1"
</span><span style="color: #0000ff;">        User-Password = "password1"
        NAS-IP-Address = 192.168.1.1
        NAS-Port = 1
</span>+- entering group authorize {...}
++[preprocess] returns ok
++[chap] returns noop
++[mschap] returns noop
[suffix] <span style="color: #0000ff;">No '@' in User-Name = "user1", looking up realm NULL
</span>[suffix] No such realm "NULL"
++[suffix] returns noop
[eap] <span style="color: #0000ff;">No EAP-Message, not doing EAP
</span>++[eap] returns noop
++[unix] returns notfound
[files] <span style="color: #0000ff;">users: Matched entry user1 at line 203
</span>[files]         <span style="color: #0000ff;">expand: Hello, %{User-Name} -&gt; Hello, user1
</span>++[files] <span style="color: #0000ff;">returns ok
</span>++[expiration] returns noop
++[logintime] returns noop
++[pap] returns updated
Found Auth-Type = PAP
+- entering group PAP {...}
[pap] login attempt with password "password1"
[pap] <span style="color: #0000ff;">Using clear text password "password1"
</span>[pap] <span style="color: #0000ff;">User authenticated successfully
</span>++[pap] <span style="color: #0000ff;">returns ok
</span>+- entering group post-auth {...}
++[exec] returns noop
<span style="color: #0000ff;">Sending Access-Accept of id 118 to 127.0.0.1 port 53435
        Reply-Message = "Hello, user1"
</span>Finished request 0.
Going to the next request
Waking up in 4.9 seconds.
Cleaning up request 0 ID 118 with timestamp +58
Ready to process requests.</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://freeradius.org/" target="_blank">FreeRADIUS: The world&#8217;s most popular RADIUS Server</a></li>
<li><a href="http://mirrors.kernel.org/fedora/updates/11/x86_64/" target="_blank">Fedora 11 x86_64 updates</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/11/basic_install_freeradius/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>คอนฟิกเซอร์วิส nscd</title>
		<link>http://spalinux.com/2008/11/configure_nscd</link>
		<comments>http://spalinux.com/2008/11/configure_nscd#comments</comments>
		<pubDate>Fri, 28 Nov 2008 09:13:12 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Server]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[cache]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=348</guid>
		<description><![CDATA[ในกรณีที่คอนฟิกให้ลีนุกซ์ตรวจสอบ user, group (authenticate) จาก LDAP Server ทุกครั้งที่มีการอ้างอิง เช่นการสร้างไฟล์ หรือแสดงรายชื่อไฟล์ด้วยคำสั่ง ls ของ user หรืออื่นๆ ที่เกี่ยวข้องกับ user, group เครื่องจะต้องมีการสอบถามจาก LDAP ทุกครั้ง ทำให้บางครั้งอาจเพิ่มโหลดมากเกินไปบนตัว LDAP Server เพื่อเพิ่มประสิทธิภาพในการตรวจสอบ user, group จาก LDAP แนะนำให้รันเซอร์วิส nscd (name service cache daemon) บนเครื่อง โดยโปรแกรมนี้จะทำหน้าที่เก็บข้อมูล cache ไว้บนเครื่องตัวเอง ถ้าถามซ้ำกับข้อมูลเดิมที่มีอยู่ใน cache แล้ว ภายในระยะเวลาที่กำหนดไว้ (time to live) จะไม่มีการส่งไปถาม LDAP Server อีก ข้อเสียของการรันเซอร์วิส nscd อย่างหนึ่งคือ เรื่องการตั้งค่าเวลา (time to [...]]]></description>
			<content:encoded><![CDATA[<p>ในกรณีที่คอนฟิกให้ลีนุกซ์ตรวจสอบ user, group (authenticate) จาก LDAP Server ทุกครั้งที่มีการอ้างอิง เช่นการสร้างไฟล์ หรือแสดงรายชื่อไฟล์ด้วยคำสั่ง ls ของ user หรืออื่นๆ ที่เกี่ยวข้องกับ user, group เครื่องจะต้องมีการสอบถามจาก LDAP ทุกครั้ง ทำให้บางครั้งอาจเพิ่มโหลดมากเกินไปบนตัว LDAP Server</p>
<p>เพื่อเพิ่มประสิทธิภาพในการตรวจสอบ user, group จาก LDAP แนะนำให้รันเซอร์วิส nscd (name service cache daemon) บนเครื่อง โดยโปรแกรมนี้จะทำหน้าที่เก็บข้อมูล cache ไว้บนเครื่องตัวเอง ถ้าถามซ้ำกับข้อมูลเดิมที่มีอยู่ใน cache แล้ว ภายในระยะเวลาที่กำหนดไว้ (time to live) จะไม่มีการส่งไปถาม LDAP Server อีก</p>
<p>ข้อเสียของการรันเซอร์วิส nscd อย่างหนึ่งคือ เรื่องการตั้งค่าเวลา (time to live) ทำให้บางครั้งอาจไม่ได้ข้อมูลที่ล่าสุด เช่นดีฟอลต์เวลาที่ cache ไว้สำหรับการเก็บข้อมูลของ user คือ 600 วินาที สำหรับการค้นหาข้อมูลที่สำเร็จ (positive-time-to-live) ถ้ามีการเปลี่ยนแปลงข้อมูลของ user บน LDAP Server จะต้องรอจนเวลานี้ผ่านไป  ข้อมูล cache ใน nscd ถึงจะปรับปรุงเป็นข้อมูลใหม่</p>
<p><span id="more-348"></span></p>
<h4>ปรับปรุงเวอร์ชั่น nscd</h4>
<p>ใช้คำสั่ง rpm เพื่อตรวจสอบเวอร์ชั่นของ nscd ที่ติดตั้งอยู่</p>
<pre>[root@ldap-client ~]# <strong>rpm -q nscd</strong>
nscd-2.8-3.i386</pre>
<p>คำแนะนำ ก่อนที่จะรันเซอร์วิส nscd แนะนำให้ปรับปรุงเป็นเวอร์ชั่นล่าสุด เช่น Fedora 9 เวอร์ชั่นล่าสุดที่เขียนบทความนี้คือ nscd-2.8-8</p>
<pre>[root@ldap-client ~]# <strong>rpm -Uvh nscd-2.8-8.i386.rpm
</strong>Preparing...                ########################################### [100%]
   1:nscd                   ########################################### [100%]</pre>
<h4>คอนฟิกไฟล์ /etc/nscd.conf</h4>
<p>ไฟล์คอนฟิกจากการติดตั้ง nscd จะเก็บ cache ของ passwd, group, hosts, services ในที่นี้เราจะเปลี่ยนคอนฟิกเพื่อให้เก็บ cache เฉพาะ passwd, group จาก LDAP</p>
<pre>[root@ldap-client ~]# <strong>cat /etc/nscd.conf
</strong>#
# /etc/nscd.conf
#
server-user             nscd
debug-level             0
paranoia                no</pre>
<pre>enable-cache            passwd          yes
positive-time-to-live   passwd          600
negative-time-to-live   passwd          20
suggested-size          passwd          211
check-files             passwd          yes
persistent              passwd          yes
shared                  passwd          yes
max-db-size             passwd          33554432
auto-propagate          passwd          yes</pre>
<pre>enable-cache            group           yes
positive-time-to-live   group           3600
negative-time-to-live   group           60
suggested-size          group           211
check-files             group           yes
persistent              group           yes
shared                  group           yes
max-db-size             group           33554432
auto-propagate          group           yes</pre>
<pre>enable-cache            hosts           <strong>no</strong>
enable-cache            services        <strong>no</strong></pre>
<p><strong>คำแนะนำการคอนฟิกไฟล์ nscd.conf</strong></p>
<ul>
<li>ดีฟอลต์คอนฟิกจากการติดตั้ง จะเป็บ cache ของ user (passwd) เป็นเวลา 600 วินาที สำหรับข้อมูลที่ค้นหาได้สำเร็จ (positive-time-to-live) แต่จะเก็บ cache ของ user ที่ค้นหาไม่สำเร็จ (ไม่มีข้อมูลใน LDAP) เป็นเวลา 20 วินาที</li>
<li>ดีฟอลต์คอนฟิกจากการติดตั้ง จะเป็บ cache ของ group เป็นเวลา 3600 วินาที สำหรับข้อมูลที่ค้นหาได้สำเร็จ (positive-time-to-live) แต่จะเก็บ cache ของ group ที่ค้นหาไม่สำเร็จ (ไม่มีข้อมูลใน LDAP) เป็นเวลา 60 วินาที</li>
<li>ต้องรอเวลา time-to-live เหล่านี้หมดไป จนกว่า nscd จะทำการตรวจสอบข้อมูลจาก LDAP ใหม่อีกครั้ง ก่อนการใช้งานจริงแนะนำให้ทดลองปรับค่าแล้วดูผลลัพธ์ที่ได้</li>
</ul>
<h4>รันเซอร์วิส nscd</h4>
<p>ใช้คำสั่ง service เพื่อรันเซอร์วิส nscd</p>
<pre>[root@fc9-k2 ~]# <strong>service nscd start</strong>
Starting nscd:                                             [  OK  ]</pre>
<p>ข้อมูล cache ของ nscd จะถูกเก็บไว้ใน /var/db/nscd/</p>
<pre>[root@fc9-k2 ~]# <strong>ls -l /var/db/nscd/
</strong>total 432
-rw------- 1 root root 217016 2008-11-28 15:39 group
-rw------- 1 root root 217016 2008-11-28 15:39 passwd</pre>
<h4>ทดสอบ nscd cache</h4>
<p>ใช้คำสั่ง time เพื่อเปรียบเทียบความเร็ว ระหว่างการดึงข้อมูล user จาก LDAP ในครั้งแรก และครั้งที่สอง ดึงข้อมูลจาก cache ของ nscd</p>
<pre>[root@fc9-k2 ~]# <strong>time id user01</strong>
uid=1011(user01) gid=513(Domain Users) groups=513(Domain Users)</pre>
<pre>real    0m0.046s
user    0m0.000s
sys     0m0.007s</pre>
<pre>[root@fc9-k2 ~]# <strong>time id user01</strong>
uid=1011(user01) gid=513(Domain Users) groups=513(Domain Users)</pre>
<pre>real    0m0.007s
user    0m0.000s
sys     0m0.005s</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/10/add_user_into_openldap">เพิ่มบัญชีผู้ใช้งานเข้าไปใน OpenLDAP</a> </li>
<li><a href="http://spalinux.com/2008/07/authenticate_user_on_fedora_directory_server">คอนฟิกให้ authenticate จาก Fedora Directory Server</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/11/configure_nscd/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ไฟล์คอนฟิก openldap สำหรับ smbldap-tools</title>
		<link>http://spalinux.com/2008/11/openldap_configuration_for_smbldap-tools</link>
		<comments>http://spalinux.com/2008/11/openldap_configuration_for_smbldap-tools#comments</comments>
		<pubDate>Thu, 27 Nov 2008 16:25:07 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Server]]></category>
		<category><![CDATA[Samba]]></category>
		<category><![CDATA[ldap]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=334</guid>
		<description><![CDATA[ไฟล์คอนฟิก /etc/openldap/slapd.conf สำหรับ คอนฟิก Samba เป็น Domain Controller โดยปรับปรุงเพิ่มเติมคุณสมบัติดังนี้ กำหนดคีย์ (index) ที่ใช้ในการค้นหาข้อมูล อนุญาตให้ผู้ใช้สามารถเปลี่ยน password โดยใช้คำสั่ง smbldap-passwd ด้วยตัวเองได้ ไม่ต้องใช้ rootdn ซ่อนรหัสผ่าน (password) ไม่ให้สามารถอ่านได้โดยตรง แต่ใช้ในการตรวจสอบสิทธิ (authenticate) ได้ # ------------------------ # /etc/openldap/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 # [...]]]></description>
			<content:encoded><![CDATA[<p>ไฟล์คอนฟิก /etc/openldap/slapd.conf สำหรับ <a href="http://spalinux.com/2008/10/configure_samba_domain_controller">คอนฟิก Samba เป็น Domain Controller</a> โดยปรับปรุงเพิ่มเติมคุณสมบัติดังนี้</p>
<ul>
<li>กำหนดคีย์ (index) ที่ใช้ในการค้นหาข้อมูล</li>
<li>อนุญาตให้ผู้ใช้สามารถเปลี่ยน password โดยใช้คำสั่ง smbldap-passwd ด้วยตัวเองได้ ไม่ต้องใช้ rootdn</li>
<li>
<pre>ซ่อนรหัสผ่าน (password) ไม่ให้สามารถอ่านได้โดยตรง แต่ใช้ในการตรวจสอบสิทธิ (authenticate) ได้</pre>
</li>
</ul>
<p><span id="more-334"></span></p>
<pre># ------------------------
# /etc/openldap/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</pre>
<pre># Samba Schema
include     /etc/openldap/schema/samba.schema</pre>
<pre># Allow LDAPv2 client connections.  This is NOT the default.
allow bind_v2</pre>
<pre>pidfile     /var/run/openldap/slapd.pid
argsfile    /var/run/openldap/slapd.args</pre>
<pre># Enable Monitoring
database monitor</pre>
<pre># ldbm and/or bdb database definitions
database    bdb
suffix      "dc=test-ldap,dc=com"
rootdn      "uid=root,ou=People,dc=test-ldap,dc=com"
rootpw      {SSHA}xxx
directory   /var/lib/ldap</pre>
<pre># Indices to maintain for this database
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
index uniqueMember                      eq</pre>
<pre># required to support pdb_getsambapwrid()
index displayName                       pres,sub,eq
index sambaSID                          eq
index sambaPrimaryGroupSID              eq
index sambaDomainName                   eq
index sambaSIDList                      eq
index sambaGroupType                    eq
index default                           sub</pre>
<pre># users can authenticate and change their password
# hide password fields
access to attrs=userPassword,sambaNTPassword,sambaLMPassword,sambaPwdMustChange,sambaPwdLastSet
      by self write
      by anonymous auth
      by * none</pre>
<pre>access to attrs=shadowLastChange,shadowMax
      by self write
      by * read</pre>
<pre># all others attributes are readable to everybody
access to *
      by * read</pre>
<pre># loglevel stats stats2</pre>
<pre># EOF.</pre>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/11/openldap_configuration_for_smbldap-tools/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>คอนฟิก Samba เป็น Domain Controller</title>
		<link>http://spalinux.com/2008/10/configure_samba_domain_controller</link>
		<comments>http://spalinux.com/2008/10/configure_samba_domain_controller#comments</comments>
		<pubDate>Sat, 18 Oct 2008 11:21:54 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[File Sharing]]></category>
		<category><![CDATA[Samba]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[domain controller]]></category>
		<category><![CDATA[smbldap-tools]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=284</guid>
		<description><![CDATA[จากบทความ ติดตั้ง smbldap-tools บน Fedora 9 นั้นเป็นการคอนฟิกให้ Samba ทำหน้าที่เป็น file sharing อย่างเดียว โดยผู้ใช้งานสามารถ map drive เข้ามาแล้ว authenticate จาก LDAP ได้ ในบทความนี้จะคอนฟิกเพิ่มเติมเพื่อให้ Samba ทำหน้าที่เป็น Domain Controller ของ Windows client ได้ แก้ไขไฟล์ /etc/samba/smb.conf ต้องแก้ไขไฟล์ smb.conf เพิ่มเติมโดยในที่นี้จะแสดงคอนฟิกทั้งหมดของไฟล์นี้เลย เพื่อคอนฟิกให้ Samba ทำหน้าที่เป็น Domain Controller [global] workgroup = SMBLDAP server string = Samba Server Version %v passdb backend = ldapsam:ldap://127.0.0.1/ passwd [...]]]></description>
			<content:encoded><![CDATA[<p>จากบทความ <a href="http://spalinux.com/2008/10/install_smbldap-tools_on_fedora_9">ติดตั้ง smbldap-tools บน Fedora 9</a><a href="http://spalinux.com/wp-content/uploads/2008/10/windows_join_domain.png"></a> นั้นเป็นการคอนฟิกให้ Samba ทำหน้าที่เป็น file sharing อย่างเดียว โดยผู้ใช้งานสามารถ map drive เข้ามาแล้ว authenticate จาก LDAP ได้</p>
<p>ในบทความนี้จะคอนฟิกเพิ่มเติมเพื่อให้ Samba ทำหน้าที่เป็น Domain Controller ของ Windows client ได้</p>
<p><span id="more-284"></span></p>
<h4>แก้ไขไฟล์ /etc/samba/smb.conf</h4>
<p>ต้องแก้ไขไฟล์ smb.conf เพิ่มเติมโดยในที่นี้จะแสดงคอนฟิกทั้งหมดของไฟล์นี้เลย เพื่อคอนฟิกให้ Samba ทำหน้าที่เป็น Domain Controller</p>
<pre>[global]
 workgroup = SMBLDAP
 server string = Samba Server Version %v</pre>
<pre> passdb backend = ldapsam:ldap://127.0.0.1/
 passwd program = /usr/sbin/smbldap-passwd -u "%u"
 passwd chat = "Changing *\nNew password*" %n\n "*Retype new password*" %n\n"
 unix password sync = Yes
 log file = /var/log/samba/log.%U
 max log size = 50
 time server = Yes
 socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192</pre>
<pre> add user script = /usr/sbin/smbldap-useradd -m "%u"
 delete user script = /usr/sbin/smbldap-userdel "%u"
 add group script = /usr/sbin/smbldap-groupadd -p "%g"
 delete group script = /usr/sbin/smbldap-groupdel "%g"
 add user to group script = /usr/sbin/smbldap-groupmod -m "%u" "%g"
 delete user from group script = /usr/sbin/smbldap-groupmod -x "%u" "%g"
 set primary group script = /usr/sbin/smbldap-usermod -g '%g' '%u'
 add machine script = /usr/sbin/smbldap-useradd -t 0 -w "%u"</pre>
<pre> logon script = logon.bat
 logon path = \\%L\profiles\%u
 logon drive = H:
 domain logons = Yes
 os level = 65
 preferred master = Yes
 domain master = Yes
 wins support = Yes</pre>
<pre> ldap admin dn = uid=root,ou=People,dc=test-ldap,dc=com
 ldap group suffix = ou=Group
 ldap idmap suffix = ou=Idmap
 ldap machine suffix = ou=Computers
 ldap suffix = dc=test-ldap,dc=com
 ldap user suffix = ou=People
 cups options = raw</pre>
<pre>[homes]
 comment = Home Directories
 read only = No
 browseable = No</pre>
<pre>[profiles]
 path = /home/profiles
 read only = No
 guest ok = Yes
 browseable = No</pre>
<p>คำแนะนำ รันคำสั่ง testparm ทุกครั้งเพื่อตรวจสอบความถูกต้องของคอนฟิกไฟล์ หลังการแก้ไขไฟล์ /etc/samba/smb.conf</p>
<h4>สร้างไดเร็คทอรีสำหรับเก็บ profiles ของ user</h4>
<p>เพื่อให้ user สามารถล็อกอินจาก Windows หลายๆ เครื่องแล้วมี profiles เหมือนกัน เช่น desktop ต้องสร้างไดเร็คทอรี่บนลีนุกซ์ที่รัน Samba สำหรับเก็บ profiles ของ user</p>
<p>ตัวอย่างการสร้างไดเร็คทอรี สำหรับเก็บ profiles ของ user</p>
<pre>[root@fc9-min ~]# <strong>cd /home
</strong>[root@fc9-min home]# <strong>mkdir profiles
</strong>[root@fc9-min home]# <strong>chgrp "Domain Users" prof</strong>iles
[root@fc9-min home]# <strong>chmod 770 profil</strong>es
[root@fc9-min home]# <strong>ls -ld profiles
</strong>drwxrwx--- 2 root Domain Users 4096 2008-10-19 00:27 profiles</pre>
<h4>รันเซอร์วิส Samba</h4>
<p>เพื่อให้ Samba ทำหน้าที่เป็น Domain Controller ได้นั้น จำเป็นต้องรัน 2 เซอร์วิสคือ smb และ nmb ตามตัวอย่าง</p>
<pre>[root@fc9-min ~]# <strong>service smb start
</strong>Starting SMB services:                                     [  OK  ]</pre>
<pre>[root@fc9-min ~]# <strong>service nmb start</strong>
Starting NMB services:                                     [  OK  ]</pre>
<h4>คอนฟิก Windows ให้ join Domain</h4>
<p>ล็อกอินเป็น Administrator บนเครื่องไคลเอนต์ Windows ที่จะ join Domain คลิ้กขวาที่ My Computer แล้วเลือก Properties คลิ้กที่ Computer Name แล้วกดปุ่ม Change ใส่ชื่อ Domain ที่ต้องการ join ในที่นี้คือ SMBLDAP</p>
<p>หน้าจอ &#8220;Computer Name Changes&#8221; จะให้ใส่ User Name และ Password ที่จะใช้ join domain ให้ใส่ User Name เป็น root และใส่ password ตามที่ระบุใน rootpw</p>
<p><img title="Windows join domain" src="http://spalinux.com/wp-content/uploads/2008/10/windows_join_domain.png" alt=""/ border="1"></p>
<p>ถ้าถูกต้องจะมีหน้าจอขึ้นข้อความ &#8220;Welcome to the SMBLDAP domain.&#8221; กดปุ่ม Ok แล้วก็รีสตาร์ตเครื่อง</p>
<p><img title="Welcome to the SMBLDAP domain" src="http://spalinux.com/wp-content/uploads/2008/10/welcome_to_the_smbldap_domain.png" alt=""/ border="1"></p>
<p>หลังจากบู๊ตเครื่องเสร็จ หน้าจอ Log On to Windows จะสามารถเลือก Log on to เป็น SMBLDAP ได้ ใส่ user ที่เพิ่มจากคำสั่ง smbldap-useradd ในตัวอย่างคือ user01</p>
<p><img title="Windows Log On" src="http://spalinux.com/wp-content/uploads/2008/10/windows_log_on.png" alt="" /></p>
<p>เมื่อล๊อกออก (Log Off) จาก user01 จะมีการเก็บ profiles ของ user เข้าไปในไดเร็คทอรี บนลีนุกซ์ที่ตั้งไว้ด้วย</p>
<p>ตัวอย่างไฟล์ profiles ที่ถูกสร้างขึ้น ของ user01</p>
<pre>[root@fc9-min ~]# <strong>ls -l /home/profiles/user01/
</strong>total 568
drwx--x--x+ 4 user01 Domain Users   4096 2008-10-18 17:48 Application Data
drwx--x--x+ 2 user01 Domain Users   4096 2008-05-03 16:20 Cookies
drwx------+ 2 user01 Domain Users   4096 2008-05-03 23:12 Desktop
drwx--x--x+ 3 user01 Domain Users   4096 2008-10-18 17:49 Favorites
drwx--x--x+ 4 user01 Domain Users   4096 2008-10-18 17:49 My Documents
drwx--x--x+ 2 user01 Domain Users   4096 2008-05-03 23:12 NetHood
-rwx------  1 user01 Domain Users 524288 2008-10-18 17:54 NTUSER.DAT
-rwx------  1 user01 Domain Users   1024 2008-10-18 17:54 NTUSER.DAT.LOG
-rw-------  1 user01 Domain Users    268 2008-10-19 00:55 ntuser.ini
drwx--x--x+ 2 user01 Domain Users   4096 2008-05-03 23:12 PrintHood
drwx--x--x+ 2 user01 Domain Users   4096 2008-10-18 17:49 Recent
drwx--x--x+ 2 user01 Domain Users   4096 2008-10-18 17:48 SendTo
drwx--x--x+ 3 user01 Domain Users   4096 2008-05-03 23:12 Start Menu
drwx--x--x+ 2 user01 Domain Users   4096 2008-05-03 16:17 Templates</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/10/install_smbldap-tools_on_fedora_9">ติดตั้ง smbldap-tools บน Fedora 9</a></li>
<li><a href="http://spalinux.com/2008/10/using_smbldap-tools">การใช้งานคำสั่งของ smbldap-tools</a></li>
<li><a href="http://spalinux.com/2008/11/openldap_configuration_for_smbldap-tools">ไฟล์คอนฟิก openldap สำหรับ smbldap-tools</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/10/configure_samba_domain_controller/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>การใช้งานคำสั่งของ smbldap-tools</title>
		<link>http://spalinux.com/2008/10/using_smbldap-tools</link>
		<comments>http://spalinux.com/2008/10/using_smbldap-tools#comments</comments>
		<pubDate>Sat, 18 Oct 2008 10:11:53 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Server]]></category>
		<category><![CDATA[File Sharing]]></category>
		<category><![CDATA[Samba]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[smbldap-tools]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=271</guid>
		<description><![CDATA[ในบทความนี้จะกล่าวถึงการใช้งานโปรแกรม smbldap-tools (เวอร์ชั่น 0.9.5) สำหรับเพิ่ม แก้ไข ลบข้อมูลของ user หรือ group ที่อยู่ใน LDAP เพื่อใช้งานร่วมกับ Samba หมายเหตุ ทุกคำสั่งของ smbldap-tools สามารถที่จะดูวิธีการใช้งานโดยย่อได้ จากการรันคำสั่งที่ต้องการแล้วต่อท้ายด้วยออปชั่น &#8216;-h&#8217; หรือ &#8216;-?&#8217; หรือไม่ก็อ่านรายละเอียดการใช้งานได้จาก man page ของแต่ละคำสั่ง smbldap-useradd เพิ่ม user คำสั่ง smbldap-useradd ใช้เพิ่ม user เข้าไปใน LDAP ตัวอย่างการเพิ่ม user01 เข้าไปใน LDAP [root@fc9-min ~]# smbldap-useradd -a -m -P user01 Changing UNIX and samba passwords for user01 New password: [...]]]></description>
			<content:encoded><![CDATA[<p>ในบทความนี้จะกล่าวถึงการใช้งานโปรแกรม smbldap-tools (เวอร์ชั่น 0.9.5) สำหรับเพิ่ม แก้ไข ลบข้อมูลของ user หรือ group ที่อยู่ใน LDAP เพื่อใช้งานร่วมกับ Samba</p>
<p>หมายเหตุ ทุกคำสั่งของ smbldap-tools สามารถที่จะดูวิธีการใช้งานโดยย่อได้ จากการรันคำสั่งที่ต้องการแล้วต่อท้ายด้วยออปชั่น &#8216;-h&#8217; หรือ &#8216;-?&#8217; หรือไม่ก็อ่านรายละเอียดการใช้งานได้จาก man page ของแต่ละคำสั่ง</p>
<p><span id="more-271"></span></p>
<hr />
<h4>smbldap-useradd เพิ่ม user</h4>
<p>คำสั่ง smbldap-useradd ใช้เพิ่ม user เข้าไปใน LDAP</p>
<p>ตัวอย่างการเพิ่ม user01 เข้าไปใน LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-useradd -a -m -P user01
</strong>Changing UNIX and samba passwords for user01
New password:
Retype new password:</pre>
<p>ออปชั่นของคำสั่ง smbldap-useradd ที่ใช้ เพื่อให้ใช้งานร่วมกับ Samba ได้มีดังนี้</p>
<ul>
<li>-a    เพิ่มข้อมูล Samba ของ user</li>
<li>-m   สร้างไดเร็คทอรี่ Home ของ user ด้วย</li>
<li>-P    ให้เรียกคำสั่ง smbldap-passwd หลังจบคำสั่ง เพื่อตั้งรหัสให้ user</li>
</ul>
<p>หลังจากที่เพิ่ม user เข้าในระบบแล้ว สามารถใช้คำสั่ง id หรือ getent เพื่อตรวจสอบข้อมูลของ user ได้</p>
<pre>[root@fc9-min ~]# <strong>id user01</strong>
uid=1001(user01) gid=513(Domain Users) groups=513(Domain Users)</pre>
<pre>[root@fc9-min ~]# <strong>getent passwd user01</strong>
user01:x:1001:513:System User:/home/user01:/bin/bash</pre>
<hr />
<h4>smbldap-passwd เปลี่ยนรหัสผ่านของ user</h4>
<p>คำสั้ง smbldap-passwd ใช้เพื่อเปลี่ยนรหัสผ่านของ user ที่อยู่ใน LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-passwd user01</strong>
Changing UNIX and samba passwords for user01
New password:
Retype new password:</pre>
<hr />
<h4>smbldap-userlist แสดงรายชื่อ user</h4>
<p>คำสั่ง smbldap-userlist ใช้เพื่อแสดงรายชื่อ user ทั้งหมดที่อยู่ใน LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-userlist
</strong>uid  |username</pre>
<pre>   0 |root                 |
 999 |nobody               |
1001 |user01               |</pre>
<hr />
<h4>smbldap-usershow แสดงรายละเอียด user</h4>
<p>คำสั่ง smbldap-usershow ใช้เพื่อตรวจสอบข้อมูลทั้งหมดของ user ที่อยู่ใน LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-usershow user01</strong>
dn: uid=user01,ou=People,dc=test-ldap,dc=com
objectClass: top,person,organizationalPerson,inetOrgPerson,posixAccount,shadowAccount,sambaSamAccount
uid: user01
uidNumber: 1001
gidNumber: 513
homeDirectory: /home/user01
sambaLogonTime: 0
sambaLogoffTime: 2147483647
sambaKickoffTime: 2147483647
sambaPwdCanChange: 0
displayName: user01
sambaSID: S-1-5-21-3697236364-1357617849-1956783867-3002
sambaPrimaryGroupSID: S-1-5-21-3697236364-1357617849-1956783867-513
sambaProfilePath: \\fc9-min\profiles\user01
sambaHomePath: \\fc9-min\user01
sambaHomeDrive: H:
sambaLMPassword: C53C042BF139A7D9AAD3B435B51404EE
sambaAcctFlags: [U]
sambaNTPassword: 152E0323FE05645650DD50FD31C2FCDF
sambaPwdLastSet: 1224343354
sambaPwdMustChange: 1228231354
userPassword: {SSHA}d+ZTyu7BhUarCaM2Ifu9bk/RS0lkSi80
shadowLastChange: 14170
shadowMax: 45
gecos: System User,,,,
cn: System User
sn: User
givenName: System
loginShell: /bin/bash</pre>
<hr />
<h4>smbldap-userinfo แก้ไขข้อมูลเบื้องต้นของ user</h4>
<p>คำสั่ง smbldap-userinfo ใช้เพื่อแก้ไขข้อมูลเบื้องต้นของ user เช่น User Shell, Full Name ถ้าต้องการแก้ไขข้อมูลอื่นๆ ต้องใช้คำสั่ง smbldap-usermod</p>
<pre>[root@fc9-min ~]# <strong>smbldap-userinfo user01
</strong>Changing the user information for user01
Enter the new value, or press ENTER for the default
 User Shell [/bin/bash]:
 Full Name [System User]: <strong>User01 Full Name</strong>
 Room Number []:
 Work Phone []:
 Home Phone []:
 Other []:
LDAP updated</pre>
<p>ตรวจสอบ Full Name หลังการแก้ไขด้วยคำสั่ง getent</p>
<pre>[root@fc9-min ~]# <strong>getent passwd user01</strong>
user01:x:1001:513:User01 Full Name,,,,:/home/user01:/bin/bash</pre>
<hr />
<h4>smbldap-usermod แก้ไขข้อมูลของ user</h4>
<p>คำสั่ง smbldap-usermod ใช้เพื่อแก้ข้อมูลของ user ที่อยู่ใน LDAP โดยต้องระบุออปชั่นที่ต้องการแก้ไข</p>
<p>ตัวอย่างการใช้คำสั่ง smbldap-usermod เพื่อแก้ไข Home ของ user01</p>
<pre>[root@fc9-min ~]# <strong>smbldap-usermod -d /new-home/user01 user01</strong></pre>
<p>ตรวจสอบหลังการแก้ไข</p>
<pre>[root@fc9-min ~]# <strong>getent passwd user01
</strong>user01:x:1001:513:User01 Full Name,,,,:/new-home/user01:/bin/bash</pre>
<p>เปลี่ยนข้อมูลกลับ</p>
<pre>[root@fc9-min ~]# <strong>smbldap-usermod -d /home/user01 user01
</strong>[root@fc9-min ~]# <strong>getent passwd user01
</strong>user01:x:1001:513:User01 Full Name,,,,:/home/user01:/bin/bash</pre>
<hr />
<h4>smbldap-userdel ลบ user</h4>
<p>คำสั่ง smbldap-userdel ใช้เพื่อลบ user ออกจาก LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-userdel -r user02</strong></pre>
<hr />
<h4>smbldap-groupadd เพิ่ม group</h4>
<p>คำสั่ง smbldap-groupadd ใช้เพื่อเพิ่ม group ใหม่เข้าไปใน LDAP</p>
<p>ตัวอย่างการเพิ่ม newgroup เข้าไปใน LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-groupadd newgroup</strong></pre>
<hr />
<h4>smbldap-groupshow ดูข้อมูลของ group</h4>
<p>คำสั่ง smbldap-groupshow ใช้เพื่อดูข้อมูลรายละเอียดของ group ที่อยู่ใน LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-groupshow newgroup</strong>
dn: cn=newgroup,ou=Group,dc=test-ldap,dc=com
objectClass: top,posixGroup
cn: newgroup
gidNumber: 1000</pre>
<hr />
<h4>smbldap-groupmod แก้ไขข้อมูลของ group</h4>
<p>คำสั่ง smbldap-groupmod ใช้เพื่อแก้ไขข้อมูลของ group เช่น การเพิ่ม user เข้าไปอยู่ใน group</p>
<p>ตัวอย่างการเพิ่ม user01 เข้าไปอยู่ใน newgroup</p>
<pre>[root@fc9-min ~]# <strong>smbldap-groupmod -m user01 newgroup</strong>
adding user user01 to group newgroup</pre>
<pre>[root@fc9-min ~]# <strong>id user01
</strong>uid=1001(user01) gid=513(Domain Users) groups=513(Domain Users),1000(newgroup)</pre>
<p>ตัวอย่างการเพิ่มหลายๆ user เข้าไปใน newgroup</p>
<pre>[root@fc9-min ~]# <strong>smbldap-groupmod -m user02,user03,user04,user05 newgroup
</strong>adding user user02 to group newgroup
adding user user03 to group newgroup
adding user user04 to group newgroup
adding user user05 to group newgroup</pre>
<p>ตรวจสอบข้อมูลของ newgroup</p>
<pre>[root@fc9-min ~]# <strong>smbldap-groupshow newgroup
</strong>dn: cn=newgroup,ou=Group,dc=test-ldap,dc=com
objectClass: top,posixGroup
cn: newgroup
gidNumber: 1000
memberUid: user01,user02,user03,user04,user05</pre>
<p>ตัวอย่างการลบ user ออกจาก group</p>
<pre>[root@fc9-min ~]# <strong>smbldap-groupmod -x user01 newgroup</strong>
deleting user user01 from group newgroup</pre>
<pre>[root@fc9-min ~]# <strong>id user01
</strong>uid=1001(user01) gid=513(Domain Users) groups=513(Domain Users)</pre>
<hr />
<h4>smbldap-groupdel ลบ group</h4>
<p>คำสั่ง smbldap-groupdel ใช้เพื่อลบ group ออกจาก LDAP</p>
<p>ตัวอย่างการลบ newgroup ออกจาก LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbldap-groupdel newgroup</strong></pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li> <a href="http://spalinux.com/2008/10/install_smbldap-tools_on_fedora_9">ติดตั้ง smbldap-tools บน Fedora 9</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/10/using_smbldap-tools/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง smbldap-tools บน Fedora 9</title>
		<link>http://spalinux.com/2008/10/install_smbldap-tools_on_fedora_9</link>
		<comments>http://spalinux.com/2008/10/install_smbldap-tools_on_fedora_9#comments</comments>
		<pubDate>Sat, 18 Oct 2008 09:09:07 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Server]]></category>
		<category><![CDATA[File Sharing]]></category>
		<category><![CDATA[Samba]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[smbldap-tools]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=266</guid>
		<description><![CDATA[บทความนี้จะอธิบายการติดตั้งโปรแกรม smbldap-tools เพื่อช่วยในการคอนฟิกให้ Samba สามารถที่จะตรวจสอบ (authenticate) user จาก OpenLDAP ได้ โดยจะอ้างอิงจากการ ติดตั้ง OpenLDAP Server บน Fedora 9 ปรับปรุง samba เป็นเวอร์ชั่นล่าสุดใน Fedora 9 ในบทความนี้จะถือว่าเป็นการติดตั้ง OpenLDAP ใหม่เลย โดยไม่มีข้อมูลใดๆ อยู่ใน LDAP ติดตั้ง Perl Module ที่จำเป็น โปรแกรม smbldap-tools เขียนด้วยภาษา Perl จะเรียกใช้ Perl Module ต่างๆ ดังนั้นก่อนที่จะใช้งานได้ ต้องติดตั้ง Perl Module เหล่านี้ก่อน สำหรับ Fedora 9 สามารถดาวน์โหลดไฟล์ต่างๆ ได้จาก Fedora 9 Everything ตัวอย่างการติดตั้ง Perl [...]]]></description>
			<content:encoded><![CDATA[<p>บทความนี้จะอธิบายการติดตั้งโปรแกรม smbldap-tools เพื่อช่วยในการคอนฟิกให้ Samba สามารถที่จะตรวจสอบ (authenticate) user จาก OpenLDAP ได้ โดยจะอ้างอิงจากการ</p>
<ul>
<li><a href="http://spalinux.com/2008/10/install_openldap_server_on_fedora_9">ติดตั้ง OpenLDAP Server บน Fedora 9</a></li>
<li><a href="http://spalinux.com/2008/07/update_samba_in_fedora_9">ปรับปรุง samba เป็นเวอร์ชั่นล่าสุดใน Fedora 9</a></li>
</ul>
<p>ในบทความนี้จะถือว่าเป็นการติดตั้ง OpenLDAP ใหม่เลย โดยไม่มีข้อมูลใดๆ อยู่ใน LDAP</p>
<p><span id="more-266"></span></p>
<h4>ติดตั้ง Perl Module ที่จำเป็น</h4>
<p>โปรแกรม smbldap-tools เขียนด้วยภาษา Perl จะเรียกใช้ Perl Module ต่างๆ ดังนั้นก่อนที่จะใช้งานได้ ต้องติดตั้ง Perl Module เหล่านี้ก่อน สำหรับ Fedora 9 สามารถดาวน์โหลดไฟล์ต่างๆ ได้จาก <a href="http://mirrors.kernel.org/fedora/releases/9/Everything/" target="_blank">Fedora 9 Everything</a></p>
<p>ตัวอย่างการติดตั้ง Perl Module ที่จำเป็นตามลำดับ บน Fedora 9</p>
<pre>[root@fc9-min ~]# <strong>rpm -ivh perl-Digest-MD4-1.5-6.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Crypt-SmbHash-0.12-8.fc9.noarch.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Digest-SHA1-2.11-7.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Net-SSLeay-1.32-5.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-IO-Socket-SSL-1.12-4.fc9.noarch.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Compress-Raw-Zlib-2.008-20.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-IO-Compress-Base-2.008-20.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-IO-Compress-Zlib-2.008-20.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Compress-Zlib-2.008-20.fc9.i386.rpm</strong>
[root@fc9-min ~]# <strong>rpm -ivh perl-HTML-Tagset-3.10-8.fc9.noarch.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-HTML-Parser-3.56-5.fc9.i386.r</strong>pm
[root@fc9-min ~]# <strong>rpm -ivh perl-URI-1.35-8.fc9.noarch.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-libwww-perl-5.808-7.fc9.noarch.rpm</strong>
[root@fc9-min ~]# <strong>rpm -ivh perl-XML-LibXML-Common-0.13-13.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-XML-NamespaceSupport-1.09-4.fc9.noarch.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh --nodeps perl-XML-SAX-0.16-5.fc9.noarch.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-XML-LibXML-1.65-5.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-LDAP-0.34-4.fc9.noarch.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Jcode-2.06-6.fc9.noarch.rpm</strong>
[root@fc9-min ~]# <strong>rpm -ivh perl-Unicode-Map-0.112-14.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Unicode-String-2.09-8.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Unicode-Map8-0.12-17.fc9.i386.rpm
</strong>[root@fc9-min ~]# <strong>rpm -ivh perl-Unicode-MapUTF8-1.11-6.fc8.noarch.rpm</strong></pre>
<p>หลังจากติดตั้ง Perl Module ที่ต้องใช้เรียบร้อยแล้ว ก็ติดตั้งโปรแกรม smbldap-tools โดยสามารถดาวน์โหลดได้จากที่เดียวกัน</p>
<pre>[root@fc9-min ~]# <strong>rpm -ivh smbldap-tools-0.9.5-2.fc9.noarch.rpm</strong></pre>
<h4>รันเซอร์วิส Samba เบื้องต้น</h4>
<p>ก่อนที่จะเริ่มคอนฟิก smbldap-tools ได้นั้น จำเป็นต้องรันเซอร์วิส Samba ก่อน โดยคอนฟิกที่ต้องเปลี่ยนในไฟล์ /etc/samba/smb.conf ในเบื้องต้นนี้คือส่วน workgroup เพราะค่านี้จะถูกอ่านตอนรันคอนฟิก smbldap-tools ส่วนคอนฟิก อื่นๆ ไว้แก้ไขที่หลังได้</p>
<p>ตัวอย่างไฟล์ smb.conf ที่แก้ไข ก่อนคอนฟิก smbldap-tools</p>
<pre> workgroup = SMBLDAP</pre>
<p>ใช้คำสั่ง service เพื่อรันเซอร์วิส Samba</p>
<pre>[root@fc9-min ~]# <strong>/etc/init.d/smb start
</strong>Starting SMB services:                                     [  OK  ]</pre>
<h4>แก้ไขคอนฟิก OpenLDAP</h4>
<p>จากการติดตั้ง OpenLDAP Server ต้องเพิ่มไฟล์ schema ของ Samba เข้าไปในไฟล์ slapd.conf ด้วย</p>
<p>ตัวอย่างไฟล์ /etc/openldap/slapd.conf หลังการแก้ไข</p>
<pre>include     /etc/openldap/schema/samba.schema</pre>
<pre>suffix      "dc=test-ldap,dc=com"
rootdn      "uid=root,ou=People,dc=test-ldap,dc=com"
rootpw      {SSHA}zA4XZB4pD1TUh/mRO31MC0kbUF+V0v2Y</pre>
<p>หมายเหตุ คอนฟิกส่วน rootpw ได้มาจากการรันคำสั่ง slappasswd</p>
<p>รันเซอร์วิส OpenLDAP หลังจากแก้ไขคอนฟิกไฟล์ slapd.conf</p>
<pre>[root@fc9-min ~]# <strong>/etc/init.d/ldap start
</strong>Starting slapd:                                            [  OK  ]</pre>
<h4>รันไฟล์ configure.pl เพื่อคอนฟิก smbldap-tools</h4>
<p>ไฟล์คอนฟิกหลักของ smbldap-tools จะอยู่ในไดเร็คทอรี /etc/smbldap-tools/ ซึ่งจะประกอบด้วยคอนฟิกหลายๆ ส่วน เพื่อความสะดวกในการแก้ไขไฟล์ จากการติดตั้ง smbldap-tools จะมีไฟล์ /usr/share/doc/smbldap-tools-0.9.5/configure.pl เพื่อช่วยในการคอนฟิกไฟล์</p>
<p>ตัวอย่างรันไฟล์ configure.pl เพื่อสร้างคอนฟิกไฟล์ของ smbldap-tools</p>
<pre>[root@fc9-min ~]# <strong>/usr/share/doc/smbldap-tools-0.9.5/configure.pl
</strong>$# is no longer supported at /usr/share/doc/smbldap-tools-0.9.5/configure.pl line 314.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
       smbldap-tools script configuration
       -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Before starting, check
 . if your samba controller is up and running.
 . if the domain SID is defined (you can get it with the 'net getlocalsid')</pre>
<pre> . you can leave the configuration using the Crtl-c key combination
 . empty value can be set with the "." character
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Looking for configuration files...</pre>
<pre>Samba Configuration File Path [/etc/samba/smb.conf] &gt;</pre>
<pre>The default directory in which the smbldap configuration files are stored is shown.
If you need to change this, enter the full directory path, then press enter to continue.
Smbldap-tools Configuration Directory Path [/etc/smbldap-tools/] &gt;
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Let's start configuring the smbldap-tools scripts ...</pre>
<pre>. workgroup name: name of the domain Samba act as a PDC
  workgroup name [SMBLDAP] &gt;
. netbios name: netbios name of the samba controler
  netbios name [] &gt; <strong>fc9-min
</strong>. logon drive: local path to which the home directory will be connected (for NT Workstations). Ex: 'H:'
  logon drive [] &gt; <strong>H:
</strong>. logon home: home directory location (for Win95/98 or NT Workstation).
  (use %U as username) Ex:'\\fc9-min\%U'
  logon home (press the "." character if you don't want homeDirectory) [\\fc9-min\%U] &gt;
. logon path: directory where roaming profiles are stored. Ex:'\\fc9-min\profiles\%U'
  logon path (press the "." character if you don't want roaming profile) [\\fc9-min\profiles\%U] &gt;
. home directory prefix (use %U as username) [/home/%U] &gt;
. default users' homeDirectory mode [700] &gt;
. default user netlogon script (use %U as username) [] &gt; <strong>\\fc9-min\netlogon\%U
</strong>  default password validation time (time in days) [45] &gt;
. ldap suffix [] &gt; <strong>dc=test-ldap,dc=com
</strong>. ldap group suffix [] &gt; <strong>ou=Group
</strong>. ldap user suffix [] &gt; <strong>ou=People</strong>
. ldap machine suffix [] &gt; <strong>ou=Computers</strong>
. Idmap suffix [ou=Idmap] &gt;
. sambaUnixIdPooldn: object where you want to store the next uidNumber
  and gidNumber available for new users and groups
  sambaUnixIdPooldn object (relative to ${suffix}) [sambaDomainName=PDCTEST] &gt;
Use of uninitialized value $server in substitution (s///) at /usr/share/doc/smbldap-tools-0.9.5/configure.pl line 244, &lt;STDIN&gt; line 17.
. ldap master server: IP adress or DNS name of the master (writable) ldap server
Use of uninitialized value $example_value in concatenation (.) or string at /usr/share/doc/smbldap-tools-0.9.5/configure.pl line 161, &lt;STDIN&gt; line 17.
Use of uninitialized value $example_value in string at /usr/share/doc/smbldap-tools-0.9.5/configure.pl line 162, &lt;STDIN&gt; line 17.
  ldap master server [] &gt; <strong>127.0.0.1
</strong>. ldap master port [389] &gt;
. ldap master bind dn [] &gt; <strong>uid=root,ou=People,dc=test-ldap,dc=com</strong>
. ldap master bind password [] &gt;
. ldap slave server: IP adress or DNS name of the slave ldap server: can also be the master one
Use of uninitialized value $server in string at /usr/share/doc/smbldap-tools-0.9.5/configure.pl line 262, &lt;STDIN&gt; line 21.
  ldap slave server [] &gt; <strong>127.0.0.1</strong>
. ldap slave port [389] &gt;
. ldap slave bind dn [] &gt; <strong>uid=root,ou=People,dc=test-ldap,dc=com</strong>
. ldap slave bind password [] &gt;
. ldap tls support (1/0) [0] &gt;
. SID for domain PDCTEST: SID of the domain (can be obtained with 'net getlocalsid fc9-min')
  SID for domain PDCTEST [S-1-5-21-3697236364-1357617849-1956783867] &gt;
. unix password encryption: encryption used for unix passwords
  unix password encryption (CRYPT, MD5, SMD5, SSHA, SHA) [SSHA] &gt;
. default user gidNumber [513] &gt;
. default computer gidNumber [515] &gt;
. default login shell [/bin/bash] &gt;
. default skeleton directory [/etc/skel] &gt;
. default domain name to append to mail adress [] &gt;
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Use of uninitialized value $# in concatenation (.) or string at /usr/share/doc/smbldap-tools-0.9.5/configure.pl line 314, &lt;STDIN&gt; line 33.
backup old configuration files:
  /etc/smbldap-tools/smbldap.conf-&gt;/etc/smbldap-tools/smbldap.conf.old
  /etc/smbldap-tools/smbldap_bind.conf-&gt;/etc/smbldap-tools/smbldap_bind.conf.old
writing new configuration file:
  /etc/smbldap-tools/smbldap.conf done.
  /etc/smbldap-tools/smbldap_bind.conf done.</pre>
<h4>รันคำสั่ง smbldap-populate</h4>
<p>โปรแกรม smbldap-tools จะมีคำสั่ง smbldap-populate เพื่อช่วยเพิ่มข้อมูลเข้าไปใน OpenLDAP โดยจะอ้างอิงจากคอนฟิกที่รันด้วย configure.pl</p>
<p>หมายเหตุ ในที่นี้จะถือว่า ไม่มีข้อมูลใดๆ อยู่ใน OpenLDAP เลย</p>
<p>ตัวอย่างการรันคำสั่ง smbldap-populate</p>
<pre>[root@fc9-min openldap]# <strong>smbldap-populate
</strong>Populating LDAP directory for domain PDCTEST (S-1-5-21-3697236364-1357617849-1956783867)
(using builtin directory structure)</pre>
<pre>adding new entry: dc=test-ldap,dc=com
adding new entry: ou=People,dc=test-ldap,dc=com
adding new entry: ou=Group,dc=test-ldap,dc=com
adding new entry: ou=Computers,dc=test-ldap,dc=com
adding new entry: ou=Idmap,dc=test-ldap,dc=com
adding new entry: uid=root,ou=People,dc=test-ldap,dc=com
adding new entry: uid=nobody,ou=People,dc=test-ldap,dc=com
adding new entry: cn=Domain Admins,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Domain Users,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Domain Guests,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Domain Computers,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Administrators,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Account Operators,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Print Operators,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Backup Operators,ou=Group,dc=test-ldap,dc=com
adding new entry: cn=Replicators,ou=Group,dc=test-ldap,dc=com
adding new entry: sambaDomainName=PDCTEST,dc=test-ldap,dc=com</pre>
<pre>Please provide a password for the domain root:
Changing UNIX and samba passwords for root
New password: <strong>ldap1234</strong>
Retype new password: <strong>ldap1234</strong></pre>
<p>หมายเหตุ Password ที่ใส่ในส่วนท้ายของคำสั่ง smbldap-populate เป็น rootpw ที่ระบุในไฟล์ /etc/openldap/slapd.conf</p>
<h4>รันคำสั่ง smbpasswd</h4>
<p>รันคำสั่ง smbpasswd เพื่อใส่ ldap admin password ที่ Samba ใช้ในการเชื่อมต่อกับ LDAP</p>
<pre>[root@fc9-min ~]# <strong>smbpasswd -w ldap1234</strong>
Setting stored password for "uid=root,ou=People,dc=test-ldap,dc=com" in secrets.tdb</pre>
<p>หมายเหตุ &#8216;ldap1234&#8242; คือ rootpw ที่ระบุในไฟล์ /etc/openldap/slapd.conf</p>
<h4>คอนฟิกให้ลีนุกซ์ ตรวจสอบผู้ใช้งานจาก LDAP</h4>
<p>ใช้คำสั่ง authconfig-tui เพื่อคอนฟิกให้ ลีนุกซ์ตรวจสอบผู้ใช้งานหรือ authenticate จาก LDAP</p>
<h4>คอนฟิก Samba ให้ authenticate จาก LDAP</h4>
<p>แก้ไขคอนฟิกไฟล์ของ Samba เพื่อให้ authenticate จาก ldap</p>
<p>ตัวอย่างไฟล์ /etc/samba/smb.conf ที่แก้ไขเพิ่มเติม</p>
<pre> workgroup = SMBLDAP
 security = user
 passdb backend = ldapsam:ldap://127.0.0.1/</pre>
<pre> ldap suffix = dc=test-ldap,dc=com
 ldap admin dn = uid=root,ou=People,dc=test-ldap,dc=com
 ldap group suffix = ou=Group
 ldap user suffix = ou=People</pre>
<h4>เพิ่ม user ใน LDAP</h4>
<pre>[root@fc9-min ~]# <strong>smbldap-useradd -a -m -s /bin/bash -d /home/user01 -P user01</strong>
Changing UNIX and samba passwords for user01
New password:
Retype new password:</pre>
<h4>ทดสอบด้วยคำสั่ง smbclient</h4>
<p>ใช้คำสั่ง smbclient เพื่อทดสอบการใช้ Samba เพื่อ authenticate ผู้ใช้จาก LDAP</p>
<p>ตัวอย่างการทดสอบด้วยคำสั่ง smbclient</p>
<pre>[root@fc9-min samba]# <strong>smbclient '\\localhost\user01' -U user01</strong>
Enter user01's password:
Domain=[fc9-min] OS=[Unix] Server=[Samba 3.2.3-0.20.fc9]
smb: \&gt; <strong>dir
</strong>  .                                   D        0  Sat Oct 18 12:21:59 2008
  ..                                  D        0  Sat Oct 18 11:38:30 2008
  .bashrc                             H      124  Sat Oct 18 11:38:30 2008
  .bash_logout                        H       18  Sat Oct 18 11:38:30 2008
  .bash_profile                       H      176  Sat Oct 18 11:38:30 2008</pre>
<pre>                60160 blocks of size 65536. 55959 blocks available
smb: \&gt; <strong>exit</strong></pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/10/install_openldap_server_on_fedora_9">ติดตั้ง OpenLDAP Server บน Fedora 9</a></li>
<li><a href="http://spalinux.com/2008/07/update_samba_in_fedora_9" target="_self">ปรับปรุง samba เป็นเวอร์ชั่นล่าสุดใน Fedora 9</a></li>
<li><a href="http://spalinux.com/2008/10/using_smbldap-tools">การใช้งานคำสั่งของ smbldap-tools</a></li>
<li><a href="http://spalinux.com/2008/10/configure_samba_domain_controller">คอนฟิก Samba เป็น Domain Controller</a></li>
<li><a href="http://www.iallanis.info/smbldap-tools/docs/smbldap-tools/" target="_blank">Smbldap-tools User Manual</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/10/install_smbldap-tools_on_fedora_9/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>เพิ่ม แก้ไข ลบ ผู้ใช้งานใน OpenLDAP</title>
		<link>http://spalinux.com/2008/10/add_modify_delete_user_in_openldap</link>
		<comments>http://spalinux.com/2008/10/add_modify_delete_user_in_openldap#comments</comments>
		<pubDate>Sat, 11 Oct 2008 18:38:23 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Server]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[openldap]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=255</guid>
		<description><![CDATA[จากบทความ ติดตั้ง OpenLDAP Server บน Fedora 9 และ เพิ่มบัญชีผู้ใช้งานเข้าไปใน OpenLDAP  ในบทความนี้จะแสดงวิธีการเพิ่ม แก้ไข ลบ รวมทั้งการเปลี่ยนรหัสผ่าน (Password) ของผู้ใช้งานที่ถูกเก็บข้อมูลไว้ใน OpenLDAP  โดยจะสร้างเป็นไฟล์ ldif แล้วใช้คำสั่งของ ldap ในการแก้ไข เพิ่มผู้ใช้งานเข้าไปใน OpenLDAP ตัวอย่างไฟล์ ldif และการใช้คำสั่ง ldapadd เพิ่ม user01 เข้าไปใน OpenLDAP [root@fc9-min ldif]# cat add-user01.ldif dn: uid=user01,ou=People,dc=test-ldap,dc=com uid: user01 cn: user01 objectClass: account objectClass: posixAccount objectClass: top objectClass: shadowAccount userPassword: {crypt}!! shadowLastChange: 14030 shadowMax: [...]]]></description>
			<content:encoded><![CDATA[<p>จากบทความ <a href="http://spalinux.com/2008/10/install_openldap_server_on_fedora_9">ติดตั้ง OpenLDAP Server บน Fedora 9</a> และ <a href="http://spalinux.com/2008/10/add_user_into_openldap">เพิ่มบัญชีผู้ใช้งานเข้าไปใน OpenLDAP</a><br />
 ในบทความนี้จะแสดงวิธีการเพิ่ม แก้ไข ลบ รวมทั้งการเปลี่ยนรหัสผ่าน (Password) ของผู้ใช้งานที่ถูกเก็บข้อมูลไว้ใน OpenLDAP  โดยจะสร้างเป็นไฟล์ ldif แล้วใช้คำสั่งของ ldap ในการแก้ไข</p>
<p><span id="more-255"></span></p>
<hr />
<h4>เพิ่มผู้ใช้งานเข้าไปใน OpenLDAP</h4>
<p>ตัวอย่างไฟล์ ldif และการใช้คำสั่ง ldapadd เพิ่ม user01 เข้าไปใน OpenLDAP</p>
<pre>[root@fc9-min ldif]# <strong>cat add-user01.ldif
</strong>dn: uid=user01,ou=People,dc=test-ldap,dc=com
uid: user01
cn: user01
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}!!
shadowLastChange: 14030
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 1001
gidNumber: 100
homeDirectory: /home/user01</pre>
<pre>[root@fc9-min ldif]# <strong>ldapadd -x -D uid=root,ou=People,dc=test-ldap,dc=com \
                       -W -f add-user01.ldif
</strong>Enter LDAP Password:
adding new entry "uid=user01,ou=People,dc=test-ldap,dc=com"</pre>
<p>รหัสผ่าน (Enter LDAP Password) ที่ต้องใส่คือรหัส rootpw ที่ถูกเข้ารหัสแล้วเก็บไว้ในไฟล์ slapd.conf</p>
<p>หลังจากที่เพิ่มผู้ใช้งาน ต้องสร้างไดเร็คทอรีเพื่อเป็น HOME ของ user ด้วย ดังนี้</p>
<pre>[root@fc9-min ~]# <strong>cd /home
</strong>[root@fc9-min home]# <strong>mkdir user01
</strong>[root@fc9-min home]# <strong>cp -av /etc/skel/. user01/
</strong>`/etc/skel/./.bash_profile' -&gt; `user01/./.bash_profile'
`/etc/skel/./.bash_logout' -&gt; `user01/./.bash_logout'
`/etc/skel/./.bashrc' -&gt; `user01/./.bashrc'
[root@fc9-min home]# <strong>chown user01:users user01/
</strong>[root@fc9-min home]# <strong>chmod 700 user01</strong></pre>
<hr />
<h4>ตรวจสอบผู้ใช้งานจาก OpenLDAP</h4>
<p>นอกจากการทดสอบด้วยการล็อกอินแล้ว สามารถใช้คำสั่ง id หรือ getent ในการตรวจสอบผู้ใช้งานจาก OpenLDAP ได้ดังนี้</p>
<pre>[root@fc9-min ~]# <strong>id user01
</strong>uid=1001(user01) gid=100(users) groups=100(users) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023</pre>
<pre>[root@fc9-min ldif]# <strong>getent passwd user01
</strong>user01:x:1001:100:user01:/home/user01:/bin/bash</pre>
<hr />
<h4>เปลี่ยนรหัสผ่าน</h4>
<p>ใช้คำสั่ง ldappasswd ในการเปลี่ยนรหัสผู้ใช้งานที่อยู่ใน OpenLDAP โดยต้องระบุ CN ของผู้ใช้นั้นๆ เช่น ต้องการเปลี่ยนรหัสผ่านของ user01 ซึ่งมี CN: uid=user01,ou=People,dc=test-ldap,dc=com สามารถทำได้ดังนี้</p>
<pre>[root@fc9-min ldif]# <strong>ldappasswd -x -S -W -D uid=root,ou=People,dc=test-ldap,dc=com \
                       uid=user01,ou=People,dc=test-ldap,dc=com</strong></pre>
<pre>New password: <strong>&lt;new-user-password&gt;</strong>
Re-enter new password: <strong>&lt;new-user-password&gt;
</strong>Enter LDAP Password: <strong>&lt;rootpw-password&gt;</strong></pre>
<p>รหัสสองอันแรกที่ต้องใส่ (New password และ Re-enter new password) เป็นรหัสใหม่ที่ต้องการตั้งให้กับผู้ใช้ ส่วน Enter LDAP Password ต้องใส่รหัสผ่านของ rootpw ที่ระบุในไฟล์ slapd.conf</p>
<hr />
<h4>แก้ไขข้อมูล</h4>
<p>ใช้คำสั่ง ldapmodify เพื่อแก้ไขข้อมูลที่อยู่ใน OpenLDAP โดยข้อมูลที่ถูกแก้ไข จะถูกระบุอยู่ในไฟล์ ldif เช่น ตัวอย่างนี้จะเป็นการแก้ไขข้อมูล homeDirectory ของ user01 ให้เป็นค่าใหม่คือ /new-home/user01 และเพิ่ม gecos โดยมีค่าเป็น “User01 GECOS Name”</p>
<pre>[root@fc9-min ldif]# <strong>cat modify-user01.ldif
</strong>dn: uid=user01,ou=People,dc=test-ldap,dc=com
changetype: modify
replace: homeDirectory
homeDirectory: /new-home/user01
-
add: gecos
gecos: User01 GECOS Name
-</pre>
<p>ใช้คำสั่ง getent เพื่อเปรียบเทียบข้อมูลก่อนและหลังรันคำสั่ง ldapmodify</p>
<pre>[root@fc9-min ldif]# <strong>getent passwd user01
</strong>user01:x:1001:100:user01:/home/user01:/bin/bash</pre>
<pre>[root@fc9-min ldif]# <strong>ldapmodify -x -D "uid=root,ou=People,dc=test-ldap,dc=com" \
                       -W -f modify-user01.ldif
</strong>Enter LDAP Password:
modifying entry "uid=user01,ou=People,dc=test-ldap,dc=com"</pre>
<pre>[root@fc9-min ldif]# <strong>getent passwd user01
</strong>user01:x:1001:100:User01 GECOS Name:/new-home/user01:/bin/bash</pre>
<hr />
<h4>ลบ user</h4>
<p>ใช้คำสั่ง ldapdelete เพื่อลบผู้ใช้งานออกจาก OpenLDAP โดยต้องระบุชื่อผู้ใช้เป็นค่า CN ของผู้ใช้นั้นๆ เช่นต้องการลบ user01 ที่มี CN: uid=user01,ou=People,dc=test-ldap,dc=com</p>
<pre>[root@fc9-min bin]# <strong>ldapdelete -x -D uid=root,ou=People,dc=test-ldap,dc=com –W \
                      uid=user01,ou=People,dc=test-ldap,dc=com
</strong>Enter LDAP Password:</pre>
<pre>[root@fc9-min bin]# <strong>getent passwd user01
</strong>[root@fc9-min bin]#</pre>
<hr />
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/10/install_openldap_server_on_fedora_9">ติดตั้ง OpenLDAP Server บน Fedora 9</a></li>
<li><a href="http://spalinux.com/2008/10/add_user_into_openldap">เพิ่มบัญชีผู้ใช้งานเข้าไปใน OpenLDAP</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/10/add_modify_delete_user_in_openldap/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
