您的位置:首页精文荟萃软件资讯 → 创建ASP组件修改《SERV-U》FTP 的密码

创建ASP组件修改《SERV-U》FTP 的密码

时间:2004/10/7 19:16:00来源:本站整理作者:蓝点我要评论(0)


            
             
              
             
            

               
               

            



            新建一《SERV-U》FTP服务器,在ASP中修改指定帐户的密码,写了一ASP组件来修改《SERV—U》  FTP密码。
启动《Vb6.0》,选择新建ActiveX DLL,更改工程属性中的工程名称为“Ftpcommand”,将CLASS名改为XJNFTP,源程序如下:

Private Const scUserAgent = "vb wininet"
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const INTERNET_OPEN_TYPE_PROXY = 3
Private Const INTERNET_INVALID_PORT_NUMBER = 0
Private Const FTP_TRANSFER_TYPE_BINARY = &H2
Private Const FTP_TRANSFER_TYPE_ASCII = &H1
Private Const INTERNET_FLAG_PASSIVE = &H8000000
Private Const INTERNET_SERVICE_FTP = 1
Private Const INTERNET_SERVICE_GOPHER = 2
Private Const INTERNET_SERVICE_HTTP = 3
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function FtpCommand Lib "wininet.dll" Alias "FtpCommandA" _
(ByVal hConnect As Long, ByVal fExpectResponse As Boolean, ByVal dwFlags As Long, _
ByVal lpszCommand As String, ByVal lContext As Long, phFtpCommand As Long) As Boolean
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _
ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long
Private hOpen As Long
Private hConnection As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer
Private newPASSWORD As String
Private oldPASSWORD As String
Private userName As String
Private URLSTR As String


‘修改FTP密码主程序
Public Function getStr() As String
hOpen = 0
    hConnection = 0
    Dim nFlag As Long
    Dim strCmd As String
nFlag = INTERNET_FLAG_PASSIVE
‘建立FTP修改密码命令字符串
strCmd = "SITE PSWD " & oldPASSWORD & Space(1) & newPASSWORD
‘建立internet连接
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
If hOpen = 0 Then getStr = "不能打开连接。..."
If hOpen <> 0 Then
‘与FTP服务器建立连接
  hConnection = InternetConnect(hOpen, URLSTR, NTERNET_INVALID_PORT_NUMBER, _
  userName, oldPASSWORD, INTERNET_SERVICE_FTP, nFlag, 0)
   If hConnection <> 0 Then
    bret = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCmd, 0, hFile)
       If bret Then
         getStr = "密码修改成功!..."
         Else
         getStr = "密码修改失败!..."
       End If
    Else
       getStr = "无法登录至FTP服务器,请检查帐户名或密码是否正确。"
   End If
End If
‘断开internet连接
If hConnection <> 0 Then InternetCloseHandle (hConnection)
‘断开FTP服务器连接
If hOpen <> 0 Then InternetCloseHandle (hOpen)
End Function
‘传入FTP服务器的URL
Public Property Let URL(URL1 As String)
URLSTR = URL1
End Property

‘传入FTP原有密码
Public Property Let oldPSD(psd As String)
    oldPASSWORD = psd
End Property

‘传入FTP新密码
Public Property Let newPSD(psd1 As String)
     newPASSWORD = psd1
End Property

‘传入FTP帐户名
Public Property Let user(psd2 As String)
     userName = psd2
End Property

编译成Ftpcommand.DLL,在ASP服务器端注册该组件,(VB6.0在ASP服务器中自动注册),在ASP中调用该组件,源程序如下:
<%
‘接受传入的帐户名
user=trim(request.form("id"))
‘接受传入的原密码
psw=trim(request.form("password"))
‘接受传入的新密码
pswx=trim(request.form("passwordx"))
‘创建FTP组件应用实例
Dim obj
Set obj = Server.CreateObject("ftpcommand.xjnftp")
‘给FTP组件传送帐户名
obj.user=user
‘给FTP组件传送原密码
obj.oldpsd=psw
‘给FTP组件传送新密码
obj.newpsd=pswx
‘给FTP组件传送FTP服务器域名地址(URL)
obj.url="ftp://ftp.luckybbs.com";
rr=obj.getstr()
Response.Write("")
Response.Write("

"+rr+"!")
Response.Write("
系统3秒钟后自动返回!!!
")
Response.Write("
返回
")
set obj=nothing
response.end
%>

本实例在WINDOWS 2000 SERVER ,IIS 5.0 ,SERV-U4.0 ,VB6.0中通过。

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3

最新文章 微信3.6.0测试版更新了微信支付漏洞会造成哪 360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗

人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本