FTP 7.5 自定义扩展功能
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
参考: http://gzzhang.blog.51cto.com/5312382/1125092
随着IIS7的发布,IIS自带的FTP终于能自定义验证了.
目前知道的自定义接口共三个 自定义校验, 自定义主目录,自定义日志
分别是 Microsoft.Web.FtpServer的
步骤:
1. 首先创建 C#类库 (要选择 2.0 / 3.5 框架) ,有说 .NET 4.0不支持 ,但是这个没做验证,需要后期继续测试
2. 然后增加生成事件 后期处理 VS2012版本:
3. 添加签名(无密码)
4. 代码
namespace FtpHomeDirectory
{
public class FtpHomeDirDemo : BaseProvider,
IFtpHomeDirectoryProvider
{
string IFtpHomeDirectoryProvider.GetUserHomeDirectoryData(
string sessionId,
string siteName,
string userName)
{
// Note: You would add your own custom logic here.
// Return the user's home directory based on their user name.
string homedir = @"D:\Ftptest\" + userName;
VASLog.WriteLog_day(@"d:\Ftptest", "ftplog", "siteName: " + siteName + " 用户想要得到的目录是:"+homedir+" ;");
return homedir;
}
}
}
密码验证
namespace FtpAuthenticationDemo
{
public class FtpAuthDemo : BaseProvider,
IFtpAuthenticationProvider,
IFtpRoleProvider
{
//void IFtpLogProvider.Log(FtpLogEntry loggingParameters)
//{
// // Note: You would add your own custom logic here.
// // Open the log file for output.
// using (StreamWriter sw =
// new StreamWriter(@"C:\inetpub\logs\LogFiles\FTPSVC8\myftplog.log", true))
// {
// // Retrieve the current date and time for the log entry.
// DateTime dt = DateTime.Now;
// // Retrieve the user name.
// string un = loggingParameters.UserName;
// // Write the log entry to the log file.
// sw.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
// dt.ToShortDateString(),
// dt.ToLongTimeString(),
// loggingParameters.RemoteIPAddress,
// (un.Length == 0) ? "-" : un,
// loggingParameters.Command,
// loggingParameters.SessionId);
// }
//}
bool IFtpAuthenticationProvider.AuthenticateUser(
string sessionId,
string siteName,
string userName,
string userPassword,
out string canonicalUserName)
{
// Note: You would add your own custom logic here.
canonicalUserName = userName;
//string strUserName = "test";
//string strPassword = "123";
VASLog.WriteLog_day(@"d:\Ftptest", "ftplog", canonicalUserName + " siteName: " +siteName +" 校验总是可以成功的;");
return true;
// Verify that the user name and password are valid.
// Note: In this example, the user name is case-insensitive
// and the password is case-sensitive.
//if (((userName.Equals(strUserName,
// StringComparison.OrdinalIgnoreCase)) == true) &&
// userPassword == strPassword)
//{
// return true;
//}
//else
//{
// return true;
//}
}
bool IFtpRoleProvider.IsUserInRole(
string sessionId,
string siteName,
string userName,
string userRole)
{
// Note: You would add your own custom logic here.
string strUserName = "MyUser";
string strRoleName = "MyRole";
//VASLog.WriteLog_day(@"d:\Ftptest", "ftplog", "IsUserInRole");
return true;
// Verify that the user name and role name are valid.
// Note: In this example, both the user name and
// the role name are case-insensitive.
if (((userName.Equals(strUserName,
StringComparison.OrdinalIgnoreCase)) == true) &&
((userRole.Equals(strRoleName,
StringComparison.OrdinalIgnoreCase)) == true))
{
return true;
}
else
{
return false;
}
}
//string IFtpHomeDirectoryProvider.GetUserHomeDirectoryData(
// string sessionId,
// string siteName,
// string userName)
//{
// VASLog.WriteLog_day(@"d:\Ftptest", "ftplog", "GetUserHomeDirectoryData");
// // Note: You would add your own custom logic here.
// // Return the user's home directory based on their user name.
// return @"d:\FtpTest\" + userName;
//}
}
}
尽量两个分开吧
生成后,在输出里可以看到
然后要做的,就是配置IIS了
1. 在IIS的根基目录中,配置 FTP身份验证,禁用其他选项,在右侧自定义提供程序中,注册刚才的DLL,
2. FTP规则里,允许所有账户
3. 同样的注册主目录DLL
4. 跟密码验证不同,主目录的DLL,还需要设置两个地方
cd %systemroot%/system32/Inetsrv/
AppCmd set site "YourFTP" /+ftpServer.customFeatures.providers.[name='FtpHomeDirectoryDemo',enabled='true']
AppCmd set site "YourFTP" /ftpServer.userIsolation.mode:Custom
注意: 第一个appcmd 里面的 name = ftphomedirectorydemo 这个name,是在上面注册在IIS里的名称,跟DLL的空间类名没关系,一定要注意
这个一定要执行,不然,修改了数据库的密码之后,依然旧密码要保留一点时间,但是原因是什么,不理解.
现象,好像是登录时,直接就过了验证,进入到了目录获取的地方去了.
这样设置之后,才能启用主目录的设置
5. 在FTP用户隔离里,选择 下面的 用户名目录(禁用全局虚拟目录) ,这个用不用,还不知道,有待测试! 原理上考虑,这个其实没作用了,毕竟主目录在DLL里,已经可以定义了
这里应该在FTP用户隔离 属性设置中,改成自定义(简单测试了下,好像是这样)
这里有个好玩的,如果继续设置LocalUser虚拟目录(物理目录也可以的),指向了同名FTP用户名的文件夹下面,
这时候设置IP限制之类的,也是生效的,这样子,可以针对单独的FTP做限制了。
FTP 7.5 自定义扩展功能的更多相关文章
- Java 自定义FTP连接池
转自:https://blog.csdn.net/eakom/article/details/79038590 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn ...
- 虚拟机中使用centos7搭建ftp服务器
应用场景 本地windows作为客户端,虚拟机CentOS7作为服务器端,搭建FTP服务器,本地访问虚拟机实现文件的上传下载.如何在虚拟机安装centos7就不在赘述. 1.在centos7上安装vs ...
- FTP和TCP的文件传输效率对比测试分析
前言 最近因项目需要,需要把一定数量的中等文件从开发板上传到电脑上,分别选择了FTP和TCP自定义协议两种方式进行传输,进行了简单的对比测试,故做如下记录. 测试环境 开发板:Linux,ARMv7 ...
- 一文看懂web服务器、应用服务器、web容器、反向代理服务器区别与联系
我们知道,不同肤色的人外貌差别很大,而双胞胎的辨识很难.有意思的是Web服务器/Web容器/Web应用程序服务器/反向代理有点像四胞胎,在网络上经常一起出现.本文将带读者对这四个相似概念如何区分. 1 ...
- Web服务器、应用服务器、Web容器、反向代理服务器区别与联系
作者: 帅虫哥 出处:www.cnblogs.com/vipyoumay/p/7455431.html(点击尾部阅读原文前往) 我们知道,不同肤色的人外貌差别很大,而双胞胎的辨识很难.有意思的是Web ...
- [转帖]一文看懂web服务器、应用服务器、web容器、反向代理服务器区别与联系
一文看懂web服务器.应用服务器.web容器.反向代理服务器区别与联系 https://www.cnblogs.com/vipyoumay/p/7455431.html 我们知道,不同肤色的人外貌差别 ...
- Membership三步曲之入门篇 - Membership基础示例
Membership 三步曲之入门篇 - Membership基础示例 Membership三步曲之入门篇 - Membership基础示例 Membership三步曲之进阶篇 - 深入剖析Pro ...
- Android Weekly Notes Issue #232
Android Weekly Issue #232 November 20th, 2016 Android Weekly Issue #232 本期内容包括: Kotlin的优势讨论; MVVM模式结 ...
- 开源免费的HTML5游戏引擎
青瓷引擎的成长 青瓷引擎自2015年4月项目启动开始,7月首次亮相2015年ChinaJoy,便得到业界的极大关注,随后开启限量测试,收到数百个开发者团队的试用申请及反馈,期间经历了18个内测版本,完 ...
随机推荐
- 关于erlang的binary
引自:http://cryolite.iteye.com/blog/1547252 1. binary数据是可以在不同进程间共享的 当然这些进程都在同一Erlang节点上. 这与普通term不同,后者 ...
- 万航单位换算器 V1.0 绿色版
软件名称: 万航单位换算器软件语言: 简体中文授权方式: 免费软件运行环境: Win 32位/64位软件大小: 347KB图片预览: 软件简介:万航单位换算器是一个可以随意转换单位的绿色软件,这个软件 ...
- java实现树型结构样式
import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; public class Root exten ...
- win8下使用eclipse进行hadoop2.6.2开发
最近在win平台下使用eclipse Mars做在远程linux上的hadoop2.6开发,出现很多问题,让人心力交瘁,在经过不懈努力后,终于解决了,让人欢欣雀跃. 1.安装JDK 在做hadoop2 ...
- SpringMvc处理post请求乱码的filter
<filter> <filter-name>encodingFilter</filter-name> <filter-clas ...
- MFC中MessageBeep与sndPlaySound播放声音函数使用
MessageBeep(0x00000000L); //用来播放系统默认音频文件,如0x00000000L为系统提示音,具体音频对应规则,请参照MSDN. sndPlaySound函数用来播放指 ...
- hdu_5777_domino(贪心)
题目链接:hdu_5777_domino 题意: 小白在玩一个游戏.桌子上有n张多米诺骨牌排成一列.它有k次机会,每次可以选一个还没有倒的骨牌,向左或者向右推倒.每个骨 牌倒下的时候,若碰到了未倒下的 ...
- 缓存2 动态缓存 memcached
01准备下载好memcached.exe文件-->放置c:\memcached目录中02准备下载好php_memcache.dll文件-->放置php\ext扩展目录中03配置 php.i ...
- shell脚本学习(一)
1.hbg@HWM:/$ su root密码:root@HWM:/# $表示普通用户, #表示管理员用户root.root是linux系统中权限最高的用户. 2.在bash中,每个变量的值都是字符串. ...
- Python之路:爬虫之urllib库的基本使用和高级使用
关于爬虫自己一直在看,所以时间太慢,这才第二更,有等不及的小伙伴可以慢慢的品尝了,在看下面的之前,建议先把上一章看一下.以下是关于python的Urllib的基础和高级用法. 1.如何扒下一个网站,用 ...