Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/11/2004, 18:34
Avatar de luisvasquez
luisvasquez
 
Fecha de Ingreso: diciembre-2003
Ubicación: Venezuela
Mensajes: 879
Antigüedad: 21 años, 5 meses
Puntos: 6
Como validar un dominio usando ASP?

Amigos,

Tengo una función para ejecutar el comando nslookup y verificar desde ASP si existe un dominio. Es parte de una función que valida el correo.

La idea es validar una forma donde el visitante introduce un correo para Recomendar mi sitio, a cambio de una contraseña de acceso temporal.

Pues bien, me atrevo a decir que el 90% de los correos introducidos en la forma pertenecen a dominios como dsdsdsd.com o algo por el estilo.

Esta función pretende validar esto en la forma, pero hasta ahora no lo he podido hacer andar.

En mi Pc local (Windows 2000 Pro con IIS 5) se queda el browser en blanco durante mucho tiempo y al final debo reiniciar el IIS. Puse para seguir donde se queda colgado y es precisamente en la ejecución del comando nslookup (pueden ver la linea en ROJO).

Cuando lo monto en el server, TODOS los dominios aparecen como invalidos...

Podrían darle un vistazo y ayudarme con esto?? creo que al final será util para todos...

Saludos y gracias, Luis Vásquez
<%

Function DomainLookup(sDomain)
Dim sReadData 'As String
Dim fIpIsNextLine 'Ad boolean
'Crear el objeto
set oShell = Server.CreateObject("Wscript.Shell")

'Ejecutar NSLookup via Cmd y poner el resultado en un archivo temporal

oShell.Run "%ComSpec% /c nslookup " & sDomain & " > %Tmp%\" & Session.SessionID & sDomain & ".txt", 0, True

'Abrir el archivo y leer el contenido para buscar la IP, lo cual nos indicará que el dominio EXISTE

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set oText = Fso.OpenTextFile("%Tmp%\" & Session.SessionID & sDomain & ".txt")

Do While Not oText.AtEndOfStream

'Read In the Text Dump
sReadData = Trim(oText.Readline)

'If the domain name was found in the previous line read then this should be the IP.
If fIpIsNextLine then DomainLookup = True

'If the domain name was found in the Read line then the tell it the next line is the Ip.
'If an IP address was not found then it should not return the domain we are looking for in
' the txt file.
If Instr(1, sReadData, sDomain) then fIpIsNextLine = true
Loop

' Cerrar el archivo
oText.Close
' Borrar el archivo
FSO.DeleteFile "%Tmp%" & Session.SessionID & sDomain & ".txt"
Set FSO = Nothing
End Function
%>

Última edición por luisvasquez; 04/11/2004 a las 18:37