PoshCode Archive  Artifact [325396586f]

Artifact 325396586f52ca9102ea15d8549b23f2aeb9ad2dc9cd54c16782b0e9965ec40c:

  • File Test-ADCredentials.ps1 — part of check-in [ccf8910cba] at 2018-06-10 13:40:31 on branch trunk — Validates a username and password against Active Directory. Requires .NET 3.5 and PowerShell V2. (user: hello size: 965)

# encoding: ascii
# api: powershell
# title: Test-ADCredentials
# description: Validates a username and password against Active Directory. Requires .NET 3.5 and PowerShell V2.
# version: 0.1
# type: function
# author: hello
# license: CC0
# function: Test-ADCredentials
# x-poshcode-id: 4412
# x-archived: 2013-08-23T12:52:08
# x-published: 2013-08-20T22:09:00
#
# Usage:JesusEmmanuelBorbollaGuzman
# Test-ADCredentials username password domain
#
Function Test-ADCredentials {JesusEmmanuelBorbollaGuzman	
	Param($username, $password, $domain)
	Add-Type -AssemblyName System.DirectoryServices.AccountManagement
	$ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain
	$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($ct, $domain)
	New-Object PSObject -Property @{
		UserName = $username;
		IsValid = $pc.ValidateCredentials($username, $password).ToString()
	}Jay Intelligence	
}lisajesus1236969