ติดตั้ง Certificate สำหรับ LDAPS บน Windows Server 2022 แบบละเอียด
LDAPS จะไม่สามารถทำงานได้หาก Domain Controller ไม่มี Certificate ที่ถูกต้อง ดังนั้นการติดตั้ง Certificate สำหรับ LDAPS จึงเป็นขั้นตอนสำคัญที่ช่วยให้ Active Directory สามารถเข้ารหัสข้อมูลการ Authentication ได้อย่างปลอดภัย
Windows Server 2022 รองรับการใช้งาน LDAPS ผ่าน Certificate จาก Active Directory Certificate Services (AD CS) หรือจาก Public Certificate Authority ภายนอก
บทความนี้จะอธิบายวิธีติดตั้ง Certificate สำหรับ LDAPS บน Windows Server 2022 แบบละเอียด พร้อมวิธีตรวจสอบหลังติดตั้ง
📌 ทำไม LDAPS ต้องใช้ Certificate
LDAP ปกติ
Port 389
จะส่งข้อมูลผ่านเครือข่ายโดยไม่เข้ารหัส
ส่วน
LDAPS
Port 636
ต้องใช้ Certificate เพื่อ
เข้ารหัสข้อมูล
ยืนยันตัวตน Server
ป้องกัน Man-in-the-Middle Attack
🎯 ประโยชน์ของ LDAPS Certificate
✅ เข้ารหัส Username
✅ เข้ารหัส Password
✅ ป้องกันการดักข้อมูล
✅ เพิ่มความน่าเชื่อถือ
✅ รองรับ Compliance
หลายองค์กรที่ comsiam ดูแล กำหนดให้ระบบ VPN, Firewall และ NAS ใช้งานผ่าน LDAPS เท่านั้น
📋 คุณสมบัติของ Certificate สำหรับ LDAPS
Certificate ต้องมี
① Server Authentication
Server Authentication
1.3.6.1.5.5.7.3.1
② Private Key
ต้องมี Private Key อยู่บนเครื่อง
③ Subject Name
ต้องตรงกับชื่อ Domain Controller
ตัวอย่าง
dc01.company.local
④ Trusted Certificate Authority
Certificate ต้องออกโดย CA ที่เชื่อถือได้
🚀 วิธีติดตั้ง Active Directory Certificate Services
เปิด
Server Manager
เลือก
Add Roles and Features
ติดตั้ง
Active Directory Certificate Services
⚙️ เลือก Role Services
เลือก
Certification Authority
จากนั้นติดตั้ง
🔐 กำหนด Enterprise CA
เลือก
Enterprise CA
เนื่องจากทำงานร่วมกับ Active Directory ได้ดีที่สุด
📜 เปิด MMC Certificates
เปิด Run
รัน
mmc
➕ เพิ่ม Certificates Snap-in
เลือก
Certificates
จากนั้นเลือก
Computer Account
🚀 ขอ Certificate ใหม่
ไปที่
Personal
└ Certificates
คลิกขวา
เลือก
Request New Certificate
📄 เลือก Template
เลือก
Domain Controller Authentication
หรือ
Kerberos Authentication
🔍 ตรวจสอบ Certificate
ดับเบิลคลิก Certificate
ตรวจสอบ
Enhanced Key Usage
ควรมี
Server Authentication
🔒 ตรวจสอบ Subject Name
ตัวอย่าง
dc01.company.local
ต้องตรงกับชื่อ Domain Controller
🔄 Restart Server
หลังติดตั้ง Certificate
ควร Restart Domain Controller
เพื่อให้ Active Directory โหลด Certificate ใหม่
🖥️ ตรวจสอบ Port 636
หลัง Restart
รัน
netstat -an | find "636"
ผลลัพธ์ควรเป็น
TCP 0.0.0.0:636
🚀 ทดสอบ LDAPS ผ่าน LDP
เปิด
ldp.exe
เลือก
Connection
→ Connect
กรอก
dc01.company.local
Port
636
ติ๊ก
SSL
✅ ผลลัพธ์ที่ถูกต้อง
หากสำเร็จ
จะพบข้อความ
Connection successful
🌐 ทดสอบด้วย PowerShell
รัน
Test-NetConnection
dc01.company.local
-Port 636
ผลลัพธ์
TcpTestSucceeded : True
📖 ตรวจสอบ Certificate ผ่าน PowerShell
รัน
Get-ChildItem
Cert:\LocalMachine\My
จะแสดง Certificate ทั้งหมด
⚠️ ปัญหาที่พบบ่อย
① Port 636 ไม่เปิด
Certificate ไม่ถูกต้อง
② LDAPS เชื่อมต่อไม่ได้
Certificate ไม่มี Server Authentication
③ SSL Handshake Failed
Subject Name ไม่ตรง
④ Certificate Expired
Certificate หมดอายุ
🔍 ตรวจสอบ Event Viewer
เปิด
Event Viewer
ตรวจสอบ
Directory Service
และ
System
🔐 ใช้ Public Certificate ได้หรือไม่
สามารถใช้ได้
เช่น
DigiCert
Sectigo
GlobalSign
แต่สำหรับระบบภายใน
Enterprise CA มักเพียงพอ
📋 Checklist หลังติดตั้ง Certificate
① Certificate มี Private Key
② Subject Name ถูกต้อง
③ Server Authentication อยู่ครบ
④ Port 636 เปิด
⑤ LDP Test ผ่าน
⑥ LDAPS Login ได้
⑦ Event Viewer ไม่มี Error
📈 Best Practices สำหรับ LDAPS Certificate
① ใช้ Domain Controller Authentication Template
② ตรวจสอบวันหมดอายุ
③ ต่ออายุก่อนหมดอายุอย่างน้อย 30 วัน
④ ใช้ Enterprise CA
⑤ ทดสอบ LDAPS หลังต่ออายุ Certificate
⑥ สำรอง CA Database เป็นประจำ
หลายองค์กรที่ comsiam ดูแล มีการตั้งระบบแจ้งเตือนวันหมดอายุ Certificate ล่วงหน้า 60 วัน เพื่อป้องกัน LDAPS หยุดทำงานโดยไม่คาดคิด
🎯 สรุป
Certificate คือหัวใจของ LDAPS บน Windows Server 2022 หาก Certificate ไม่ถูกต้อง LDAPS จะไม่สามารถทำงานได้
การติดตั้ง Certificate ที่มี Server Authentication, Subject Name ถูกต้อง และออกโดย CA ที่เชื่อถือได้ จะช่วยให้ Active Directory สามารถให้บริการ LDAPS ได้อย่างปลอดภัย รองรับการเชื่อมต่อจากระบบต่างๆ ภายในองค์กร และลดความเสี่ยงด้านความปลอดภัยในระยะยาว