Windows linux Software Super Tips

All Tips For Os & Software

 
Home
Add to Technorati Favorites

User authentication
Monday, January 8, 2007
อ่านเพิ่มเติมได้จาก http://www.apacheweek.com/features/userauth หรือ http://www.thaiall.com/cgi/htpasswd.pl
ขั้นตอนการ lock ห้องของตนเอง ในฐานะผู้ใช้ทั่วไป
ท่านต้องส่งแฟ้ม 2 แฟ้มคือ .htpasswd และ .htaccess ไปไว้ในห้องที่ต้องการ lock โดยทำการถาม User และ password ก่อนเข้า
.htaccess นั้นสามารถคัดลอกด้านล่างไปได้เลย โดยแก้ไขอะไรเล็กน้อยตามต้องการ เช่นเปลี่ยนคำว่า lock ที่บรรทัดแรก เป็น username ของท่าน
.htpasswd แต่ละบรรทัดคือ 1 user สำหรับแฟ้มนี้ ถ้าผู้ดูแลไม่คิดบริการ ท่านก็ใช้บริการไม่ได้ สำหรับ server ที่ผมดูแล ได้ทำ โปรแกรมเข้ารหัส สร้างรหัสให้
ถ้าเป็นผู้ดูแล(Super user) สามารถใช้
คำสั่ง #htpasswd -nb yourname yourpassword แสดงรหัสผ่าน ที่ shell prompt
คำสั่ง #htpasswd -c .htpasswd yourname สร้างแฟ้ม .htpasswd พร้อม รอรับรหัสผ่าน จากแป้นพิมพ์
ดูเพิ่มเติมจาก #man htpasswd ที่ shell prompt
เพิ่มในแฟ้ม .htpasswd
.htaccess
.htpasswd
AuthName "User:yourname Password:yourpassword for accessing this directory"
AuthType Basic
require valid-user
DirectoryIndex index.html index.htm index.shtml index.php
.htpasswd
test:1A/c8vPQJQiL2
yourname:UtecEDcEa3/L2

ปัญหา และวิธีแก้ไข ที่ผู้ดูแลอาจพบ
ครั้งแรกที่สร้าง .htaccess และ .htpasswd ก็ไม่เกิดผล คือสองแฟ้มนี้ไม่ทำงาน ตรวจสอบแล้วพบว่าผู้ดูแลต้องแก้แฟ้ม /etc/httpd/conf/httpd.conf
ให้ส่วนของ ในบรรทัดที่เขียนว่า AllowOverride None เปลี่ยนเป็น AllowOverride All
หรือส่วนของ ในบรรทัดที่เขียนว่า AllowOverride None เปลี่ยนเป็น AllowOverride All ถ้าท่านใช้ public_html
lock/index.php
:: ใช้แสดงรหัสที่ผู้ใช้กำหนดขึ้น และนำไปเพิ่มในแฟ้ม .htpasswd ของ directory ที่ต้องการ lock

User:

Password:



This line for .htpasswd

$x = "htpasswd -nb ". $_GET['u'] . " " . $_GET['p'];
echo `$x`;
?>


Detail of .htaccess and .htpasswd at

http://www.thaiall.com/cgi/htpasswd.pl
 
0 Comments:
Post a Comment
<< Home
 
Search



Previous Post
Archives
Links
    Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online Add to My AOL Add to Technorati Favorites!
Powered by

BLOGGER

© 2005 Windows linux Software Super Tips
eXTReMe Tracker