欢迎光临
我们一直在努力

用程序来自动建立FTP帐号(serv-u的odbc设置)-.NET教程,Web Service开发

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

步骤:

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

{

/// <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:

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用程序来自动建立FTP帐号(serv-u的odbc设置)-.NET教程,Web Service开发
分享到: 更多 (0)