Guest User

Untitled

a guest
Jan 3rd, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. Function Test-UserCredential {
  2. Param($username, $password)
  3. Add-Type -AssemblyName System.DirectoryServices.AccountManagement
  4. $ct = [System.DirectoryServices.AccountManagement.ContextType]::Machine, $env:computername
  5. $opt = [System.DirectoryServices.AccountManagement.ContextOptions]::SimpleBind
  6. $pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList $ct
  7. $Result = $pc.ValidateCredentials($username, $password).ToString()
  8. $Result
  9. }
  10.  
  11. $comp_username = Get-Property -Name COMPUTER_USERNAME
  12.  
  13. $comp_password = Get-Property -Name COMPUTER_PASSWORD
  14.  
  15. $result = Test-UserCredential -username $comp_username -password $comp_password
  16.  
  17. if ($result)
  18. {
  19. #Enable "Next" button
  20. }
  21.  
  22. else
  23. {
  24. #Disable "Next" button
  25. }
Add Comment
Please, Sign In to add comment