asp+|serv-u|sql| Tutorials | online
The following is a demonstration combined with Serv-u 6.0 and SQL Server 2000.
To build a table SQL statement:
CREATE TABLE [Groupaccounts] (
[id] int IDENTITY (1,1) PRIMARY KEY,
[Index] int Default 0,
[Name] NVarChar 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 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 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 default ',
[Hidehidden] int Default 0,
[Homedir] NVarChar default ',
[idletimeout] int Default 0,
[Logmesfile] NVarChar default ',
[MAXIP] int Default-1,
[Maxspeeddown] Decimal Default 0,
[Maxspeedup] Decimal Default 0,
[maxusers] int Default-1,
[Name] NVarChar default ',
[needsecure] int Default 0,
[Notes] NVarChar (255) Default ',
[Passtype] int Default 0,
[Password] NVarChar 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 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 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 default '
)
CREATE INDEX [name] on [useripaccess] ([name])
ODBC Information in Servudaemon.ini:
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
We use the Serv-u OBDC function, you can put the FTP user information in the database, so that a lot of web operations convenient, the following is an online change password, the database for Access, table and field design refer to the Serv-u Help file.
Encryption algorithm for random code and MD5 32-bit encryption, for example:
Two random letters: AB
User input Password: 123456
The generated password is: AB + MD5 (ab123456)
Add: MD5 return to 32-bit uppercase characters, attached md5.asp
Tip: Code only implements the ability to change passwords, and does not necessarily fully meet or meet your needs.
<!--#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 ("form is not filled in complete")
End If
If Trim (newpassword) <>trim (Renewpassword) Then
Alert ("Password is not the same as confirmation password")
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 ("User name does not exist")
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 ("Password error")
Else
Rndstr = MYRANDC (2) ' Two-bit random letter
Newdbpassword = RNDSTR & MD5 (RNDSTR & NewPassword)
SQL2 = "Update [useraccounts] set [password] = '" & Newdbpassword & "where Name=" "& UserName &" "
Conn.execute (SQL2)
Alert ("Password has changed, may take several minutes to take effect")
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) ' generates random characters, n is the number of characters
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
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Author" content= "Web Teaching Network" >
<meta name= "Keywords" content= "http://www.webjx.com" >
<title> Change FTP (serv-u) password-51windows.net</title>
<body>
<form method= "POST" action= "name=" form "autocomplete=" off ">
<input type= "hidden" name= "act" value= "Update" >
<div align= "center" >
<center>
<table border= "0" width= "cellpadding=" 2 "cellspacing=" 1 "class=" table "style=" border:1 solid #336699; : 14px; " >
<tr>
<TD width= "100%" align= "center" colspan= "2" class= "title" style= "background: #336699; color: #FFFFFF; > Change FTP (serv-u) password </td>
</tr>
<tr>
<TD width= "30%" align= "left" > user name [√]:</td>
<TD width= "70%" ><input class= "input" type= "text" maxlength=20 name= "UserName" size= "value=" " /> (FTP login username) </td>
</tr>
<tr>
<td width= "30%" align= "left" > Old password [√]:</td>
<td width= " 70% "><input class=" input "type=" password "maxlength=20 name=" OldPassword "size=" "value=" "/>" ( Must enter old password) </td>
</tr>
<tr>
<TD width= "30%" align= "left" > New password [√]:</td>
<TD width= "70%" ><input class= "input" type= "password" name= "NewPassword" size= "value=" "/>" (Enter new password) </ Td>
</tr>
<tr>
<TD width= "30%" align= "Left" > Confirmation [√]:</td>
<TD width= "70%" ><input class= "input" type= "password" name= "Renewpassword" size= "value=" "/>" (Enter new password again) </td>
</tr>
<tr>
<TD width= "100%" height= "align=" center "colspan=" 2 "><input style=" font-size:14px; "type=" Submit "size=" Value= "OK" class=button></td>
</tr>
</table>
</center>
</div>
<%
Set rs = Nothing
Conn.close
Set conn = Nothing
%>