Advertisement
Guest User

Untitled

a guest
Sep 14th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <%
  2.  
  3. Dim objLogon
  4.  
  5. ' create an object for impersonating IIS to use a valid domain user instead of anonymous user IUSR_machinename
  6. Set objLogon = Server.CreateObject("LoginAdmin.ImpersonateUser")
  7.  
  8. ' any domain user who has rights to access active directory
  9. objLogon.Logon "user id", "password", "domain name"
  10.  
  11. ' check here for a form post ...
  12. if request("GETUSER") = "" Then
  13.  
  14. ' write out the form
  15. With Response
  16. .write "<p><h3>Active Directory Login Form</h3></p><br>"
  17. .write "<FORM ACTION=login.asp METHOD=POST>"
  18. .write "<INPUT TYPE=TEXT NAME=oUSer>ENTER USER NAME TO CHECK<BR>"
  19. .write "<INPUT TYPE=PASSWORD NAME=oPassword>ENTER USER PASSWORD<BR>"
  20. .Write "<INPUT TYPE =SUBMIT NAME=GETUSER VALUE=CHECK>"
  21. .write "</FORM>"
  22. end with
  23.  
  24. else
  25. ' Form was autopostback, grab the form variables ...
  26. strUser = Request("oUser")
  27. strPassword = Request("oPassword")
  28.  
  29. Set oUser = Server.CreateObject("prjLogin.clsDomainLogin")
  30.  
  31. ' BindObject has two parameters userid and password
  32. iResult = oUser.BindObject(strUser, strPassword, "localhost")
  33.  
  34. 'on error resume next
  35. ' Set reference to the ADSI interface to NT User Manager ...
  36.  
  37. Response.write "<p><h4>Output</h4></p>"
  38.  
  39. if iResult = 1 then
  40. Response.write "<br>Login success!"
  41. ' Whatever you want to process here
  42. else
  43. Response.write "<br>BAD PASSWORD!"
  44. ' Whatever you want to process here
  45. end if
  46.  
  47. set oUser = Nothing
  48.  
  49. end if
  50. objLogon.Logoff
  51. Set objLogon = Nothing
  52. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement