상속: RemObjects.InternetPack.CommandBased.SessionEventArgs
예제 #1
0
		protected override void InvokeOnUserLogin(FtpUserLoginEventArgs ea)
		{
#if DEBUGSERVER
			Debug.EnterMethod("Login({0})", ea.UserName);
			try
			{
#endif
				if (fUserManager == null) return;
				VirtualFtpSession lSession = (VirtualFtpSession)ea.Session;
				ea.LoginOk = fUserManager.CheckLogin(ea.UserName, ea.Password, lSession);
#if DEBUGSERVER
				Debug.Write("Login result " + ea.LoginOk);
#endif
				base.InvokeOnUserLogin(ea);
#if DEBUGSERVER
			}
			finally
			{
				Debug.ExitMethod("Login({0}):{1}", ea.UserName, ea.LoginOk);
			}
#endif
		}
예제 #2
0
 internal protected virtual void InvokeOnUserLogin(FtpUserLoginEventArgs e)
 {
     if (this.OnUserLogin != null)
         this.OnUserLogin(this, e);
 }
예제 #3
0
        public static void Cmd_PASS(Object sender, CommandEventArgs e)
        {
            FtpSession lSession = (FtpSession)e.Session;

            if (lSession.State == FtpState.PasswordRequired)
            {
                if (e.Parameters.Length != 1)
                {
                    e.Connection.WriteLine("501 Syntax error in parameters or arguments.");
                }
                else
                {
                    FtpUserLoginEventArgs lEventArgs = new FtpUserLoginEventArgs(e.Session, e.Connection, e.Server);
                    lEventArgs.UserName = lSession.Username;
                    lEventArgs.Password = e.Parameters[0];
                    try
                    {
                        ((FtpServer)e.Server).InvokeOnUserLogin(lEventArgs);
                    }
                    catch (FtpException ex)
                    {
                        e.Connection.WriteLine(ex.ToString());
                        return;
                    }
                    catch
                    {
                        e.Connection.WriteLine("500 Internal Error");
                        return;
                    }

                    if (lEventArgs.LoginOk)
                    {
                        if (lEventArgs.NeedAccount)
                        {
                            lSession.State = FtpState.AccountRequired;
                            e.Connection.WriteLine("332 Need account for login.");
                        }
                        else
                        {
                            lSession.State = FtpState.LoggedIn;
                            e.Connection.WriteLine("230 User logged in, proceed.");
                        }
                    }
                    else
                    {
                        lSession.State = FtpState.Start;
                        e.Connection.WriteLine("530 Unable to login");
                    }
                }
            }
            else
            {
                e.Connection.WriteLine("503 Bad sequence of commands.");
            }
        }
예제 #4
0
 private void OnUserLogin(object sender, FtpUserLoginEventArgs e)
 {
     if (e.LoginOk)
     {
         VirtualFtpServer server = (VirtualFtpServer)sender;
         VirtualFtpSession session = (VirtualFtpSession)e.Session;
         session.IsFileAdmin = e.UserName.Equals(server.RootFolder.Name);
         session.CurrentFolder = GetUserFolder(session);
     }
 }