<# .SYNOPSIS Bölüm 01 · Adım 1.2 — Alternatif UPN Suffix, Tiered OU Mimarisi ve ESC8 Korumalı AD CS / LDAPS .DESCRIPTION Hibrit Entra ID için yönlendirilebilir UPN suffix ekler, kazara silinmeye karşı korumalı 5 temel OU oluşturur ve ADCS-Web-Enrollment (ESC8) olmadan 4096-bit SHA256 Enterprise Root CA kurarak LDAPS (TCP 636) bağlantısını devreye alır. .EXAMPLE powershell -ExecutionPolicy Bypass -File "D:\Lab\Scripts\02-Setup-ADCS-LDAPS-OU.ps1" -PublicUpn "contoso.com" #> #Requires -RunAsAdministrator param( [string]$PublicUpn = "canercetinkaya.com", [string]$CaName = "CORP-DC01-CA" ) $ErrorActionPreference = "Stop" Import-Module ActiveDirectory $Forest = Get-ADForest $BaseDN = (Get-ADDomain).DistinguishedName Write-Host "[1/4] Alternatif UPN Suffix ekleniyor: $PublicUpn" -ForegroundColor Cyan if ($Forest.UPNSuffixes -notcontains $PublicUpn) { Set-ADForest -Identity $Forest.Name -UPNSuffixes @{ Add = $PublicUpn } } Write-Host "[2/4] Korumalı Tiered OU yapısı oluşturuluyor..." -ForegroundColor Cyan foreach ($ou in @("Tier0", "Servers", "Workstations", "CorpUsers", "ServiceAccounts")) { if (-not (Get-ADOrganizationalUnit -Filter "Name -eq '$ou'" -SearchBase $BaseDN -SearchScope OneLevel -ErrorAction SilentlyContinue)) { New-ADOrganizationalUnit -Name $ou -Path $BaseDN -ProtectedFromAccidentalDeletion $true } } Write-Host "[3/4] ESC8 korumalı ADCS-Cert-Authority (4096-bit RSA + SHA256) kuruluyor..." -ForegroundColor Cyan Install-WindowsFeature ADCS-Cert-Authority -IncludeManagementTools | Out-Null if ((Get-Service CertSvc -ErrorAction SilentlyContinue).Status -ne 'Running') { Install-AdcsCertificationAuthority ` -CAType EnterpriseRootCA ` -CACommonName $CaName ` -CryptoProviderName "RSA#Microsoft Software Key Storage Provider" ` -KeyLength 4096 -HashAlgorithmName SHA256 ` -ValidityPeriod Years -ValidityPeriodUnits 10 -Force | Out-Null } Write-Host "[4/4] Otomatik DC sertifikası ve LDAPS (TCP 636) doğrulanıyor..." -ForegroundColor Green gpupdate /force | Out-Null certutil -pulse | Out-Null Start-Sleep -Seconds 5 $fqdn = "$env:COMPUTERNAME.$($Forest.RootDomain)" Get-Service CertSvc | Select-Object Name, Status Test-NetConnection -ComputerName $fqdn -Port 636 | Select-Object ComputerName, RemotePort, TcpTestSucceeded Get-ChildItem Cert:\LocalMachine\My | Select-Object Subject, Issuer, NotAfter | Format-Table -AutoSize