วันอังคารที่ 10 พฤศจิกายน พ.ศ. 2569

wServer - ADCS

 

คู่มือการติดตั้ง Active Directory Domain Services และ Active Directory Certificate Services

Windows Server 2022

รูปแบบการติดตั้ง: แยก AD DS และ AD CS คนละเครื่อง
วัตถุประสงค์: ใช้งานระบบ Certificate ภายในองค์กร
ประเภทเอกสาร: Installation & Configuration Guide

จัดทำสำหรับผู้ดูแลระบบ Windows Server และระบบเครือข่ายองค์กร


สารบัญ

  1. วัตถุประสงค์
  2. ออกแบบระบบและกำหนด IP Address
  3. เตรียมความพร้อมก่อนติดตั้ง
  4. ติดตั้ง Active Directory Domain Services (DC01)
  5. ตรวจสอบระบบ Active Directory และ DNS
  6. เตรียมเครื่อง Certificate Authority (CA01)
  7. Join CA01 เข้า Domain
  8. ติดตั้ง Active Directory Certificate Services
  9. Configure Enterprise Root CA
  10. ตั้งค่า Certificate Template
  11. ตั้งค่า Group Policy Auto Enrollment
  12. ทดสอบการออก Certificate จาก Client
  13. ตรวจสอบ Firewall และ Network
  14. Backup และ Security
  15. Troubleshooting
  16. Checklist ตรวจรับระบบ
  17. แหล่งอ้างอิง Microsoft

1. วัตถุประสงค์

เอกสารฉบับนี้จัดทำขึ้นเพื่ออธิบายขั้นตอนการติดตั้งและตั้งค่าระบบ Active Directory Domain Services (AD DS) และ Active Directory Certificate Services (AD CS) บน Windows Server 2022 โดยแยกการติดตั้งออกเป็น 2 เครื่อง Server

ระบบจะประกอบด้วย

  • DC01 ทำหน้าที่ Domain Controller และ DNS Server
  • CA01 ทำหน้าที่ Enterprise Certificate Authority
  • Client Windows 10/11 สำหรับทดสอบการรับ Certificate

วัตถุประสงค์ในการใช้งาน ได้แก่

  • บริหารจัดการ User และ Computer ภายในองค์กร
  • จัดการสิทธิ์การใช้งานผ่าน Active Directory
  • ออกและจัดการ Digital Certificate ภายในองค์กร
  • รองรับ HTTPS และ SSL สำหรับระบบภายใน
  • รองรับ Certificate Authentication
  • รองรับ Certificate Auto Enrollment ผ่าน Group Policy

2. ออกแบบระบบและกำหนด IP Address

2.1 Network Diagram

โครงสร้างระบบตัวอย่าง

INTERNAL NETWORK: 192.168.10.0/24

SERVER 01

  • Hostname: DC01
  • IP: 192.168.10.10
  • Role: AD DS / DNS
  • Domain: company.local

SERVER 02

  • Hostname: CA01
  • IP: 192.168.10.20
  • Role: AD CS
  • CA Name: COMPANY-CA

CLIENT

  • Hostname: CLIENT01
  • IP: 192.168.10.100
  • Role: Domain Client

2.2 ตาราง IP Address

รายการDC01CA01CLIENT01
IP Address192.168.10.10192.168.10.20192.168.10.100
Subnet/24/24/24
Gateway.1.1.1
DNS.10.10.10
HostnameDC01CA01CLIENT01

Domain Name: company.local

หมายเหตุ: IP Address และ Domain Name เป็นตัวอย่าง ต้องปรับให้ตรงกับระบบเครือข่ายจริงขององค์กร แนะนำให้ใช้ DNS Subdomain ที่องค์กรเป็นเจ้าของ เช่น ad.company.com สำหรับระบบใหม่

3. เตรียมความพร้อมก่อนติดตั้ง

ตรวจสอบรายการต่อไปนี้ก่อนเริ่มติดตั้ง

  • ติดตั้ง Windows Server 2022 เรียบร้อยแล้ว
  • เปิดใช้งาน Windows Server และติดตั้ง Updates
  • กำหนด Static IP Address
  • ตั้งชื่อ Server ให้เรียบร้อย
  • ตรวจสอบ Network Connectivity
  • ตรวจสอบเวลาและ Time Zone
  • เตรียมบัญชี Administrator
  • เตรียมรหัสผ่าน DSRM
  • เตรียมพื้นที่สำหรับ Backup

ควรใช้บัญชีผู้ดูแลระบบที่เหมาะสมกับแต่ละขั้นตอน และไม่ใช้ Domain Administrator เป็นบัญชีทำงานประจำวัน

4. ติดตั้ง Active Directory Domain Services (DC01)

4.1 เปลี่ยนชื่อเครื่อง Server

เปิด PowerShell แบบ Run as Administrator:

powershell

Rename-Computer -NewName "DC01" -Restart

หลังจาก Server Restart ให้ Login อีกครั้ง

4.2 กำหนด Static IP Address

ตรวจสอบชื่อ Network Adapter

powershell

Get-NetAdapter

กำหนด IP Address

powershell

New-NetIPAddress `
-InterfaceAlias "Ethernet" `
-IPAddress "192.168.10.10" `
-PrefixLength 24 `
-DefaultGateway "192.168.10.1"

กำหนด DNS

powershell

Set-DnsClientServerAddress `
-InterfaceAlias "Ethernet" `
-ServerAddresses "127.0.0.1"

ตรวจสอบ IP

powershell

Get-NetIPConfiguration

หมายเหตุ: หากมี IP เดิมจาก DHCP ให้เปลี่ยน Adapter เป็น Static หรือจัดการค่าที่มีอยู่ก่อน เพื่อป้องกันการกำหนด IP ซ้ำ

4.3 ติดตั้ง AD DS และ DNS

powershell

Install-WindowsFeature `
-Name AD-Domain-Services,DNS `
-IncludeManagementTools

ตรวจสอบ

powershell

Get-WindowsFeature AD-Domain-Services,DNS

ผลลัพธ์ที่ต้องการคือ Install State แสดง Installed

4.4 สร้าง Domain และ Forest ใหม่

กำหนด Domain Name เป็น company.local

powershell

Install-ADDSForest `
-DomainName "company.local" `
-DomainNetbiosName "COMPANY" `
-InstallDNS

ระบบจะให้กำหนด DSRM Password

หลังดำเนินการ Server จะ Restart อัตโนมัติ

4.5 Login เข้าระบบ Domain

ใช้บัญชี

text

COMPANY\Administrator

4.6 ตรวจสอบ Domain

powershell
Get-ADDomain

powershell
Get-ADForest

ตรวจสอบ Domain Controller

powershell

Get-ADDomainController -Filter *

ตรวจสอบสุขภาพระบบ

powershell

dcdiag /v

ตรวจสอบ DNS

powershell

nslookup company.local

ตรวจสอบ SRV Record

powershell

nslookup -type=SRV _ldap._tcp.dc._msdcs.company.local

ผลลัพธ์ที่ต้องการ

  • Domain สามารถค้นหาได้
  • DNS สามารถ Resolve ชื่อ DC01 ได้
  • SRV Record ของ Active Directory แสดง Domain Controller
  • ไม่มี Error สำคัญจาก DCDIAG

5. เตรียมเครื่อง Certificate Authority (CA01)

5.1 ตั้งชื่อเครื่อง

เปิด PowerShell แบบ Administrator

powershell

Rename-Computer -NewName "CA01" -Restart

5.2 กำหนด Static IP

powershell
New-NetIPAddress `
-InterfaceAlias "Ethernet" `
-IPAddress "192.168.10.20" `
-PrefixLength 24 `
-DefaultGateway "192.168.10.1"

กำหนด DNS ให้ชี้ไป DC01

powershell
Set-DnsClientServerAddress `
-InterfaceAlias "Ethernet" `
-ServerAddresses "192.168.10.10"

ตรวจสอบ DNS

powershell
nslookup DC01.company.local

ผลลัพธ์ควรได้ 192.168.10.10

5.3 ทดสอบการเชื่อมต่อ Domain Controller

powershell
Test-NetConnection DC01.company.local -Port 389

ตรวจสอบ DNS

powershell
Resolve-DnsName company.local

6. Join CA01 เข้า Domain

เปิด PowerShell แบบ Administrator

powershell
Add-Computer `
-DomainName "company.local" `
-Credential (Get-Credential) `
-Restart

กรอกบัญชี Domain Admin ที่ได้รับอนุญาต

ตัวอย่าง

text
COMPANY\Administrator

หลัง Restart ตรวจสอบ

powershell
Get-CimInstance Win32_ComputerSystem |
Select-Object Name,Domain,PartOfDomain

ผลลัพธ์ที่ต้องการ

text
Name         : CA01
Domain       : company.local
PartOfDomain : True

7. ติดตั้ง Active Directory Certificate Services

7.1 ข้อกำหนดก่อนติดตั้ง

ตรวจสอบว่า

  • CA01 Join Domain สำเร็จ
  • DNS ทำงานปกติ
  • ติดต่อ DC01 ได้
  • เวลา Server ถูกต้อง
  • ผู้ติดตั้งมีสิทธิ์ Enterprise Admins และ Domain Admins ของ Root Domain ตามข้อกำหนดของ Microsoft

7.2 ติดตั้ง AD CS Role

เปิด PowerShell แบบ Administrator

powershell
Install-WindowsFeature `
-Name ADCS-Cert-Authority `
-IncludeManagementTools

ตรวจสอบ

powershell
Get-WindowsFeature ADCS-Cert-Authority

7.3 Configure Enterprise Root CA

กำหนดรายละเอียด

รายการค่า
CA TypeEnterprise Root CA
CA NameCOMPANY-CA
Key Length2048
Hash AlgorithmSHA256
Validity Period5 Years

หมายเหตุ: ใช้ค่า RSA 2048 ตามค่าเริ่มต้นที่ Microsoft แนะนำเพื่อความเข้ากันได้ และควรประเมินอายุ CA ตามนโยบาย PKI ขององค์กร

7.4 Configure ผ่าน PowerShell

powershell
Install-AdcsCertificationAuthority `
-CAType EnterpriseRootCA `
-CACommonName "COMPANY-CA" `
-KeyLength 2048 `
-HashAlgorithmName SHA256 `
-ValidityPeriod Years `
-ValidityPeriodUnits 5 `
-Force

คำสั่งนี้จะสร้าง Private Key และ CA Certificate รวมถึงลงทะเบียน Enterprise CA เข้ากับ Active Directory

ข้อควรระวัง: ชื่อ CA เป็นค่าที่สำคัญมาก ไม่ควรเปลี่ยนหลังติดตั้ง และต้องมีแผนสำรอง CA Private Key ก่อนนำระบบไปใช้งานจริง

7.5 ตรวจสอบบริการ CA

powershell
Get-Service CertSvc

ผลลัพธ์ที่ต้องการ

text
Status : Running
Name   : CertSvc

ตรวจสอบ CA

powershell
certutil -getconfig
powershell
certutil -config - -ping

ผลลัพธ์ควรพบ

text
CA01.company.local\COMPANY-CA

8. ตั้งค่า Certificate Template

8.1 เปิด Certificate Templates Console

ที่เครื่อง CA01

กด Windows + R

text
certtmpl.msc

จะปรากฏหน้าต่าง Certificate Templates

8.2 Duplicate Computer Template

  1. ค้นหา Template ชื่อ Computer
  2. คลิกขวา Computer
  3. เลือก Duplicate Template
  4. เลือก Compatibility ให้เหมาะสมกับ Windows Server 2022 และ Client ที่จะใช้งาน
  5. ตั้งชื่อ Template เป็น COMPANY-Computer

8.3 ตั้งค่า General

  • Template Display Name: COMPANY-Computer
  • Validity Period: 1 Year
  • Renewal Period: ตามนโยบายองค์กร

8.4 ตั้งค่า Security

เพิ่มกลุ่ม Domain Computers

กำหนดสิทธิ์

PermissionSetting
ReadAllow
EnrollAllow
AutoenrollAllow

ไม่ควรให้ Domain Users หรือ Authenticated Users มีสิทธิ์ออก Certificate ที่มีความสำคัญโดยไม่จำเป็น

ตรวจสอบแท็บ Subject Name และ Extensions ให้เหมาะกับวัตถุประสงค์การใช้งาน Certificate โดยเฉพาะหากจะใช้กับ HTTPS หรือ Client Authentication

8.5 Publish Template

เปิด Certification Authority

text
certsrv.msc

ดำเนินการ

  1. ขยาย CA01
  2. คลิกขวา Certificate Templates
  3. เลือก New
  4. เลือก Certificate Template to Issue
  5. เลือก COMPANY-Computer
  6. กด OK

ตรวจสอบว่ามี COMPANY-Computer ปรากฏในรายการ Certificate Templates

9. ตั้งค่า Group Policy Auto Enrollment

9.1 เปิด Group Policy Management

บน DC01 กด Windows + R

text
gpmc.msc

สร้าง GPO ใหม่ชื่อ

text
COMPANY-Certificate-AutoEnrollment

Link GPO ไปยัง OU ที่มี Computer เป้าหมายอยู่

9.2 ตั้งค่า Auto Enrollment

เปิด Edit GPO แล้วไปที่

text
Computer Configuration
  Policies
    Windows Settings
      Security Settings
        Public Key Policies
          Certificate Services Client - Auto-Enrollment

กำหนด

  • Configuration Model: Enabled
  • Renew expired certificates, update pending certificates, and remove revoked certificates: Checked
  • Update certificates that use certificate templates: Checked

กด Apply และ OK

หมายเหตุ: ต้องสร้างและ Publish User Template เพิ่มต่างหาก หากต้องการ Auto Enrollment ให้ User

10. ทดสอบ Certificate จาก Client

10.1 เตรียม Client

ตั้งค่า IP

text
IP Address: 192.168.10.100
Subnet Mask: 255.255.255.0
Gateway: 192.168.10.1
DNS: 192.168.10.10

ทดสอบ DNS

powershell
nslookup DC01.company.local

Join Domain 

powershell
Add-Computer `
-DomainName "company.local" `
-Credential (Get-Credential) `
-Restart

10.2 สั่ง Update Group Policy

เปิด PowerShell แบบ Administrator

powershell
gpupdate /force

ตรวจสอบ GPO

powershell
gpresult /r

10.3 สั่ง Certificate Auto Enrollment

powershell
certutil -pulse

10.4 ตรวจสอบ Certificate

กด Windows + R

text
certlm.msc

เปิด

text
Certificates (Local Computer)
  Personal
    Certificates

ตรวจสอบว่ามี Certificate ของ CLIENT01 และ Issuer เป็น COMPANY-CA

10.5 ตรวจสอบผ่าน PowerShell

powershell
Get-ChildItem Cert:\LocalMachine\My |
Select-Object Subject,Issuer,NotBefore,NotAfter,Thumbprint

ผลลัพธ์ที่ต้องการ

  • มี Certificate ของเครื่อง
  • Issuer เป็น COMPANY-CA
  • Certificate ยังไม่หมดอายุ
  • มี Enhanced Key Usage ที่ตรงกับ Template
  • Certificate Chain สามารถตรวจสอบได้

11. ตรวจสอบ Firewall และ Network

Port ที่เกี่ยวข้อง


PortProtocolService
53TCP/UDPDNS
88TCP/UDPKerberos
123UDPNTP
135TCPRPC
389TCP/UDPLDAP
445TCPSMB
464TCP/UDPKerberos Password
636TCPLDAPS
3268TCPGlobal Catalog
3269TCPGlobal Catalog SSL
49152–65535TCPDynamic RPC

สำหรับ AD CS ต้องตรวจสอบการเชื่อมต่อ RPC/DCOM และ Dynamic RPC ระหว่าง CA และ Client รวมถึงช่องทาง HTTP/HTTPS สำหรับ CRL หรือ AIA หากมีการกำหนดให้เผยแพร่ผ่าน Web Server

ไม่ควรเปิด Port ทั้งหมดให้ทุกเครือข่าย ควรจำกัด Source และ Destination ตามการใช้งานจริง

ทดสอบ Port


powershell
Test-NetConnection DC01.company.local -Port 389
powershell
Test-NetConnection CA01.company.local -Port 135

12. Backup และ Security

12.1 Backup AD CS

สร้าง Folder สำหรับ Backup

powershell
New-Item -Path "C:\CABackup" `
-ItemType Directory -Force

Backup CA

powershell
Backup-CARoleService `
-Path "C:\CABackup"

ต้องตรวจสอบผลการ Backup และจัดเก็บสำเนาในพื้นที่ปลอดภัยที่แยกจาก CA01

รายการที่ต้องสำรอง

  • CA Database
  • CA Private Key
  • CA Certificate
  • CA Configuration
  • CAPolicy.inf (ถ้ามี)
  • CRL และข้อมูลที่เกี่ยวข้อง

ควรทดสอบ Restore ตามแผน Disaster Recovery ขององค์กร

12.2 Security Recommendation

  • จำกัดสิทธิ์ CA Administrator
  • แยกบัญชี Admin จากบัญชีใช้งานประจำวัน
  • ป้องกันการเข้าถึง Private Key
  • จำกัดสิทธิ์ Certificate Template
  • เปิด Windows Firewall
  • ติดตั้ง Windows Updates
  • สำรอง CA Database และ Private Key
  • ตรวจสอบ Certificate ที่ถูกออกเป็นประจำ
  • กำหนด CRL Publication และตรวจสอบการเข้าถึง CRL
  • วางแผนการต่ออายุ CA Certificate ก่อนหมดอายุ

ข้อแนะนำด้านสถาปัตยกรรม: การติดตั้ง Enterprise Root CA บน Domain Member Server เป็นระบบ One-Tier PKI ซึ่งเหมาะกับ Lab หรือองค์กรขนาดเล็กที่ยอมรับความเสี่ยงได้ สำหรับระบบ Production ที่ต้องการความปลอดภัยสูง ควรใช้ Two-Tier PKI โดยแยก Offline Standalone Root CA ออกจาก Online Enterprise Subordinate CA

13. Troubleshooting

ปัญหา 1 Join Domain ไม่ได้

ตรวจสอบ DNS

powershell
ipconfig /all
powershell
nslookup company.local

ตรวจสอบ Port

powershell
Test-NetConnection DC01.company.local -Port 389

สาเหตุที่พบบ่อย: ตั้ง DNS ผิด หรือ Client ไม่สามารถติดต่อ Domain Controller ได้

ปัญหา 2 CA Service ไม่ทำงาน

powershell
Get-Service CertSvc

ตรวจสอบ Event Log

powershell
Get-WinEvent -LogName System -MaxEvents 50

ปัญหา 3 Client ไม่ได้รับ Certificate

ตรวจสอบ

powershell
gpresult /r
powershell
certutil -pulse

ตรวจสอบ Template ว่า

  • Publish บน CA แล้ว
  • มีสิทธิ์ Enroll และ Autoenroll
  • GPO ถูก Link ไปยัง OU ที่ถูกต้อง
  • Client มีสิทธิ์เข้าถึง CA
  • Template มีการกำหนด Subject Name และ EKU ถูกต้อง

ปัญหา 4 Certificate Chain ไม่สมบูรณ์

ตรวจสอบ Root CA Certificate

powershell
certutil -store Root

ตรวจสอบ Certificate Revocation List

powershell
certutil -urlfetch -verify C:\Temp\client.cer

ตรวจสอบว่า CRL Distribution Point สามารถเข้าถึงได้และ CRL ยังไม่หมดอายุ

14. Checklist ตรวจรับระบบ


ลำดับรายการตรวจสอบสถานะ
1ติดตั้ง Windows Server 2022□
2กำหนด Static IP DC01□
3ติดตั้ง AD DS□
4ติดตั้ง DNS□
5สร้าง Domain□
6ตรวจสอบ DCDIAG□
7กำหนด Static IP CA01□
8Join CA01 เข้า Domain□
9ติดตั้ง AD CS□
10Configure Enterprise CA□
11Publish Certificate Template□
12ตั้งค่า Group Policy□
13Join Client เข้า Domain□
14ทดสอบ Auto Enrollment□
15ตรวจสอบ Certificate Chain□
16Backup CA สำเร็จ□
17ทดสอบ CRL และ Revocation□

15. สรุปผลการติดตั้ง

เมื่อดำเนินการครบทุกขั้นตอน จะได้ระบบดังนี้

SERVER 01: DC01

  • Active Directory Domain Services
  • DNS Server
  • Domain Controller
  • Group Policy Management

SERVER 02: CA01

  • Active Directory Certificate Services
  • Enterprise Root CA
  • Certificate Templates
  • Certificate Issuance
  • Certificate Management

CLIENT

  • Join Domain
  • รับ Group Policy
  • รับ Certificate ผ่าน Auto Enrollment
  • ตรวจสอบ Certificate Chain

ระบบนี้สามารถนำไปใช้เป็นพื้นฐานสำหรับ Internal PKI ขององค์กร และต่อยอดไปยังระบบ HTTPS, VPN, Wi-Fi Enterprise และ Computer Authentication ได้

16. แหล่งอ้างอิง Microsoft

  1. Install Active Directory Domain Services: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/install-active-directory-domain-services--level-100-
  2. Install the Certification Authority on Windows Server: https://learn.microsoft.com/en-us/windows-server/networking/core-network-guide/cncg/server-certs/install-the-certification-authority
  3. Install-AdcsCertificationAuthority PowerShell: https://learn.microsoft.com/en-us/powershell/module/adcsdeployment/install-adcscertificationauthority?view=windowsserver2022-ps
  4. Install-ADDSForest PowerShell: https://learn.microsoft.com/en-us/powershell/module/addsdeployment/install-addsforest?view=windowsserver2022-ps

สิ้นสุดเอกสาร

ชื่อเอกสาร: Windows Server 2022 AD DS & AD CS Installation Guide

เวอร์ชันเอกสาร: 1.0

ประเภท: Internal IT Infrastructure Documentation

หมายเหตุ: เอกสารนี้เป็นคู่มือการติดตั้งและทดสอบ ไม่ใช่หลักฐานว่าระบบได้ผ่านการติดตั้งจริงแล้ว ผู้ดูแลระบบต้องบันทึกผลการทดสอบและค่าการตั้งค่าจริงก่อนส่งมอบงาน

ไม่มีความคิดเห็น:

แสดงความคิดเห็น