2017-01-27 67 views
1

"リモートサーバーからエラーが返されました:(530)ログインしていません。 FtpWebRequest.GetResponse()が呼び出されたとき。私は基本的な認証のためにFTPサイトを間違って構成したためだと思うが、わからない。私は他の投稿を読んだことがありますが、ソリューションはNetworkCredentialオブジェクトで指定されている間違った資格情報を中心に回転しているようです。私はSSLを介してFTPサイトに資格情報を渡すことができるようにしたいと思います。私はこの問題をテストプロジェクトに分離しました。ここでは、主にMSDN https://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.enablessl(v=vs.110).aspxからコピーされます。FtpWebRequest:リモートサーバーからエラーが返されました:(530)ログインしていません

enter image description here

enter image description here

enter image description here

次は何

public static void Main(string[] args) 
{ 
    // Only use this to get around issues with self-signed certificates... 
    ServicePointManager.ServerCertificateValidationCallback = 
     delegate (object s, X509Certificate certificate, X509Chain chain, 
     SslPolicyErrors sslPolicyErrors) { return true; }; 

    ListFilesOnServerSsl(new Uri("ftp://127.0.0.1:21")); 

    Console.WriteLine("Press any key..."); 
    Console.ReadKey(); 
} 

public static bool ListFilesOnServerSsl(Uri serverUri) 
{ 
    // The serverUri should start with the ftp:// scheme. 
    if (serverUri.Scheme != Uri.UriSchemeFtp) 
    { 
     return false; 
    } 
    // Get the object used to communicate with the server. 
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri); 
    request.Method = WebRequestMethods.Ftp.ListDirectory; 
    request.UseBinary = false; 
    request.EnableSsl = true; 

    // Need to use credentials to log in... 
    request.Credentials = new NetworkCredential("TestFtpUser", "IDontKnow"); 

    // Get the ServicePoint object used for this request, and limit it to one connection. 
    // In a real-world application you might use the default number of connections (2), 
    // or select a value that works best for your application. 

    ServicePoint sp = request.ServicePoint; 
    Console.WriteLine("ServicePoint connections = {0}.", sp.ConnectionLimit); 
    sp.ConnectionLimit = 1; 

    FtpWebResponse response = (FtpWebResponse)request.GetResponse(); 
    Console.WriteLine("The content length is {0}", response.ContentLength); 
    // The following streams are used to read the data returned from the server. 
    Stream responseStream = null; 
    StreamReader readStream = null; 
    try 
    { 
     responseStream = response.GetResponseStream(); 
     readStream = new StreamReader(responseStream, System.Text.Encoding.UTF8); 

     if (readStream != null) 
     { 
      // Display the data received from the server. 
      Console.WriteLine(readStream.ReadToEnd()); 
     } 
     Console.WriteLine("List status: {0}", response.StatusDescription); 
    } 
    finally 
    { 
     if (readStream != null) 
     { 
      readStream.Close(); 
     } 
     if (response != null) 
     { 
      response.Close(); 
     } 
    } 


    Console.WriteLine("Banner message: {0}", 
     response.BannerMessage); 

    Console.WriteLine("Welcome message: {0}", 
     response.WelcomeMessage); 

    Console.WriteLine("Exit message: {0}", 
     response.ExitMessage); 
    return true; 
} 

がIISで私のローカルホスト上でFTPサイトを作成するためのスクリーンショットです

enter image description here

enter image description here

基本認証が設定されているときにIISからパスワードの入力を求められていないことに気付きました。なぜこれがわからないのですか? FTPサイトで基本認証を使用しないでください。

事前に感謝します。

答えて

0

IISでftpサイトを構成するときに、 "指定されたユーザー"と一致するようにマシン上にローカルユーザーアカウントを構成していないことがわかりました。 「コントロールパネル」=>「ユーザーアカウント」=>「ユーザーアカウント」=>「ユーザーアカウントの管理」=>「ユーザーアカウントの管理」=>「追加」をクリックしてローカルマシンにユーザーを追加すると、「 530)Not Logged In "が消えた。

関連する問題