Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/05/2010, 09:41
Avatar de Myakire
Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 22 años, 3 meses
Puntos: 146
Respuesta: Generar Public Function con un trozo de código

Cómo que no funciona?

Claro que lo hace

Código ASP:
Ver original
  1. <&#37;
  2. FUNCTION ValidaLdap(strUsername,strpassword,domainname)
  3.  
  4. Set objDomain = GetObject ("GC://rootDSE")
  5. objADsPath = objDomain.Get("defaultNamingContext")
  6. Set objDomain = Nothing
  7. Set objConnection = Server.CreateObject("ADODB.Connection")
  8. objConnection.provider ="ADsDSOObject"
  9. objConnection.Properties("User ID") = domainname+"\" + strUsername
  10. objConnection.Properties("Password") = strpassword
  11. objConnection.open "Active Directory Provider"
  12. Set objCommand = CreateObject("ADODB.Command")
  13. Set objCommand.ActiveConnection = objConnection
  14. objCommand.CommandText ="select cn FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
  15.  
  16. on error resume next
  17.  
  18. Set objRS = objCommand.Execute
  19.  
  20. If Err.Number <> 0 Then
  21. ldap = 0
  22. Else
  23. ldap = 1
  24. End If
  25. ValidaLdap = ldap
  26.  
  27. End Function
  28.  
  29. if Request("login") <> "" Then
  30.    if ValidaLdap(Request("login"), Request("password"), Request("dominio")) Then
  31.         response.write "Correcto"
  32.      else
  33.         response.write "Incorrecto"
  34.    end if
  35. End if
  36.  
  37. %>
  38.  
  39.  
  40. <html>
  41. <body>
  42. <form method=post>
  43.   Login:&nbsp; <input type="text" name="login"    value=""><br>
  44.     Password:&nbsp; <input type="password" name="password" value=""><br>
  45.     Dominio:&nbsp; <input type="text" name="dominio" value="">
  46.     <input type="submit" name="btn" value="Login">
  47. </form>
  48. </body>
  49. </html>