/// <summary> /// Finds a user by userName and password /// </summary> /// <param name="username">The username of the user to find</param> /// <param name="password">The password of the user</param> /// <param name="u">The reference of the user to fill</param> /// <returns>The user if found or null otherwise</returns> public LoginResult Find(string username, string password, ref DSPrima.WcfUserSession.Interfaces.IUser u) { if (string.IsNullOrWhiteSpace(username)) { return(LoginResult.Failed); } ManagerHandler m = new ManagerHandler(); User user = m.UserManager.FindByName(username); if (user == null) { return(LoginResult.Failed); } if (!user.EmailConfirmed) { return(LoginResult.RegistrationNotCompleted); } if (m.UserManager.IsLockedOut(user.Id)) { return(LoginResult.UserIsLockedOut); } if (user.IsExternalUser && !string.IsNullOrWhiteSpace(password)) { bool success = WcfUserSessionUserManager.ExternalAuthenticathor.VerifyUsernameAndPassword(username, password); if (!success) { return(LoginResult.Failed); } } else if (user.IsExternalUser && !WcfUserSessionSecurity.Current.RequestHeader.ClientName.Equals(Settings.Default.SecuredAccessServerName, System.StringComparison.CurrentCultureIgnoreCase)) { return(LoginResult.Failed); } else if (!user.IsExternalUser && !m.UserManager.CheckPassword(user, password)) { if (user.LockoutEnabled) { m.UserManager.AccessFailed(user.Id); } return(LoginResult.Failed); } m.UserManager.ResetAccessFailedCount(user.Id); user.ProxyUserPatientMap = (from p in m.UserManager.GetPatientsForUserInSession(user.Id) select new ProxyUserPatientMap(user, p)).ToList(); user.Permissions = m.UserManager.GetPermissions(user.Id); user.RoleNames = m.UserManager.GetRoles(user.Id); u = user; return(LoginResult.Success); }
/// <summary> /// Sets the CurrentSession of the Business Logic to the WcfUserSessionSecurity current session /// </summary> /// <param name="sessionId">The Id of the current session</param> /// <param name="user">The user to set it to</param> /// <param name="header">The Request header that was part of the message</param> public static void WcfUserSessionSecurity_SessionUpdated(string sessionId, DSPrima.WcfUserSession.Interfaces.IUser user, RequestHeader header) { SecuritySession.SetCurrentSession(sessionId, (User)user); WcfUserSessionUserManager.SetSessionPermissions(); }