Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/05/2010, 12:41
Canal_on
 
Fecha de Ingreso: julio-2007
Mensajes: 16
Antigüedad: 16 años, 10 meses
Puntos: 2
Respuesta: Generar Public Function con un trozo de código

Ok, gracias!!

mi manera de ejecutar la función no debe de ser correcta... pero ya veo que no es problema de la función en si misma

probaré a cambiar mi página llamando a la función de otra forma

reitero gracias!


sl2


Cita:
Iniciado por Myakire Ver Mensaje
Cómo que no funciona?

Claro que lo hace

Código ASP:
Ver original
  1. <%
  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>