Click here to Skip to main content
15,881,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All
How to clear error " Logon failure: unknown user name or bad password"
below coding using error occur how to clear error
C#
private void Run()
        {
            /* Execute PSFTP as a System.Diagnostics.Process using the supplied login info and generated batch file */
            try
            {
                SecureString sec_strPassword = new SecureString();
                SecureString secureString = new SecureString();
                Misc miscObj = new Misc();
                //Converting UnSecure String to Secure String
                sec_strPassword = miscObj.convertToSecureString(_Password.Trim());
                
                ProcessStartInfo PsftpStartInfo = new ProcessStartInfo(_PsftpPath,
                _User.Trim() + @"@" + _Host.Trim() + @" -pw " + _Password.Trim() + @" -batch -be -b " + _BatchFilePath);

                /* Allows redirecting inputs/outputs of PSFTP to your app */
                PsftpStartInfo.RedirectStandardInput = true;
                PsftpStartInfo.RedirectStandardOutput = true;
                PsftpStartInfo.RedirectStandardError = true;
                PsftpStartInfo.UseShellExecute = false;
                PsftpStartInfo.Domain = _Host;
                PsftpStartInfo.UserName = _User.Trim();
                PsftpStartInfo.Password = sec_strPassword  ;
                System.Diagnostics.Process PsftpProcess = new System.Diagnostics.Process();
                PsftpProcess.StartInfo = PsftpStartInfo;
           <big>     PsftpProcess.Start();</big>

                /* Streams for capturing outputs and errors as well as taking ownership of the input */
                StreamReader PsftpOutput = PsftpProcess.StandardOutput;
                StreamReader PsftpError = PsftpProcess.StandardError;
                StreamWriter PsftpInput = PsftpProcess.StandardInput;


                while (!PsftpOutput.EndOfStream)
                {
                    try
                    {
                        /* This is usefule for commands other than 'put' or 'get' 
                         and for catching errors. */
                        Outputs += PsftpOutput.ReadLine();
                        Outputs += PsftpError.ReadLine();
                    }
                    catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                }

                PsftpOutput.Close();
                PsftpError.Close();
                PsftpInput.Close();
                PsftpProcess.WaitForExit();

                PsftpStartInfo = null;
                PsftpProcess = null;
            }
            catch (Exception ex) { Console.WriteLine(ex.ToString()); }

            /* Delete the batch file */
            try
            {
                File.Delete(_BatchFilePath);
            }
            catch (Exception ex) { Console.WriteLine(ex.ToString()); }

            return;
        }
Posted
Updated 23-Apr-14 1:54am
v3
Comments
CHill60 23-Apr-14 7:56am    
Supply the correct logon and password????
[no name] 23-Apr-14 8:19am    
5! virtually

1 solution

It has nothing to do with your code. You just need to make sure you pass the correct combination of user name and password.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900