Consolidated ASP Classic MVC framework from best components
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

45 wiersze
1.3KB

  1. <%
  2. Function HashPassword(password)
  3. Dim shell, command, execObj, outputLine, result
  4. ' Create Shell Object
  5. Set shell = CreateObject("WScript.Shell")
  6. ' Construct PowerShell Command
  7. command = "cmd /c powershell -ExecutionPolicy Bypass -NoLogo -NoProfile -File """ & Server.MapPath(".") & "..\Core\hash_sha256.ps1"" -password " & password
  8. ' Execute Command
  9. Set execObj = shell.Exec(command)
  10. ' Read Output
  11. Do While Not execObj.StdOut.AtEndOfStream
  12. outputLine = Trim(execObj.StdOut.ReadAll())
  13. If outputLine <> "" Then
  14. result = outputLine ' Capture the hash
  15. End If
  16. Loop
  17. ' Cleanup
  18. Set shell = Nothing
  19. Set execObj = Nothing
  20. ' Return the hash or error message
  21. If result = "" Or Left(result, 5) = "ERROR" Then
  22. HashPassword = result ' "ERROR: Hash not generated"
  23. Else
  24. HashPassword = result
  25. End If
  26. End Function
  27. Function CheckPassword(username, password)
  28. Dim user,UsersRepository
  29. Set UsersRepository = CreateRepository(conn, "Users", "UserId")
  30. ' Find User
  31. Set User = UsersRepository.Find(Array("UserName", user), Empty)
  32. If user Is Nothing Then Exit Function ' Implicitly returns False
  33. ' Compare Hashed Password
  34. CheckPassword = (HashPassword(password) = user.PasswordHash)
  35. End Function
  36. %>

Powered by TurnKey Linux.