欢迎光临
我们一直在努力

ASP+MS SQL在线修改Serv-u的密码教程-ASP教程,ASP应用

建站超值云服务器,限时71元/月

 

下面是以serv-u 6.0和sql server 2000相结合的演示。

建表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|groupipaccess
odbccolumns=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的obdc功能,可以把ftp用户信息存在数据库中,这样对web操作方便了很多,下面是在线更改密码的列子,数据库为access,表和字段的设计请参考serv-u的帮助文件。

加密算法为随机码与md5 32 位加密,例如:
两个随机字母:ab
用户输入密码:123456
生成的密码为:ab + md5(ab123456)

补充:md5返回为32位的大写字符,附md5.asp

提示:代码仅实现更改密码的功能,并不一定完全符合或达到您的需求。

<!–#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=”海娃(51windows)”>
<meta name=”keywords” content=”http://www.51windows.net”>
<title>更改ftp (serv-u) 密码 – 51windows.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
%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP+MS SQL在线修改Serv-u的密码教程-ASP教程,ASP应用
分享到: 更多 (0)