private eLoginEnum LoginInternal(string username, string password, Version AClientVersion, out Int32 AClientID, out string AWelcomeMessage, out Boolean ASystemEnabled, out IPrincipal AUserInfo, out Boolean AMustChangePassword) { AUserInfo = null; ASystemEnabled = true; AWelcomeMessage = string.Empty; AClientID = -1; AMustChangePassword = false; if (DBAccess.GDBAccessObj == null) { TServerManager.TheCastedServerManager.EstablishDBConnection(); } try { TConnectedClient CurrentClient = TClientManager.ConnectClient( username.ToUpper(), password.Trim(), HttpContext.Current.Request.UserHostName, HttpContext.Current.Request.UserHostAddress, AClientVersion, TClientServerConnectionType.csctRemote, out AClientID, out AWelcomeMessage, out ASystemEnabled, out AUserInfo); TSession.SetVariable("LoggedIn", true); // the following values are stored in the session object DomainManager.GClientID = AClientID; DomainManager.CurrentClient = CurrentClient; UserInfo.GUserInfo = (TPetraPrincipal)AUserInfo; DBAccess.GDBAccessObj.UserID = username.ToUpper(); TServerManager.TheCastedServerManager.AddDBConnection(DBAccess.GDBAccessObj); AMustChangePassword = (((TPetraPrincipal)AUserInfo).LoginMessage == SharedConstants.LOGINMUSTCHANGEPASSWORD); return(eLoginEnum.eLoginSucceeded); } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); TSession.SetVariable("LoggedIn", false); if (DBAccess.GDBAccessObj != null) { DBAccess.GDBAccessObj.CloseDBConnection(); } TSession.Clear(); return(TClientManager.LoginErrorFromException(e)); } }
private eLoginEnum LoginInternal(string username, string password, Version AClientVersion, out Int32 AClientID, out string AWelcomeMessage, out Boolean ASystemEnabled, out Boolean AMustChangePassword) { ASystemEnabled = true; AWelcomeMessage = string.Empty; AClientID = -1; AMustChangePassword = false; Int64 SiteKey; try { if (username.ToUpper() == "SELFSERVICE") { throw new Exception("Login with user SELFSERVICE is not permitted"); } TConnectedClient CurrentClient = TClientManager.ConnectClient( username.ToUpper(), password.Trim(), HttpContext.Current.Request.UserHostName, HttpContext.Current.Request.UserHostAddress, AClientVersion, TClientServerConnectionType.csctRemote, out AClientID, out AWelcomeMessage, out ASystemEnabled, out SiteKey); TSession.SetVariable("LoggedIn", true); // the following values are stored in the session object DomainManager.GClientID = AClientID; DomainManager.CurrentClient = CurrentClient; DomainManager.GSiteKey = SiteKey; AMustChangePassword = (UserInfo.GetUserInfo().LoginMessage == SharedConstants.LOGINMUSTCHANGEPASSWORD); return(eLoginEnum.eLoginSucceeded); } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); TSession.SetVariable("LoggedIn", false); TSession.CloseSession(); return(TClientManager.LoginErrorFromException(e)); } }