首页 > 开发 > 综合 > 正文

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

2024-07-21 02:21:22
字体:
来源:转载
供稿:网友

步骤:
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 = 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_as
go



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'ansi null default', n'false'
go



exec sp_dboption n'host', n'recursive triggers', n'false'
go



exec sp_dboption n'host', n'ansi 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'
go



exec sp_dboption n'host', n'ansi warnings', n'false'
go



exec sp_dboption n'host', n'auto create statistics', 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'isusertable') = 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'isusertable') = 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'isusertable') = 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, n'isusertable') = 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, n'isusertable') = 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, n'isusertable') = 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 n'ms_description', n'目录权限', n'user', n'dbo', n'table', n'useraccounts', n'column', n'access'
go
exec sp_addextendedproperty n'ms_description', n'是否允许更改密码', n'user', n'dbo', n'table', n'useraccounts', n'column', n'changepass'
go
exec sp_addextendedproperty n'ms_description', n'帐号是否禁用', n'user', n'dbo', n'table', n'useraccounts', n'column', n'disable'
go
exec sp_addextendedproperty n'ms_description', n'过期时间', n'user', n'dbo', n'table', n'useraccounts', n'column', n'expiration'
go
exec sp_addextendedproperty n'ms_description', n'过期类型', n'user', n'dbo', n'table', n'useraccounts', n'column', n'expirationtype'
go
exec sp_addextendedproperty n'ms_description', n'用户组', n'user', n'dbo', n'table', n'useraccounts', n'column', n'groups'
go
exec sp_addextendedproperty n'ms_description', n'主目录', n'user', n'dbo', n'table', n'useraccounts', n'column', n'homedir'
go
exec sp_addextendedproperty n'ms_description', n'是否锁定在主目录', n'user', n'dbo', n'table', n'useraccounts', n'column', n'lockhomedir'
go
exec sp_addextendedproperty n'ms_description', n'最大下载速率', n'user', n'dbo', n'table', n'useraccounts', n'column', n'maxdown'
go
exec sp_addextendedproperty n'ms_description', n'最大上传速率', n'user', n'dbo', n'table', n'useraccounts', n'column', n'maxup'
go
exec sp_addextendedproperty n'ms_description', n'最大登陆用户数', n'user', n'dbo', n'table', n'useraccounts', n'column', n'maxusers'
go
exec sp_addextendedproperty n'ms_description', n'消息文件', n'user', n'dbo', n'table', n'useraccounts', n'column', n'messagefile'
go
exec sp_addextendedproperty n'ms_description', n'密码类型', n'user', n'dbo', n'table', n'useraccounts', n'column', n'passtype'
go
exec sp_addextendedproperty n'ms_description', n'密码', n'user', n'dbo', n'table', n'useraccounts', n'column', n'password'
go
exec sp_addextendedproperty n'ms_description', n'管理权限', n'user', n'dbo', n'table', n'useraccounts', n'column', n'privilege'
go
exec sp_addextendedproperty n'ms_description', n'当前配额', n'user', n'dbo', n'table', n'useraccounts', n'column', n'quotacurrent'
go
exec sp_addextendedproperty n'ms_description', n'启用磁盘配额', n'user', n'dbo', n'table', n'useraccounts', n'column', n'quotaenable'
go
exec sp_addextendedproperty n'ms_description', n'最大配额', n'user', n'dbo', n'table', n'useraccounts', n'column', n'quotamax'
go
exec sp_addextendedproperty n'ms_description', n'下载比率', n'user', n'dbo', n'table', n'useraccounts', n'column', n'ratiodown'
go
exec sp_addextendedproperty n'ms_description', n'上传比率', n'user', n'dbo', n'table', n'useraccounts', n'column', n'ratioup'
go
exec sp_addextendedproperty n'ms_description', n'用户名', n'user', n'dbo', n'table', n'useraccounts', n'column', n'username'




go


ftp.cs代码:

using system;
using system.web.security;
using system.configuration;
using system.data;
using system.data.sqlclient;

namespace host
{
/// <summary>
/// ftp 的摘要说明。
/// </summary>
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
{
/// <summary>
/// webform1 的摘要说明。
/// </summary>
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);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void initializecomponent()
{
this.load += new system.eventhandler(this.page_load);

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

2、建立域:

3、配制serv-u:



发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表