For details, please refer to: http://asp2004.net/dvbbs/dispbbs.asp? BoardID = 6 & id = 287 Database script: / ****** Object: Database Host Script Date: 2004-12-24 13:16:31 ****** / if EXISTS (Select Name from Master.dbo.sysDatabases Where Name = N'Host ') DROP DATABASE [HOST] GO
Create Database [host] on (name = n'Host_data ', filename = n'd: /wwwroot/host/database/host.mdf', size = 2, filegrowth = 10%) log on (Name = n'Host_log ' , Filename = n'd: /wwwroot/host/database/host_log.ldf ', size = 9, filegrowth = 10%) Collate Chinese_prc_ci_ASGO
EXEC SP_DBOPTION N'HOST ', N'AUTOCLOSE', N'FALSe'go
EXEC SP_DBOPTION N'HOST ', N'BULKCOPY', N'FALSE'GO
EXEC SP_DBOPTION N'HOST ', N'TRUNC. LOG', N'FALSE'GO
EXEC SP_DBOPTION N'HOST ', N'TORN PAGE Detection', N'true'go
EXEC SP_DBOPTION N'HOST ', N'READ ONLY', N'FALSE'go
EXEC SP_DBOPTION N'HOST ', N'DBO USE', N'FALSE'go
EXEC SP_DBOPTION N'HOST ', N'SINGLE', N'FALSE'GO
EXEC SP_DBOPTION N'HOST ', N'AUTOSHRINK', N'FALSE'GO
EXEC SP_DBOPTION N'HOST ', N'SI Null Default', N'False'go
EXEC SP_DBOPTION N'HOST ', N'Recursive Triggers', N'False'go
EXEC SP_DBOPTION N'HOST ', N'si Nulls', N'False'go
EXEC SP_DBOPTION N'HOST ', N'CONCAT NULL YIELDS NULL', N'FALSE'go
EXEC SP_DBOPTION N'HOST ', N'CURSOR Close on Commit', N'False'go
EXEC SP_DBOPTION N'HOST ', N'DEFAULT to LOCAL CURSOR', N'FALSE'GO
EXEC SP_DBOPTION N'HOST ', N'QUOTED Identifier', N'False'goexec Sp_dboption N'Host ', N'si Warnings', N'False'go
EXEC SP_DBOPTION N'HOST ', N'AUTO CREATE STATISTISTIS', N'TRUE'GO
EXEC SP_DBOPTION N'HOST ', N'AUTO UPDATE STATISTICS', N'TRUE'GO
Use [host] Go
/ ****** Object: Table [DBO]. [GroupAccess] Script date: 2004-12-24 13:16:31 ****** / if EXISTS (SELECT * from dbo.sysobjects where id = Object_id (N '[dbo]. [Groupaccess]') And ObjectProperty (ID, n'susertable ') = 1) Drop Table [dbo]. [Groupaccess] Go
/ ****** Object: table [dbo]. [Groupaccounts] script date: 2004-12-24 13:16:31 ****** / if EXISTS (SELECT * from dbo.sysObjects where id = Object_id (N '[dbo]. [Groupaccounts]') And ObjectProperty (ID, n'susertable ') = 1) Drop Table [dbo]. [Groupaccounts] Go
/ ****** Object: table [dbo]. [Groupipaccess] script date: 2004-12-24 13:16:31 ****** / if exists (select * from dbo.sysObjects where id = Object_ID (N '[dbo]. [Groupipaccess]') And ObjectProperty (ID, n'susertable ') = 1) Drop Table [dbo]. [Groupipaccess] Go
/ ****** Object: table [dbo]. [Useeraccess] script date: 2004-12-24 13:16:31 ****** / if EXISTS (Select * from dbo.sysObjects where id = Object_id (N '[dbo]. [Useeraccess]') And ObjectProperty (ID, n'susertable ') = 1) Drop Table [dbo]. [Useeraccess] GO
/ ****** Object: table [dbo]. [Useeraccounts] script date: 2004-12-24 13:16:31 ******* / if EXISTS (SELECT * from dbo.sysObjects where id = Object_id (N '[dbo]. [Useraccounts]') And ObjectProperty (ID, n'susertable ') = 1) Drop Table [dbo]. [Useeraccounts] Go
/ ****** Object: table [dbo]. [Useripaccess] script date: 2004-12-24 13:16:31 ****** / if EXISTS (Select * from dbo.sysObjects where id = Object_id (N '[DBO]. [Useripaccess]') And ObjectProperty (ID, n'susertable ') = 1) DROP TABLE [DBO]. [Useripaccess] go / ****** Object: table [dbo]. GroupAccess: 2004-12-24 13:16:34 ****** / CREATE TABLE [DBO]. [GroupAccess] ([indexno] [int] null, [username] [nvarchar] (50) Collate Chinese_prc_ci_as null, [access] [nvarchar] (200) collate chinese_prc_ci_as null, [GAID] [INT] Identity (1, 1) Not null) on [primary] GO
/ ****** Object: table [dbo]. [Groupaccounts] script date: 2004-12-24 13:16:36 ****** / CREATE TABLE [DBO]. [GroupAccounts] ([username] [nvarchar] (50) collate chinese_prc_ci_as null, [access] [nvarchar] (200) collate chinese_prc_ci_as null, [notes] [nvarchar] (200) collate chinese_prc_ci_as null, [Gasid] [INT] Identity (1, 1) Not null ) On [primary] Go
/ ****** Object: table [dbo]. [Groupipaccess] script date: 2004-12-24 13:16:36 ****** / CREATE TABLE [DBO]. [GroupiPaccess] ([IndexNo] [int] null, [username] [nvarchar] (50) collate chinese_prc_ci_as null, [access] [nvarchar] (200) collate chinese_prc_ci_as null, [gipaid] [INT] Identity (1, 1) not null) on [primary] Go
/ ****** Object: table [dbo]. [Useeraccess] script date: 2004-12-24 13:16:37 ****** / CREATE TABLE [DBO]. [Useeraccess] ([indexno] [int] null, [username] [nvarchar] (50) collate chinese_prc_ci_as null, [access] [nvarchar] (200) collate chinese_prc_ci_as null, [UAID] [INT] Identity (1, 1) Not null) ON [primary] Go
/ ****** Object: table [dbo]. [Useeraccounts] script date: 2004-12-24 13:16:37 ****** / CREATE TABLE [DBO]. [Useraccounts] ([ID] [int] Identity (1, 1) NOT NULL, [Username] [NVARCHAR] (50) Collate Chinese_PRC_CI_AS NOT NULL, [PASSWORD] [NVARCHAR] (50) Collate Chinese_PRC_CI_AS NULL, [Disable] [Bit] Not Null, [Access] ] [nvarchar] (255) collate chinese_prc_ci_as null, [ChangePass] [bit] NOT NULL, [PASSTYPE] [Tinyint] NOT NULL, [EXPIRATION] [SmallDateTime] NULL, [ExpirationType] [tinyint] not null, [SKEY] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL, [RelPaths] [bit] NOT NULL, [HomeDir] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL, [MessageFile] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL, [MaxUsers] [int ] NOT NULL, [MAXUP] [INT] NOT NULL, [MAXDOWN] [INT] NULL, [Ratioup] [INT] null, [Ratiodown] [INT] null, [Ratiocredit] [FLOAT] NULL, [Ratiotype] [ Tinyint] NULL, [quotaenable] [bit] not null, [quotamax] [int] not null, [quotacurrent] [int] not null, [GRO UPS] [nvarchar] (255) collate chinese_prc_ci_as null, [privileg] [tinyint] not null, [LockHomedir] [bit] not null) on [primary] go / ****** Object: Table [dbo]. Useripaccess] script date: 2004-12-24 13:16:38 ****** / CREATE TABLE [DBO]. [UseriPaccess] ([IndexNo] [Smallint] null, [username] [nvarchar] (50) collate Chinese_prc_ci_as null, [Access] [nvarchar] (200) collate chinese_prc_ci_as null, [UIPAID] [INT] Identity (1, 1) Not null) on [primary] GO
Alter Table [DBO]. [GroupAccess] with nocheck address [pk_groupaccess] Primary Key Clustered ([GAID]) on [primary] GO
Alter Table [DBO]. [Groupaccounts] with nocheck add constraint [pk_groupaccounts] Primary Key Clustered ([Gasid]) on [primary] Go
ALTER TABLE [dbo]. [GroupIPAccess] WITH NOCHECK ADD CONSTRAINT [PK_GroupIPAccess] PRIMARY KEY CLUSTERED ([GIpAid]) ON [PRIMARY] GOALTER TABLE [dbo]. [UserAccess] WITH NOCHECK ADD CONSTRAINT [PK_UserAccess] PRIMARY KEY CLUSTERED ([UAid ]) ON [PRIMARY] GO
Alter Table [DBO]. [Useeraccounts] with nocheck add constraint [pk_useraccounts] Primary Key Clustered ([ID]) on [primary] Go
Alter Table [DBO]. [Useripaccess] with nocheck add constraint [pk_useripaccess] Primary Key Clustered ([UIPAID]) on [primary] GO
ALTER TABLE [dbo]. [UserAccounts] WITH NOCHECK ADD CONSTRAINT [DF_UserAccounts_Disable] DEFAULT (0) FOR [Disable], CONSTRAINT [DF_UserAccounts_ChangePass] DEFAULT (1) FOR [ChangePass], CONSTRAINT [DF_UserAccounts_PassType] DEFAULT (0) FOR [PassType] , CONSTRAINT [DF_UserAccounts_ExpirationType] DEFAULT (1) FOR [ExpirationType], CONSTRAINT [DF_UserAccounts_RelPaths] DEFAULT (0) FOR [RelPaths], CONSTRAINT [DF_UserAccounts_MaxUsers] DEFAULT ((-1)) FOR [MaxUsers], CONSTRAINT [DF_UserAccounts_MaxUp] DEFAULT (0 ) FOR [MaxUp], CONSTRAINT [DF_UserAccounts_MaxDown] DEFAULT (0) FOR [MaxDown], CONSTRAINT [DF_UserAccounts_RatioUp] DEFAULT (1) FOR [RatioUp], CONSTRAINT [DF_UserAccounts_RatioDown] DEFAULT (1) FOR [RatioDown], CONSTRAINT [DF_UserAccounts_RatioCredit] DEFAULT (0) FOR [RatioCredit], CONSTRAINT [DF_UserAccounts_RatioType] DEFAULT (0) FOR [RatioType], CONSTRAINT [DF_UserAccounts_QuotaEnable] DEFAULT (1) FOR [QuotaEnable], CONSTRAINT [DF_UserAccounts_QuotaMax] DEFAULT (0) FOR [QuotaMax], CO NSTRAINT [DF_UserAccounts_QuotaCurrent] DEFAULT (0) FOR [QuotaCurrent], CONSTRAINT [DF_UserAccounts_Privilege] DEFAULT (0) FOR [Privilege], CONSTRAINT [DF_UserAccounts_LockHomeDir] DEFAULT (1) FOR [LockHomeDir], CONSTRAINT [IX_UserAccounts] UNIQUE NONCLUSTERED ([UserName]) ON [primary] GO
exec sp_addextendedproperty N'MS_Description ', N' directory permissions', N'user ', N'dbo', N'table ', N'UserAccounts', N'column', N'Access'GOexec sp_addextendedproperty N'MS_Description ', N 'Is it allowed to change the password', N'User ', N'TBO', N'TABLE ', N'USERACCOUNTS', N'COLUMN ', N'ChangePass'goexec sp_addextendedProperty N'MS_DEXTENDEDPROPERTY N'MS_DESCRIPTION', N 'account is disabled', N'User ', N'dbo', N'Table ', N'Useraccounts', N'Column', N'Disable'goexec sp_addextendedProperty N'MS_DESCRIPTION ', N' Expired Time ', N'User', N'dbo ', N'column', n'Expiration'goexec sp_addextendedproperty N'MS_DESCRIPTION ', N' Expansion ', N'User', N'dbo ', N'table', N 'Useeraccounts', N'ExpirationType'goexec sp_addextendedproperty N'MS_DEXTENDPROPERTY N'MS_DESCRIPTION ', N' User Group ', N'User', N'dbo ', N'TABLE', N'USERACCOUNTS ', N'COLUMN' , N'Groups'goexec sp_addextendedproperty N'MS_DESCRIPTION ', N' Home Directory ', N'TBO', N'table ', N'Useraccounts', N'Column', N'Homedir'goexec sp_addextendedProperty n 'Ms_description', n 'is locked in the main directory', N'User ', N'dbo', N'table ', N'Useraccounts', N'Column', N'Lockhom Edir'goexec sp_addextendedProperty N'MS_Description ', N' Maximum download rate ', n'user', n'dbo ', n'Table', n'usraccounts', n'column ', n'maxdown'goexec sp_addextendedproperty n'
MS_DESCRIPTION ', N' Maximum Upload Speed ', N'User', N'dbo ', N'Table', N'Useraccounts ', N'Column', N'Maxup'Goexec Sp_addextendedProperty N'MS_DESCRIPTION ', N' Max Land Use of users', N'User ', N'dbo', N'Table ', N'Useraccounts', N'Column', N'MaxUsers'goexec sp_addextendedProperty N'MS_DESCRIPTION ', N'Message file', N'User ' , N'dbo ', N'table', N'Column ', N'MessageFile'goexec sp_addextendedproperty N'MS_DEXTENDEDPROPERTY N'MS_DESBRIPTION', N'DD Class Type ', N'User', N'dbo ', N' Table ', N'Useraccounts', N'Column ', N'Passtype'goexec sp_addextendedproperty N'MS_DEXTENDPROPERTY N'MS_DESBRIPTION', N ', N'TEER', N'DBO ', N'TABLE', N'USERACCUNTS ', N'USERACCOUNTS', N 'Column', N'Password'goexec sp_addextendedproperty N'MS_DEXTENDPROPERTY N'MS_DESBRIPTION ', N' Management Permissions', N'TEER ', N'Useraccounts', N'column', N'Priviege ' GOexec sp_addextendedproperty N'MS_Description ', N' current quota ', N'user', N'dbo ', N'table', N'UserAccounts', N'column ', N'QuotaCurrent'GOexec sp_addextendedproperty N'MS_Description', N 'Enable Disk Quota', N'User ', N'dbo', N'Table ', N'Useraccounts', N'Column', N'quotaenable'goexec SP_ADDEXTENDEDPROPER Ty N'MS_Description ', N'User', N'dbo ', N'Table', N'Useraccounts ', N'Column', N'quoTamax'GoExec sp_addextendedProperty N'MS_DESCRIPTION ', N' Download ratio ', n'
User ', N'dbo', N'table ', N'Useraccounts', N'Column', N'ratiodown'goexec sp_addextendedproperty N'MS_DEXTENDEDPROPERTY N'MS_DESBRIPTION ', N'Upload ratio', N'User ', N'dbo', N'table ', N'Useraccounts', N'Column', N'ratioup 'Goexec sp_addextendedproperty N'MS_DEXTENDPROPERTY N'MS_DESBRIPTION', N 'User Name, N'TEBE', N'Useraccounts ', N'column', N'Username'go
ASP.NET implemented code: use system; use system.web.security; using system.configuration; using system.data; using system.data.sqlclient;
Namespace Host {///
Public String UserName; // User Name Public String Password; // Password Public Bool Disable; // Disable Account True: Disable Account False: Enable Account Public String Access; // Directory / IP Access Rule Public Byte Passtype; // Password Type 0: Rule Password 1: OTP S / KEY MD4 2: OTP S / Key MD5 Public Bool ChangePass; // Allows Change Password True: Allow FALSE: Prohibition of Public DateTime Expiration; // Expired Time PUBLIC BYTE ExpirationType; // Expired Type 1 : Delete 2: Disable Public STRING SKEY; PUBLIC BOOL Relpaths; // Requires Security Connection True: Requires False: No PUBLIC STRING HOMEDIR; // Main Directory Public String MessageFile; // Message File PUBLIC INT MAXUSERS; // Maximum User Public int maxup; // Maximum Upload rate public int maxdown; // Maximum download rate public Byte ratiotype; // ratio type public int RatiOUp; // Upload rate public int ratioDown; // download rate public float ratiocredit; // ratio trust Public Bool Quotaenable; // Allow quota True: Allow FALSE: Prohibition of public int quotamax; // Maximum quota public int quotacurrent; // Current quota public string groups; // User group public Byte privilege; // Administration 0: No permission 1: System Administrator 2: Group Administrator 3: Domain Administrator 4: Read-up administrator public bool lockHomedir; // Lock at the main directory TRUE: Lock FALSE: Do not lock
Public ftp () {// // Todo: Add constructor logic // username = "guest"; password = "guest"; disable = false; access = ""; passtype = 0; changePass = true; eviration = DATETIME.NOW.DATE; ExpirationType = 1; SKEY = ""; Relpaths = false; homedir = ""; messagefile = "; MAXUSERS = 1; MAXUP = 100 * 1024; // 100k maxdown = 100 * 1024; / / 100K ratiotype = 0; RatiOUp = 1; Ratiodown = 1; Ratiocredit = 0; quotaenable = true; quotamax = 10 * 1024 * 1024; // 10m quotacurrent = 0; groups = ""; privilege = 0; LockHomedir = true; Conhost = new sqlconnection (configurationSettings.appsettings ["constring"]); conhost.open ();
~ ftp () {conhost.close ();
public void Add () {// add the account SqlCommand cmdAdd = new SqlCommand ( "insert into UserAccounts (UserName, Password, Disable, Access, ChangePass, PassType, Expiration, ExpirationType, SKey, RelPaths, HomeDir, MessageFile, MaxUsers, MaxUp, MaxDown , RatioUp, RatioDown, RatioCredit, RatioType, QuotaEnable, QuotaMax, QuotaCurrent, Groups, Privilege, LockHomeDir) values (@ UserName, @ Password, @ Disable, @ Access, @ changePass, @ PassType, @ Expiration, @ ExpirationType, @ SKey, @ RelPaths, @ HomeDir, @ MessageFile, @ MaxUsers, @ MaxUp, @ MaxDown, @ RatioUp, @ RatioDown, @ RatioCredit, @ RatioType, @ QuotaEnable, @ QuotaMax, @ QuotaCurrent, @ Groups, @ Privilege, @ LockHomeDir) ", CONHOST);
Cmdadd.Parameters.Add ("@usename"; cmdadd.parameters.add ("@password", pass ()); cmdadd.parameters.add ("@disable", disable); cmdadd.parameters.add ( "@Access", access); cmdadd.parameters.add ("@ChangePass", ChangePass; cmdadd.Parameters.Add ("@Passtype"; cmdadd.parameters.add ("@Expiration", expression; cmdadd.parameters.add ("@ExpirationType"; cmdadd.parameters.add ("@skey", skey); cmdadd.parameters.add ("@relpaths", relpaths; cmdadd.Parameters.Add ("@ Homedir ", Homedir); cmdadd.parameters.add (" @MASSAGEFILE ", messagefile; cmdadd.parameters.add (" @maxusers "; cmdadd.parameters.add (" @maxup ", maxup); cmdadd. Parameters.add ("@maxdown", maxdown; cmdadd.parameters.add ("@ratious", ratioup; cmdadd.parameters.add ("@ratiodown", ratiodown; cmdadd.parameters.add ("@ratiocredit" , Ratiocredit; cmdadd.Parameters.Add ("@ratiotype", ratiotype); cmdadd.parameters.add ("@quotaenable", quo TAENABLE); cmdadd.parameters.add ("@quotamax", quotamax); cmdadd.parameters.add ("@quotacurrent", quotacurrent; cmdadd.parameters.add ("@groups", groups); cmdadd.parameters.add ("@Privilege"; cmdadd.parameters.add ("@lockhomedir", lockHomedir); //cmdadd.parameters.add ("@",); cmdadd.executenon query ()
Public string pass () {// Password encryption Random RNM = new random (); char A = (char) (RNM.Next (97, 123)); char b = (char) (RNM.Next (97, 123) ); String password = string.format ("{0} {1} {2}", a, b, password); password = formsauthentication.hashpasswordforstoringInfigfile (Password, "MD5"); password = string.format ("{0 } {1} {2} ", A, B, Password.toupper ()); Return Password;} Public Bool ModifyPass (String Oldpass, String Newpass) {// Modify Password Return true;}}}}