Serv-U的确比iis6.0自带的那个ftp强大很多,感觉确实不错,不管从性能还是功能,不过能在线管理就更方便了,在网上找了一些在线更改Serv-U的密码的教程,但是多数写的都不明白,有些还是用ASP写的,呵呵,我的ASP不好,再说学校的学弟学妹也是用.NET的比较多,是吧.....呵呵,废话少说,教程开始 本教程纯属原创,如有雷同,均为盗版 ------------------------------------------------------------------------------------------------ 首先,大家要了解Serv-U的工作模式,它可以将帐户信息保存在MySql和SQL Server 等数据库上,但是前提要建立ODBC数据源,我想对于软件班想当程序员的同学们,这个不成问题吧,呵呵 ======================================================= 如何设置Serv-U的ODBC功能 ======================================================= 如何用Serv-U连接ODBC| 1、可以在 FTP所在服务器安装一个 SQL Server 数据库,也可以使用论坛自带的数据库。建议在 FTP所在服务器安装一个全新的 SQL Server。 2、配置DSN。到Windows的管理工具,数据源(ODBC)。在用户 DSN,点击“添加”,选择"SQL Server",然后点击完成。 在接下来出现的对话框中,Data Source Name(名称) 填写任意一个DSN名字,比如Serv-U。下面填写储存FTP信息的SQL Server 数据库信息,包括主机名,用户名密码等。OK后进行下一步。 3、打开Serv-U管理器,新建一个域名,在域名添加向导的第4步Domain type中选择Store in ODBC database。 4、打开Serv-U安装目录下的ServUDaemon.ini文件,做以下*作: (1)用下面的代码覆盖原来的ODBCSource、ODBCTables、ODBCColumns ------------------------------------------ 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
------------------------------------------
用户密码的加密方法可以在Serv-U官方网站的知识库查到 http://rhinosoft.com/KBArticle.asp?RefNo=1177&prod=su Manually Entering Encrypted Passwords into the ServUDaemon.ini File To generate an encrypted password, first two random characters (the salt - in the range a..z, A..Z) are added to the beginning of the clear-text password. This is then hashed using MD5 and the resulting hash is hex-encoded. The result of this is written as plain-text starting with the 2 salt characters followed by the hex-encoded hash. For a user account in the .ini file, this will look like: Password=cb644FB1F31184F8D3D169B54B3D46AB1A The salt is the string "cb", the MD5 hash is "644FB1F31184F8D3D169B54B3D46AB1A". When verifying a users password, Serv-U will do the same. It parses the salt from the users stored password (ie. "cb" in this case), prepends it the password the user sent to it by the client, MD5 hashes it, and compares the result with the stored hash. If the values are equal, then the entered password is correct.
------------------------------------------------------------------------------------------------
简单的解释一下,例如有个用户的密码是 123456其MD5值是 E10ADC3949BA59ABBE56E057F20F883E Serv-U的加密方式是 产生两位随机的从 a...z 的字母,例如 ab 将 ab放到密码的前面,也就是ab123456,在将其用MD5加密,也就是872BE7378D2E5C4B747F2547144C6DC5 再把ab加到ab123456的MD5值的前面,也就是 ab872BE7378D2E5C4B747F2547144C6DC5 这个就是Serv-U最终的密码了,呵呵 了解了原理,下面就用ASP.NET实现这个效果
------------------------------------------------------------------------------------------------
protected void Page_Load(object sender, EventArgs e) { string ran = this.rdom() //定义变量ran存储rdom()函数返回的随机数 //在我的电脑上产生的随机字符是 zk string pass = "123456" //要加密的密码 123456 Response.Write("随机字符是:" + ran + "\t") Response.Write("生成的密码是:" + md5_pass(ran, pass)) } protected string rdom() //定义一个产生两位从a..z的函数 { string strran = "" //定义字符串 Random ran = new Random() strran += Convert.ToChar(ran.Next(26) + a ).ToString() + Convert.ToChar(ran.Next(26) + a ).ToString() //将随机产生的两个字母相连.例如:a+b=ab return strran } protected string md5_pass(string rdoms, string md5) //定义一个加密的函数,加密结果返回 { string strmd5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile ( rdoms + md5 , "MD5") //把两位随机字母和md5连接并再次进行MD5加密 return rdoms + strmd5 //将两位随机字母与加密后的MD5值再次连接 }
------------------------------------------------------------------------------------------------
输出结果
随机字符是:zk 生成的密码:zkFE7CE0A9173FF8DFEBBC87EC928D98C4
------------------------------------------------------------------------------------------------ |