Validating Active Directory Credentials

by Aug 12, 2019

PowerShell can validate AD username and passwords against the Active Directory:

Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$account = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([DirectoryServices.AccountManagement.ContextType]::Domain, $env:userdomain)

$account.ValidateCredentials('user12', 'topSecret')

Note that this approach is for diagnostic purposes only. It accepts a plain text password.


Twitter This Tip! ReTweet this Tip!