Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > FTP Login verification

Reply
Thread Tools

FTP Login verification

 
 
Phillip Armitage
Guest
Posts: n/a
 
      03-01-2005
I've spent the better part of two days checking out PHP, javascript and
numerous other language sites trying to find what I figure should be be an
easy web script page. Essentially what I want is a self calling script (ASP,
PHP, whatever) which will do the following:

Let's assume that my script is called FTP.ASP

1) Display an HTML login form prompting user to enter a user name and
password. Login button action (either at the button or form level) calls
ftp.asp again. Ftp server name is hardcoded into the ASP code.

2) When login is clicked on and page reloads itself, take user name and
password values and use them to attempt make a connection to an FTP server
(lots of code out there showing how to do this in PHP. Shame that my version
of php isn't supporting the ftp requests). If login/connection is
unsuccessful, display login form again with a message that previous attempt
failed, please try again.

3) If ftp connection was successful, then username/password combination must
be valid. Open URL ftp://username.

In ASP I've found enough information to accomplish parts 1 and 3. However, I
can't seem to find anything about ASP ftp functions which could be used to
do part 2.

Without having to load third party ftp utilities on my IIS 5 server, any
suggestions on how I can perform step 2? Link to an ASP (not ASP.NET) page
explaining built-in ftp functions?

I look forward to your response


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      03-01-2005
"Phillip Armitage" <> wrote in message
news:...
> I've spent the better part of two days checking out PHP, javascript and
> numerous other language sites trying to find what I figure should be be an
> easy web script page. Essentially what I want is a self calling script

(ASP,
> PHP, whatever) which will do the following:
>
> Let's assume that my script is called FTP.ASP
>
> 1) Display an HTML login form prompting user to enter a user name and
> password. Login button action (either at the button or form level) calls
> ftp.asp again. Ftp server name is hardcoded into the ASP code.
>
> 2) When login is clicked on and page reloads itself, take user name and
> password values and use them to attempt make a connection to an FTP server
> (lots of code out there showing how to do this in PHP. Shame that my

version
> of php isn't supporting the ftp requests). If login/connection is
> unsuccessful, display login form again with a message that previous

attempt
> failed, please try again.
>
> 3) If ftp connection was successful, then username/password combination

must
> be valid. Open URL ftp://username.
>
> In ASP I've found enough information to accomplish parts 1 and 3. However,

I
> can't seem to find anything about ASP ftp functions which could be used to
> do part 2.
>
> Without having to load third party ftp utilities on my IIS 5 server, any
> suggestions on how I can perform step 2? Link to an ASP (not ASP.NET) page
> explaining built-in ftp functions?
>
> I look forward to your response



Will this help? Watch for word-wrap.

<%@ Language="VBScript" %>
<% Option Explicit
'*
'* Declare Constants
'*
Const cASP = "LoginFTP.asp"
Const cFTP = "LoginFTP.ftp"
Const cLOG = "LoginFTP.log"
Const cDOM = "lmsrf.org" 'mydomain.com"
Const cWSS = "%comspec% /C "
Const c500 = "500 " '= Invalid userid/password"
Const c530 = "530 " '= User ??? cannot log in."
Const cERR = "<b>Invalid Username or Password!</b><br><br>"
'*
'* Declare Globals
'*
Dim strUSR
strUSR = Request.Form("User")
Dim strPWD
strPWD = Request.Form("Pass")
Dim strURL
strURL = "ftp://" & strUSR & ":" & strPWD & "@" & cDOM
'*
'* LoginFTP()
'*
If strUSR <> "" And strPWD <> "" Then
If LoginFTP() Then
Response.Redirect(strURL)
Else
Response.Write(cERR)
End If
End If

Function LoginFTP()
'****
'* Return result of attempted login.
'****
LoginFTP = False
'*
'* Declare Variables
'*
Dim strFTP
strFTP = Server.MapPath(cFTP)
Dim strLOG
strLOG = Server.MapPath(cLOG)
Dim strOTF
strOTF = "open " & cDOM & vbCrLf
strOTF = strOTF & strUSR & vbCrLf
strOTF = strOTF & strPWD & vbCrLf
strOTF = strOTF & "close" & vbCrLf
strOTF = strOTF & "bye" & vbCrLf
Dim strWSS
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim objOTF
Dim objWSS
'*
'* Delete ".ftp"
'*
If objFSO.FileExists(strFTP) Then objFSO.DeleteFile(strFTP)
'*
'* Create ".ftp"
'*
Set objOTF = objFSO.OpenTextFile(strFTP,2,true)
objOTF.WriteLine(strOTF)
objOTF.Close()
Set objOTF = Nothing
'*
'* Run ".ftp" to Create ".log"
'*
strWSS = cWSS & " ftp -i -s:" & strFTP & " > " & strLOG
Set objWSS = Server.CreateObject("WScript.Shell")
objWSS.Run strWSS,2,True
Set objWSS = Nothing
'*
If objFSO.FileExists(strFTP) Then objFSO.DeleteFile(strFTP)
'*
'* Read ".log"
'*
Set objOTF = objFSO.OpenTextFile(strLOG,1)
strOTF = objOTF.ReadAll()
objOTF.Close()
Set objOTF = Nothing
'*
Set objFSO = Nothing
'*
'* Return
'*
If InStr(strOTF,c500) > 0 Then Exit Function
If InStr(strOTF,c530) > 0 Then Exit Function
LoginFTP = True
End Function
%>
<html>
<head>
<title><%=cASP%></title>
</head>
<body>
<form action="<%=cASP%>" method="post">
<br><b>Username : </b> &nbsp;
<input type="text" name="User" size="10" maxlength="10">
<br><b>Password : </b> &nbsp;
<input type="text" name="Pass" size="10" maxlength="10">
<br>
<input type="submit" value="Login FTP">
</form>
</body>
</html>


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      03-01-2005
{snip]

Make that:

Const cDOM = "ftp.mydomain.com"


 
Reply With Quote
 
Phillip Armitage
Guest
Posts: n/a
 
      03-02-2005

So close....

Going through your code, testing it in my environment, I've come to
understand that the way you test if the ftp connection is good is by
attempting to open a file on the FTP server. I presume that you believe the
web server running this app to also be the same server running the FTP
server. Sorry, not the case. The ftp server is running on another box and is
not IIS based.

Any idea if there is something along the lines of a
"CreateObject(FTP.Connection)" that comes as part of either VBScript or IIS?

Thanks for the code. I'll keep it around, just in case I move my FTP server
into IIS.


 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      03-02-2005
"Phillip Armitage" <> wrote in message
news:...
>
> So close....
>
> Going through your code, testing it in my environment, I've come to
> understand that the way you test if the ftp connection is good is by
> attempting to open a file on the FTP server. I presume that you believe

the
> web server running this app to also be the same server running the FTP
> server. Sorry, not the case. The ftp server is running on another box and

is
> not IIS based.
>
> Any idea if there is something along the lines of a
> "CreateObject(FTP.Connection)" that comes as part of either VBScript or

IIS?
>
> Thanks for the code. I'll keep it around, just in case I move my FTP

server
> into IIS.



The script isn't "attempting to open a file on the FTP server"; its
attempting to make a connection to the FTP server. The results are placed
in a log file which is examined to see if it failed. If it didn't then it
invokes Response.Redirect.

"I presume that you believe the web server running this app to also be the
same server running the FTP server." -- I do not. "cDOM" identifies the FTP
server both for testing the connection and redirecting. The FTP server does
not have to be "IIS Based".



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      03-02-2005
[snip]

I wasn't able to get the following to work:

ftp://username

from my script. Should this be browser-based?

Also, I don't know if it's supported under Win XP SP2.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sun.net.ftp.FtpProtocolException: Error reading FTP pending reply long990802@gmail.com Java 3 12-11-2005 02:46 AM
Re: ftplib question - ftp.dir() returns something and ftp.nlst()does not Nico Grubert Python 0 11-25-2005 10:09 AM
ftplib question - ftp.dir() returns something and ftp.nlst() does not Nico Grubert Python 0 11-24-2005 02:00 PM
Net::FTP problems getting files from Windows FTP server, but not Linux FTP Server. D. Buck Perl Misc 2 06-29-2004 02:05 PM
FTP over SSL vs FTP over SSH someone Java 1 04-25-2004 03:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57