用程序来自动建立FTP帐号(serv-u的odbc设置)

步骤:
1、建立数据库(可以用任何数据库SQL SERVER,ACCESS均可)
2、建立DNS
3、安装Serv-U
4、建立域
5、完成了。呵呵~!
serv-u build 6.0.0.1版本



        ★ Serv-U FTP Server 6.0.0.1 final



非常好的FTP服务器软件,它设置简单,功能强大,性能稳定。
你现在就可以建立你自己的FTP服务器了。



汉化说明:



1、请先安装原英文软件。
2、退出 FTP Serv-U 应用程序!包括系统栏图标!
3、解压缩后运行汉化包,填入你的安装目录进行汉化。
4、汉化包中另带有企业版的破解补丁:
   Serv-U6001cr.exe,如需要,大家可自行破解,破解前请中
   止系统中的ServUDaemon.exe进程,或中止Serv-U 的服务。
   然后将破解文件复制到 Serv-U 安装目录进行破解。破解后
   为永不过期的“企业版”,如果用了以前的破解版本,可能
   会报告说你盗用了注册码,这时请在“本地服务器--许可”
   中选择“删除密钥”即可。
5、有些原英文版用户汉化后可能会导致设置丢失,这可能是由
   于汉化的资源与英文版不同所致,只能请大家重新设置一下
   了。以前即用汉化版则无此问题。
6、如果以前使用过我的汉化补丁,请将原目录下旧的“汉化说
   明.txt”文件删除后再使用新的汉化补丁。



建立数据库的SQL:



/****** Object:  Database host    Script Date: 2004-12-24 13:16:31 ******/
IF EXISTS (Select name FROM master.dbo.sysdatabases Where name = Nhost)
Drop DATABASE [host]
GO



Create DATABASE [host]  ON (NAME = NHost_Data, FILENAME = ND:\wwwroot\host\database\host.mdf , SIZE = 2, FILEGROWTH = 10%) LOG ON (NAME = NHost_Log, FILENAME = ND:\wwwroot\host\database\host_log.ldf , SIZE = 9, FILEGROWTH = 10%)
COLLATE Chinese_PRC_CI_AS
GO



exec sp_dboption Nhost, Nautoclose, Nfalse
GO



exec sp_dboption Nhost, Nbulkcopy, Nfalse
GO



exec sp_dboption Nhost, Ntrunc. log, Nfalse
GO



exec sp_dboption Nhost, Ntorn page detection, Ntrue
GO



exec sp_dboption Nhost, Nread only, Nfalse
GO



exec sp_dboption Nhost, Ndbo use, Nfalse
GO



exec sp_dboption Nhost, Nsingle, Nfalse
GO



exec sp_dboption Nhost, Nautoshrink, Nfalse
GO



exec sp_dboption Nhost, NANSI null default, Nfalse
GO



exec sp_dboption Nhost, Nrecursive triggers, Nfalse
GO



exec sp_dboption Nhost, NANSI nulls, Nfalse
GO



exec sp_dboption Nhost, Nconcat null yields null, Nfalse
GO



exec sp_dboption Nhost, Ncursor close on commit, Nfalse
GO



exec sp_dboption Nhost, Ndefault to local cursor, Nfalse
GO



exec sp_dboption Nhost, Nquoted identifier, Nfalse
GO



exec sp_dboption Nhost, NANSI warnings, Nfalse
GO



exec sp_dboption Nhost, Nauto create statistics, Ntrue
GO



exec sp_dboption Nhost, Nauto update statistics, Ntrue
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, NIsUserTable) = 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, NIsUserTable) = 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, NIsUserTable) = 1)
drop table [dbo].[GroupIPAccess]
GO



/****** Object:  Table [dbo].[UserAccess]    Script Date: 2004-12-24 13:16:31 ******/
if exists (select * from dbo.sysobjects where id = object_id(N[dbo].[UserAccess]) and OBJECTPROPERTY(id, NIsUserTable) = 1)
drop table [dbo].[UserAccess]
GO



/****** Object:  Table [dbo].[UserAccounts]    Script Date: 2004-12-24 13:16:31 ******/
if exists (select * from dbo.sysobjects where id = object_id(N[dbo].[UserAccounts]) and OBJECTPROPERTY(id, NIsUserTable) = 1)
drop table [dbo].[UserAccounts]
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, NIsUserTable) = 1)
drop table [dbo].[UserIPAccess]
GO



/****** Object:  Table [dbo].[GroupAccess]    Script Date: 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].[UserAccess]    Script Date: 2004-12-24 13:16:37 ******/
Create TABLE [dbo].[UserAccess] (
[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].[UserAccounts]    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] NOT 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] NOT 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 ,
[Groups] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[Privilege] [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 ADD
CONSTRAINT [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]
GO



Alter TABLE [dbo].[UserAccess] WITH NOCHECK ADD
CONSTRAINT [PK_UserAccess] PRIMARY KEY  CLUSTERED
(
  [UAid]
)  ON [PRIMARY]
GO



Alter TABLE [dbo].[UserAccounts] 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],
CONSTRAINT [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 NMS_Description, N目录权限, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NAccess
GO
exec sp_addextendedproperty NMS_Description, N是否允许更改密码, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NChangePass
GO
exec sp_addextendedproperty NMS_Description, N帐号是否禁用, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NDisable
GO
exec sp_addextendedproperty NMS_Description, N过期时间, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NExpiration
GO
exec sp_addextendedproperty NMS_Description, N过期类型, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NExpirationType
GO
exec sp_addextendedproperty NMS_Description, N用户组, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NGroups
GO
exec sp_addextendedproperty NMS_Description, N主目录, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NHomeDir
GO
exec sp_addextendedproperty NMS_Description, N是否锁定在主目录, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NLockHomeDir
GO
exec sp_addextendedproperty NMS_Description, N最大下载速率, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NMaxDown
GO
exec sp_addextendedproperty NMS_Description, N最大上传速率, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NMaxUp
GO
exec sp_addextendedproperty NMS_Description, N最大登陆用户数, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NMaxUsers
GO
exec sp_addextendedproperty NMS_Description, N消息文件, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NMessageFile
GO
exec sp_addextendedproperty NMS_Description, N密码类型, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NPassType
GO
exec sp_addextendedproperty NMS_Description, N密码, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NPassword
GO
exec sp_addextendedproperty NMS_Description, N管理权限, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NPrivilege
GO
exec sp_addextendedproperty NMS_Description, N当前配额, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NQuotaCurrent
GO
exec sp_addextendedproperty NMS_Description, N启用磁盘配额, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NQuotaEnable
GO
exec sp_addextendedproperty NMS_Description, N最大配额, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NQuotaMax
GO
exec sp_addextendedproperty NMS_Description, N下载比率, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NRatioDown
GO
exec sp_addextendedproperty NMS_Description, N上传比率, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NRatioUp
GO
exec sp_addextendedproperty NMS_Description, N用户名, Nuser, Ndbo, Ntable, NUserAccounts, Ncolumn, NUserName




GO


ftp.cs代码:

using System;
using System.Web.Security;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace host
{
///
/// ftp 的摘要说明。
///

public class ftp
{
  private SqlConnection conHost;


  public string UserName;//用户名
  public string Password;//密码
  public bool Disable;//禁用帐号 true:禁用帐号 false:启用帐号
  public string Access;//目录/IP访问规则
  public byte PassType;//密码类型 0:规则密码 1:OTP S/KEY MD4 2:OTP S/KEY MD5
  public bool ChangePass;//允许修改密码 true:允许 false:禁止
  public DateTime Expiration;//过期时间
  public byte ExpirationType;//过期类型 1:删除 2:禁用
  public string SKey;
  public bool RelPaths;//需要安全连接 true:需要 false:不需要
  public string HomeDir;//主目录
  public string MessageFile;//消息文件
  public int MaxUsers;//最大用户数
  public int MaxUp;//最大上传速率
  public int MaxDown;//最大下载速率
  public byte RatioType;//比率类型
  public int RatioUp;//上传率
  public int RatioDown;//下载率
  public float RatioCredit;//比率信任
  public bool QuotaEnable;//允许配额 true:允许 false:禁止
  public int QuotaMax;//最大配额
  public int QuotaCurrent;//当前配额
  public string Groups;//用户组
  public byte Privilege;//管理权限 0:没有权限 1:系统管理员 2:组管理员 3:域管理员 4:只读管理员
  public bool LockHomeDir;//锁定于主目录 true:锁定 false:不锁定

  public ftp()
  {
   //
   // TOD 在此处添加构造函数逻辑
   //
   UserName = "guest";
   Password = "guest";
   Disable = false;
   Access = "";
   PassType = 0;
   ChangePass = true;
   Expiration = 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()
  {
   //添加帐号
   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( "@UserName", UserName );
   cmdAdd.Parameters.Add( "@Password", pass() );
   cmdAdd.Parameters.Add( "@Disable", Disable );
   cmdAdd.Parameters.Add( "@Access", Access );
   cmdAdd.Parameters.Add( "@ChangePass", ChangePass );
   cmdAdd.Parameters.Add( "@PassType", PassType );
   cmdAdd.Parameters.Add( "@Expiration", Expiration );
   cmdAdd.Parameters.Add( "@ExpirationType", ExpirationType );
   cmdAdd.Parameters.Add( "@SKey", SKey );
   cmdAdd.Parameters.Add( "@RelPaths", RelPaths );
   cmdAdd.Parameters.Add( "@HomeDir", HomeDir );
   cmdAdd.Parameters.Add( "@MessageFile", MessageFile );
   cmdAdd.Parameters.Add( "@MaxUsers", MaxUsers );
   cmdAdd.Parameters.Add( "@MaxUp", MaxUp );
   cmdAdd.Parameters.Add( "@MaxDown", MaxDown );
   cmdAdd.Parameters.Add( "@RatioUp", RatioUp );
   cmdAdd.Parameters.Add( "@RatioDown", RatioDown );
   cmdAdd.Parameters.Add( "@RatioCredit", RatioCredit );
   cmdAdd.Parameters.Add( "@RatioType", RatioType );
   cmdAdd.Parameters.Add( "@QuotaEnable", QuotaEnable );
   cmdAdd.Parameters.Add( "@QuotaMax", QuotaMax );
   cmdAdd.Parameters.Add( "@QuotaCurrent", QuotaCurrent );
   cmdAdd.Parameters.Add( "@Groups", Groups );
   cmdAdd.Parameters.Add( "@Privilege", Privilege );
   cmdAdd.Parameters.Add( "@LockHomeDir", LockHomeDir );
   //cmdAdd.Parameters.Add( "@",  );

   cmdAdd.ExecuteNonQuery();
  }

  public string pass()
  {
   //密码加密
   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.HashPasswordForStoringInConfigFile( password, "md5" );
   password = string.Format( "{0}{1}{2}", a, b, password.ToUpper() );
   return password;
  }

  public bool modifypass( string oldpass, string newpass )
  {
   //修改密码
   return true;
  }
}
}


例子WebForm1.aspx.cs:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;

namespace host
{
///
/// WebForm1 的摘要说明。
///

public class WebForm1 : System.Web.UI.Page
{
  protected System.Web.UI.WebControls.Label Label1;

  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   ftp test = new ftp();
   test.UserName = "t";
   test.Password = "t";
   test.Access = "D:\\wwwroot\\test|RWAMLCDP";
   test.HomeDir = "D:\\wwwroot\\test";
   test.Groups = "test";
   test.Add();
   Label1.Text = "成功";
  }

  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  ///
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  ///

  private void InitializeComponent()
  {    
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion
}
}
相关图片:
建立DNS:

2、建立域:



3、配制Serv-U:



上一篇: 学校信息管理系统开发规划和实施项目
下一篇: mssql2000中char类型和varchar类型的区别
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: 3490
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 300 字 | UBB代码 开启 | [img]标签 关闭