ForWork.Net

欢迎参观ForWork.Net,快乐工作·快乐生活!你我的快乐生活:)

上一篇: 公益广告,是积极表扬好,还是勇敢揭露好? 下一篇:几个用过的经典入侵技巧整理

使用Serv-U的ODBC功能,可以把ftp用户数据存放在数据库中,这样FTP用户可以很方便的更改自己的密码。下面是以Serv-U 6.0和Sql Server 2000相结合的演示。下载演示(自播放的dmf演示文件),希望对大家有所帮助,这可是一个朋友请我一顿饭我才做出来的,如果你按这个操作也搞定了,也记得请客哦^O^!有什么问题请留言给我哦。

建表Sql 语句:

CREATE TABLE [groupaccounts] ([id] int IDENTITY (1,1) PRIMARY KEY,[Index] int Default 0,[Name] nVarChar(50) default '',[Notes] nVarChar(255) default '')CREATE INDEX [Name] on [groupaccounts]([Name] )CREATE TABLE [groupdiraccess] ([id] int IDENTITY PRIMARY KEY,[Access] nVarChar(255) default '',[Index] int Default 0,[Name] nVarChar(50) default '')CREATE INDEX [Name] on [groupdiraccess]([Name] )CREATE TABLE [groupipaccess] ([id] int IDENTITY PRIMARY KEY,[Access] nVarChar(255) default '',[Index] int Default 0,[Name] nVarChar(50) default '')CREATE INDEX [Name] on [groupipaccess]([Name] )CREATE TABLE [useraccounts] ([id] int IDENTITY PRIMARY KEY,[Access] nVarChar(255) default '',[AlwaysLogin] int Default 0,[ChangePass] int Default 0,[Disable] int Default 0,[Expirationtype] int Default 0,[Expiration] datetime Default '1980-1-1',[Groups] nVarChar(50) default '',[HideHidden] int Default 0,[HomeDir] nVarChar(100) default '',[idleTimeOut] int Default 0,[LogMesfile] nVarChar(100) default '',[MaxIp] int Default -1,[MaxSpeedDown] decimal Default 0,[MaxSpeedUp] decimal Default 0,[MaxUsers] int Default -1,[Name] nVarChar(50) default '',[Needsecure] int Default 0,[Notes] nVarChar(255) default '',[PassType] int Default 0,[Password] nVarChar(50) default '',[Privilege] int Default 0,[QuotaCurrent] decimal Default 0,[QuotaEnable] int Default 0,[QuotaMax] decimal Default 0,[RatioCredit] decimal Default 0,[RatioDown] int Default 0,[RatioType] int Default 0,[RatioUP] int Default 0,[RelPaths] int Default 0,[SessionTimeOut] int Default 0,[SkeyValues] nVarChar(50) default '')CREATE INDEX [Name] on [useraccounts]([Name] )CREATE TABLE [userdiraccess] ([id] int IDENTITY PRIMARY KEY,[Access] nVarChar(255) default '',[Index] int Default 0,[Name] nVarChar(50) default '')CREATE INDEX [Name] on [userdiraccess]([Name] )CREATE TABLE [useripaccess] ([id] int IDENTITY PRIMARY KEY,[Access] nVarChar(255) default '',[Index] int Default 0,[Name] nVarChar(50) default '')CREATE INDEX [Name] on [useripaccess]([Name] )

ServUDaemon.ini中的ODBC信息

ODBCSource=Serv-U||ODBCTables=useraccounts|groupaccounts|userdiraccess|groupdiraccess|useripaccess|groupipaccessODBCColumns=Name|Password|SkeyValues|HomeDir|LogMesfile|Access|Disable|Needsecure|RelPaths|HideHidden|AlwaysLogin|ChangePass|QuotaEnable|MaxIp|MaxSpeedUp|MaxSpeedDown|MaxUsers|idleTimeOut|SessionTimeOut|RatioUP|RatioDown|RatioCredit|QuotaCurrent|QuotaMax|Expiration|Privilege|PassType|RatioType|Groups|Notes|Index

在线更改Serv-U密码示例代码<!--#include file='conn.asp'-->
<!--#include file='include/md5.asp'-->
<%
dim act,UserName,OldPassword,NewPassword,reNewPassword
act = Request.form("act")
if act = "update" then

 UserName  = Request.form("UserName")
 OldPassword  = Request.form("OldPassword")
 NewPassword  = Request.form("NewPassword")
 reNewPassword = Request.form("reNewPassword")
 UserName  = Replace(UserName,"'","'")

 if len(UserName)<1 or len(OldPassword)<1 or len(NewPassword)<1 or len(reNewPassword)<1 then
  alert("表单没有填写完整")
 end if

 if trim(NewPassword)<>trim(reNewPassword) then
  alert("密码与确认密码不一样")
 end if

 Sql0 = "select top 1 name,[password] from [useraccounts] where name = '"& UserName &"'"
 set rs0 = conn.execute(Sql0)
 if rs0.eof and rs0.bof then
  alert("用户名不存在")
 else
  dbname = rs0("name")
  dbpassword = rs0("password")
 end if

 cdbpassword = left(dbpassword,2) & md5(left(dbpassword,2) & OldPassword)

 if trim(cdbpassword) <> trim(dbpassword) then
  alert("密码错误")
 else
  rndstr = MyRandc(2) '两位随机字母
  newdbpassword = rndstr &  md5(rndstr & NewPassword)
  sql2 = "update [useraccounts] set [password] = '"& newdbpassword &"' where name='"& UserName &"'"
  conn.execute(sql2)
  alert("密码已经更改,可能要几钟后才能生效")
 end if
end if

function alert(x)
 response.write "<script language='JavaScript'>alert('"& replace(x,"""","\""") &"');history.go(-1);</script>"
 conn.close
 set conn = nothing
 response.end
end function

function MyRandc(n)'生成随机字符,n为字符的个数
 thechr = ""
 for i=1 to n
  Randomize timer
  zNum = cint(25*Rnd)
  if zNum mod 2 = 0 then
   zNum = zNum + 97
  else
   zNum = zNum + 65
  end if
  thechr = thechr & chr(zNum)
 next
 MyRandc = thechr
end function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META NAME="Author" CONTENT="Person01">
<META NAME="Keywords" CONTENT="http://www.forwork.net">
<title>更改FTP (Serv-U) 密码 -www.forwork.net</title>
</head>
<body>
<form method="POST" action="" name="form" autocomplete="off">
<input type="hidden" name="act" value="update">
<div align="center">
  <center>
      <table border="0" width="480" cellpadding="2" cellspacing="1" class="table" style="border: 1 solid #336699;font-size:14px;">
        <tr>
          <td width="100%" align="center" colspan="2" class="title" style="background:#336699;color:#FFFFFF;">更改FTP (Serv-U) 密码</td>
        </tr>

        <tr>
          <td width="30%" align="left"> 用户名[√]:</td>
          <td width="70%"><input class="input" type="text" maxlength=20  name="UserName" size="25" value="" /> (FTP登陆用户名)</td>
        </tr>
 
        <tr>
          <td width="30%" align="left"> 旧密码[√]:</td>
          <td width="70%"><input class="input" type="password" maxlength=20  name="OldPassword" size="25" value="" /> (必须输入旧密码)</td>
        </tr>

        <tr>
          <td width="30%" align="left"> 新密码[√]:</td>
          <td width="70%"><input class="input" type="password" name="NewPassword" size="25" value="" /> (输入新密码)</td>
        </tr>

        <tr>
          <td width="30%" align="left"> 确 认[√]:</td>
          <td width="70%"><input class="input" type="password" name="reNewPassword" size="25" value="" /> (再次输入新密码)</td>
        </tr>

        <tr>
          <td width="100%" height="30" align="center" colspan="2"><input style="font-size:14px;" type="submit" size="10" value="确 定" class=button></td>
        </tr>
      </table>
  </center>
</div>
</html>
<%
set rs = nothing
conn.close
set conn = nothing
%>

 

点击这里获取该日志的TrackBack引用地址

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于本文

您正在阅读的是:serv-u的odbc设置
Person01 发表于:2008-3-12 8:3:31
分类:技术文摘
关键词:Serv-u  ftp  sql  ODBC  技术  学习  

最近发表

最新评论及回复

最近留言

友情链接

控制面板

Search

网站分类

文章归档

图标汇集

订阅ForWork.Net

什么是RSS订阅?查看解释
订阅到您的在线阅读器

抓虾 google reader my yahoo bloglines 鲜果 哪吒

博客作者

Person01

Copyright 2006-2008 ForWork.Net 【快乐工作·快乐生活】 Rights Reserved.  苏ICP备05070716号

Powered By Z-Blog 1.8 Walle Build 100427 Code detection by Codefense 网络支持 网服数据