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个内测版本,完 ...
随机推荐
- C++primer第三章标准库类型
除第二章介绍的基本数据类型外,C++ 还定义了一个内容丰富的抽象数据类型标准库. 本章将介绍标准库中的 vector.string 和 bitset 类型. string 类型支持长度可变的字符串 v ...
- JPA 系列教程15-继承-一个表-SINGLE_TABLE
继承映射策略 一个类继承结构一个表的策略,最终只生成一个表,这是继承映射的默认策略. 举例 如果实体类Teacher继承实体类Person,实体类Student也继承自实体Person,那么只会映射成 ...
- toggle的使用心得
点击同一个标签可以实现不同效果 或者几个效果 以前一般都是if 判断的 逻辑还有判断比较繁琐 看啦手册后 发现这个功能可以不用判断的自动循环点击事件 比以前的简单好用 主要用法:$("td& ...
- php 提交表单
滴答…滴答…的雨,欢迎大家光临我的博客. 学习是快乐的,教育是枯燥的. 博客园 首页 博问 闪存 联系 订阅 管理 随笔-58 评论-2017 文章-5 trackba ...
- 项目管理实践【四】Bug跟踪管理【Bug Trace and Management】
首先,向大家说一声抱歉,这篇文章耽误了这么久才和大家见面.至于Bug的跟踪和管理的必要性和好处,我就不在这里说了,下面介绍几款Bug跟踪和管理的软件. 一.BugNET BugNET是一个非常优秀的开 ...
- 安装gensim
安装了一天的gensim,其中因为版本不一致等等各种问题纠结了好久,现记录如下: 正确安装方式: 1. 安装python2.7 2. 下载Python Extension Packages对应版本的n ...
- JQuery简介及HelloWorld
一.JQuery是什么: -JQuery是一个JavaScript框架. 二.JQuery的优点: –轻量级 –强大的选择器 –出色的 DOM 操作的封装 –可靠的事件处理机制 –完善的 Ajax – ...
- Flask -- 会话
会话session 在不同请求间存储特定用户的信息.它是在 Cookies 的基础上实现的,并且对 Cookies 进行密钥签名.这意味着用户可以查看你 Cookie 的内容,但却不能修改它,除非用户 ...
- 创建简单动画(一) --- 常规hud
先说下当前我为处理动画的思路: (新手上路, 老司机轻喷,如果有更好的实现方法请大神指教 感恩戴德) #1. 分析动画构成 #2. 如果是位移动画则考虑使用BasicAnimation或者Keyfra ...
- 【2】docker 与UFW
ufw是一个主机端的iptables类防火墙配置工具. 1.查看ufw的状态:ufw status 2.如果使用UFW,需要对其进行修改才能让DOCKER工作.docker使用一个网桥来管理容器中的网 ...