コード例 #1
0
        public void RegisterUserForAuthentication(string username, SecureString password)
        {
            UserManager userManager = new UserManager();
            var currentApplicationUser = userManager.GetUser(username, password);

            AuthenticationManager.IsAnAdmin = currentApplicationUser.IsAdmin;
            AuthenticationManager.IsReadOnly = currentApplicationUser.IsReadOnly;
            AuthenticationManager.CurrentUser = currentApplicationUser.Username;

            if (this.ValidAuthenticationEvent != null)
                this.ValidAuthenticationEvent(this, EventArgs.Empty);
        }
コード例 #2
0
        private bool IsUserCredentialsCorrect(string username, SecureString password)
        {
            UserManager userManager = new UserManager();
            bool isUserCredentialsCorrect = true;
            try
            {
                userManager.GetUser(username, password);
            }
            catch (ArgumentNullException)
            {
                isUserCredentialsCorrect = false;
            }
            catch (ArgumentException)
            {
                isUserCredentialsCorrect = false;
            }

            return isUserCredentialsCorrect;
        }