Skip to content

Instantly share code, notes, and snippets.

View bryanmulvey's full-sized avatar

Bryan Mulvey bryanmulvey

  • Littleton, Colorado
View GitHub Profile
@alexmags
alexmags / new-LDAPcert.ps1
Created March 23, 2024 11:15
PowerShell self-signed cert for LDAPs
# In a lab, or a AD domain with non-routable top level domain (.corp, .local etc...)
# Creating one self-signed cert usable across multiple domain controllers for encrypted LDAP
Import-Module ActiveDirectory
$addomain=get-addomain
$expirydate = (Get-Date).AddYears(1)
# Get all (currently existing) domain controllers to be subject alternative names (avoid cloud kerberos trust object)
$ArraySubjectAlternativeNames=(Get-ADComputer -SearchBase $addomain.DomainControllersContainer -filter * | where {$_.name -ne 'AzureADKerberos'}).dnshostname
$ArraySubjectAlternativeNames+="ldap.$($addomain.DNSRoot)" # useful as movable DNS alias or for network load balancer