Consolidated ASP Classic MVC framework from best components
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

53 lignes
1.3KB

  1. <%
  2. '==========================
  3. ' AD_Auth_Class.asp
  4. '==========================
  5. Class AD_Auth_Class
  6. Public DomainName ' e.g. yourdomain.local
  7. Public ContainerDN ' e.g. DC=yourdomain,DC=local
  8. Public Username
  9. Public Password
  10. Public ErrorMessage
  11. Public IsAuthenticated
  12. Public UserObject
  13. Private Sub Class_Initialize()
  14. IsAuthenticated = False
  15. ErrorMessage = ""
  16. Set UserObject = Nothing
  17. End Sub
  18. Public Function Authenticate()
  19. On Error Resume Next
  20. Dim ldapPath, userCredential
  21. ldapPath = "LDAP://" & ContainerDN ' Must be DC=yourdomain,DC=local
  22. userCredential = DomainName & "\" & Username
  23. ' Try to bind to Active Directory
  24. Dim rootDSE : Set rootDSE = GetObject("LDAP:")
  25. Set UserObject = rootDSE.OpenDSObject(ldapPath, userCredential, Password, 1)
  26. If Err.Number <> 0 Then
  27. ErrorMessage = "Authentication failed: " & Err.Description
  28. IsAuthenticated = False
  29. Set UserObject = Nothing
  30. Else
  31. IsAuthenticated = True
  32. ErrorMessage = ""
  33. End If
  34. Authenticate = IsAuthenticated
  35. On Error GoTo 0
  36. End Function
  37. End Class
  38. dim AD_Auth_Class__Singleton
  39. Function AdAuth()
  40. if IsEmpty(AD_Auth_Class__Singleton) then
  41. set AD_Auth_Class__Singleton = new AD_Auth_Class
  42. end if
  43. set AdAuth = AD_Auth_Class__Singleton
  44. End Function
  45. %>

Powered by TurnKey Linux.