How to authenticate a user in ActiveDirectory using powershell

I would like to authenticate the user in my ActiveDirectory with username and password. Is there any chance to do this with powershell and the activeDirectory module. Thanks you

+6
source share
2 answers

There are several ways to do this. Here is a quick and easy function that authenticates the user for AD.

Function Test-ADAuthentication { param($username,$password) (new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null } PS C:\> Test-ADAuthentication "dom\myusername" "mypassword" True PS C:\> 

This may not be the best feature for your needs, but your question does not contain details.

+14
source

Requires .NET 3.5 and PowerShell V2

 $UserName = 'user1' $Password = ' P@ssw0rd ' $Domain = $env:USERDOMAIN Add-Type -AssemblyName System.DirectoryServices.AccountManagement $ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain $pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext $ct,$Domain $pc.ValidateCredentials($UserName,$Password) 
+8
source

Source: https://habr.com/ru/post/898677/


All Articles