Classic ASP
Classic ASP
Log In After ConnectOnly on an FTP Server
See more FTP Examples
Demonstrates the Chilkat Ftp2.LoginAfterConnectOnly method, which authenticates a control connection previously established by ConnectOnly. It takes no arguments, sends USER, PASS, and ACCT when required, then performs normal post-login initialization.
Background: This is the second half of the two-step connect. Beyond sending the credentials, it runs the same post-login setup
Connect would — for example issuing TYPE I and any auto-negotiated features — so the session ends up in the same ready state either way. The value of the split is entirely in what you can do in the gap between the two calls.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Demonstrates the Ftp2.LoginAfterConnectOnly method, which authenticates a control connection
' previously established by ConnectOnly. It takes no arguments and sends USER, PASS, and (when
' required) ACCT, then performs normal post-login initialization.
set ftp = Server.CreateObject("Chilkat.Ftp2")
ftp.Hostname = "ftp.example.com"
ftp.Port = 21
' First connect without logging in.
success = ftp.ConnectOnly()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( ftp.LastErrorText) & "</pre>"
Response.End
End If
' Set credentials (for example, after inspecting the greeting), then log in.
ftp.Username = "myFtpLogin"
ftp.Password = "myPassword"
success = ftp.LoginAfterConnectOnly()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( ftp.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Logged in.") & "</pre>"
success = ftp.Disconnect()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( ftp.LastErrorText) & "</pre>"
Response.End
End If
%>
</body>
</html>