Reputation: 34198
Our company web site is hosted in ORCSWEB. Some kind of policy and rule has been set on ORCS end. When people try to access our company ftp with wrong credential 3 times and fail then our ftp will be locked. We often upload file through ftp by programatically but some times found ftp lock. So I talk to orcsweb tech support: they said we are try to access our ftp anonymously by code. So the code which I use to access ftp as follows. So please go through my code and tell me what is wrong in my code which causes anonymous access because I try to access with the right credentials.
public static string IsFtpAccessible(string FTPAddress)
{
string strError = "";
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(FTPAddress);
FtpWebResponse res;
StreamReader reader;
ftp.Credentials = new NetworkCredential("myuserid", "00000password");
ftp.KeepAlive = false;
ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
ftp.UsePassive = true;
ftp.UseBinary = true;
ftp.KeepAlive = false;
try
{
using (res = (FtpWebResponse)ftp.GetResponse())
{
reader = new StreamReader(res.GetResponseStream());
}
}
catch(Exception ex)
{
strError = "ERROR:" + ex.Message.ToString();
}
return strError;
}
So tell me what is missing in my code that causes anonymous access.
Upvotes: 2
Views: 7987
Reputation: 1537
Anonymous access must be allowed on the server, which I'm assuming is not allowed based on your description. Typically, Anonymous access credentials are supplied like this:
request.Credentials = new NetworkCredential ("anonymous","[email protected]");
The main point is that an email address is the password.
If you only sometimes find that the code based FTP is locked, then this is not where your problem lies.
Upvotes: 3