2016-04-25 15 views
0

C#を使用してIIS FTP 8のカスタム認証者を作成しました。 IISは、私のDLLを使用するように、私は正しく、カスタム機能ハンドラを設定しているが、私は常に取得ログインしようとすると:IIS FTP 8カスタム認証許可ルールがアクセスを拒否しました

Response: 331 Password required 
Command: PASS ******** 
Response: 530-User cannot log in, home directory inaccessible. 
Response: Win32 error: No such interface supported 
Response: Error details: Authorization rules denied the access. 
Response: 530 End 

私はフォルダのアクセス許可を除外しましたかなり確信している - それはのように大きく開いていますそれができるように。だから私はメッセージを理解する - それは私には何も認可ルールがないと言っている。しかし、カスタムオーセンティケータに1つを追加する方法はないようです。 IISマネージャーのUIは、通常の設定機能を無効にして、そこに追加することはできません。

私はアプリcmdを試してみました:なし、成功と役割(ゲスト、*、など)のバリエーションを持つ

appcmd.exe set config "mysite" -section:system.ftpServer/security/authorization /+"[accessType='Allow',roles='administrators',permissions='Read, Write']" /commit:apphost 

私はapplicationHost.configの中のサイトのエントリを編集しようとしたが、私はマイクロソフトのドキュメントからこの「非カスタム」の例以外にそれを置く場所上の任意のドキュメントを見つけることができません。

<location path="ftp.example.com"> 
    <system.ftpServer> 
    <security> 
     <authorization> 
     <add accessType="Allow" roles="administrators" permissions="Read, Write" /> 
     </authorization> 

とき自分の設定の指定された位置に認証タグを追加すると、FTPサービスは再起動しません。

カスタムFTP認証プロバイダを使用しているときに、どのように認証ルールを追加しますか?

完全性のために、ここにプロバイダクラスのコードを示します。 LogMessageメソッドのテキストファイルへの出力に注意してください。それはすべてが機能していることを私に示しています。ユーザーのホームフォルダにアクセスするルールは存在しないため、ホームフォルダにはアクセスできません。

using System; 
using System.IO; 
using Microsoft.Web.FtpServer; 

namespace MyCustomFtpExtension 
{ 
    public class DatabaseAuthenticator : BaseProvider, 
     IFtpAuthenticationProvider, 
     IFtpRoleProvider, IFtpHomeDirectoryProvider, IFtpPostprocessProvider, 
     IFtpLogProvider 
    { 
     private readonly string _logfile = Path.Combine(@"c:\test", "logs", "FtpExtension.log"); 
     public bool AuthenticateUser(string sessionId, string siteName, string userName, string userPassword, 
      out string canonicalUserName) 
     { 
      canonicalUserName = userName; 

      var result = DatabaseHelper.Authenticate(userName, userPassword); 
      if (result) 
      { 
       LogMessage("Login Success: " + userName); //this message appears 
      } 
      else 
      { 
       LogMessage("Login Failure: " + userName); 
      } 
      return result; 
     } 

     string IFtpHomeDirectoryProvider.GetUserHomeDirectoryData(
      string sessionId, 
      string siteName, 
      string userName) 
     { 
      LogMessage("In ftp home directory"); //this message never appears 

      return @"c:\temp\test"; 
     } 

     public FtpProcessStatus HandlePostprocess(FtpPostprocessParameters postProcessParameters) 
     { 

      LogMessage("Running Post Process"); //this message never appears 
      return FtpProcessStatus.FtpProcessContinue; 
     } 

     public bool IsUserInRole(string sessionId, string siteName, string userName, string userRole) 
     { 
      return true; // I don't care about this - if they authenticate, that's all I need. 
     } 


     //to keep the sample short I took out the log provider - it was copy/paste from Microsoft's example 

     //this is a quick and dirty output so I can see what's going on (which isn't much) 
     private void LogMessage(string logEntry) 
     { 
      using (var sw = new StreamWriter(_logfile, true)) 
      { 
       // Retrieve the current date and time for the log entry. 
       var dt = DateTime.Now; 

       sw.WriteLine("{0}\t{1}\tMESSAGE:{2}", 
        dt.ToShortDateString(), 
        dt.ToLongTimeString(), 
        logEntry); 
       sw.Flush(); 
      } 
     } 
    } 
} 

答えて

0

ライブラリfirホームディレクトリプロバイダを割り当てるコマンドを実行する必要があります。

AppCmd set site "FTP Site Name" /+ftpServer.customFeatures.providers.[name='CustomFtpAuthDemo',enabled='true'] 
関連する問題