Example #1
0
 private void RequestWindowsAuthentication(HttpStatusCode statusCode, Uri requestUri, out bool submitCredentials)
 {
     submitCredentials = false;
     if (statusCode == HttpStatusCode.Unauthorized)
     {
         try
         {
             using (var windowsAuthenticationForm = new WindowsAuthentication(requestUri.Host))
             {
                 DialogResult result = windowsAuthenticationForm.ShowDialog();
                 if (result == DialogResult.OK)
                 {
                     _userName = windowsAuthenticationForm.userName;
                     _password = windowsAuthenticationForm.password;
                     OnWebClientCredentialsModified(_userName, _password);
                     submitCredentials = true;
                 }
                 else
                 {
                     OnWebClientCredentialsModified(null, null);
                 }
             }
         }
         catch (Exception ex)
         {
             submitCredentials = false;
         }
     }
 }
Example #2
0
    //grabs the users login credientials and logs user in the datalayer
    public void WindowsAuth()
    {
        try
        {
            WindowsAuthentication WinAuth = new WindowsAuthentication
            {
                ActivDirName = User.Identity.Name,

            };

            WinAuth.FullName = WinAuth.GetFullName();
            WinAuth.UserName = WinAuth.GetUsername();
            user = Page.User.Identity.Name;

            Name.Text = WinAuth.FullName + " ";
            userlogin.Text = WinAuth.UserName;

        }
        catch (Exception err)
        {
            userlogin.Visible = true;
            userlogin.ForeColor = Color.Red;
            userlogin.Text = "An error has occurred logging you in. " + err.Message;
            //Label1.Text += err.Message;
        }
    }
Example #3
0
 internal void MakeReadOnly()
 {
     _isReadOnly = true;
     ClientCertificate.MakeReadOnly();
     IssuedTokenAuthentication.MakeReadOnly();
     SecureConversationAuthentication.MakeReadOnly();
     ServiceCertificate.MakeReadOnly();
     UserNameAuthentication.MakeReadOnly();
     WindowsAuthentication.MakeReadOnly();
 }
        public void LogoutThrowsNotSupported()
        {
            AuthenticationDomainContext mock    = new AuthenticationDomainContext();
            WindowsAuthentication       service = new WindowsAuthentication();

            service.DomainContext = mock;

            ExceptionHelper.ExpectException <NotSupportedException>(
                () => service.Logout(false));
        }
        public void LogoutThrowsNotSupported()
        {
            AuthenticationDomainContext mock = new AuthenticationDomainContext();
            WindowsAuthentication service = new WindowsAuthentication();

            service.DomainContext = mock;

            ExceptionHelper.ExpectException<NotSupportedException>(
                () => service.Logout(false));
        }
        public void Constructor_Test()
        {
            var windowsAuthentication = new WindowsAuthentication();

            var firstWindowsAuthenticationInternal = windowsAuthentication.WindowsAuthenticationInternal;
            var firstWebFacade = windowsAuthentication.WebFacade;

            windowsAuthentication = new WindowsAuthentication();

            var secondWindowsAuthenticationInternal = windowsAuthentication.WindowsAuthenticationInternal;
            var secondWebFacade = windowsAuthentication.WebFacade;

            Assert.IsFalse(ReferenceEquals(firstWindowsAuthenticationInternal, secondWindowsAuthenticationInternal));
            Assert.IsTrue(ReferenceEquals(firstWebFacade, secondWebFacade));
        }
Example #7
0
        private void EditGame()
        {
            bool canEdit = true;

            if (Score.LockResults)
            {
                canEdit = WindowsAuthentication.Authenticate("Results are Locked. Authenticate to Continue.", true);
            }

            if (canEdit && _gamesListView.SelectedItem != null)
            {
                Game game = (Game)_gamesListView.SelectedItem;
                EditGameWindow.EditGame(this, game);
                Score.Tourney.ApplyGame(game);
                game.LogEvent("Edit Game");
            }
        }
Example #8
0
        /// <summary>
        /// Validate the current user.
        /// </summary>
        private void LoginClient()
        {
            try
            {
                bool   ret      = false;
                string username = txtUsername.Text.Trim();
                string password = txtUserPassword.Text.Trim();

                // Create a new instance of the windows authentication class.
                using (WindowsAuthentication auth = new WindowsAuthentication())
                {
                    // Attach to the on authenticate
                    // event through an anonymous
                    // delegate.
                    auth.OnAuthenticate += delegate(Object s, AuthenticateArgs ae)
                    {
                        // if the user has been authenticated
                        // then the IsAuthenticated property
                        // will return true else false.
                        // Assign the ret value.
                        ret = ae.IsAuthenticated;
                    };

                    // Attempt to authenticate the user.
                    bool result = auth.AuthenticateUser(username, Environment.MachineName, password);

                    // If the user was not authenticated.
                    if (!ret)
                    {
                        MessageBox.Show("Username and or password are incorrect.");
                    }
                    else
                    {
                        LoadData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #9
0
        public TM_Authentication mapUserRoles(bool _disable_CSRF_Check)
        {
            disable_CSRF_Check = _disable_CSRF_Check;
            //"[TM_Authentication] mapUserRoles".info();
            if (sessionID == Guid.Empty || sessionID.validSession() == false)
            {
                /*if (SingleSignOn.singleSignOn_Enabled)
                 * {
                 *  sessionID = new SingleSignOn().authenticateUserBasedOn_SSOToken();
                 * }
                 * else*/
                if (WindowsAuthentication.windowsAuthentication_Enabled)
                {
                    sessionID = new WindowsAuthentication().authenticateUserBaseOn_ActiveDirectory();
                }
            }


            var userGroup = UserGroup.None;

            if (sessionID != Guid.Empty)
            {
                if (check_CSRF_Token())                         // only map the roles if the CSRF check passed
                {
                    userGroup = new UserRoleBaseSecurity().MapRolesBasedOnSessionGuid(sessionID);
                }
                //else
                //    "[TM_Authentication] check_CSRF_Token failed".error();
            }
            if (userGroup == UserGroup.None)
            {
                if (TMConfig.Current.ShowContentToAnonymousUsers)
                {
                    UserGroup.Reader.setThreadPrincipalWithRoles();
                }
                else
                {
                    UserGroup.Anonymous.setThreadPrincipalWithRoles();
                }
            }
            return(this);
        }
Example #10
0
        /// <summary>
        /// 保存连接参数至配置文件MyDB.xml
        /// </summary>
        /// <returns></returns>
        public bool SaveSettings()
        {
            bool bSuccessSaved = false;

            try
            {
                string DbConfigFile = Directory.GetCurrentDirectory() + "\\" + DB_CONFIG_FILE;

                MyXml.XmlWrite(DbConfigFile, "DbConfig", "ServerType", ServerType.ToString());
                MyXml.XmlWrite(DbConfigFile, "DbConfig", "Server", Server);
                MyXml.XmlWrite(DbConfigFile, "DbConfig", "Port", Port);
                MyXml.XmlWrite(DbConfigFile, "DbConfig", "WindowsAuthentication", WindowsAuthentication.ToString());
                MyXml.XmlWrite(DbConfigFile, "DbConfig", "UserId", UserId);
                MyXml.XmlWrite(DbConfigFile, "DbConfig", "Password", DES.Encrypt(Password, MES_KEY, MES_IV));  //加密
                MyXml.XmlWrite(DbConfigFile, "DbConfig", "Database", Database);
                bSuccessSaved = true;
            }
            catch (Exception ex)
            {
                throw (new Exception(ex.Message));
            }
            return(bSuccessSaved);
        }
Example #11
0
    //grabs the users login credientials and logs user in the datalayer
    public void WindowsAuth()
    {
        try
        {
            WindowsAuthentication WinAuth = new WindowsAuthentication
            {
                ActivDirName = User.Identity.Name,
            };

            WinAuth.FullName = WinAuth.GetFullName();
            WinAuth.UserName = WinAuth.GetUsername();
            user             = Page.User.Identity.Name;

            Name.Text      = WinAuth.FullName + " ";
            userlogin.Text = WinAuth.UserName;
        }
        catch (Exception err)
        {
            userlogin.Visible   = true;
            userlogin.ForeColor = Color.Red;
            userlogin.Text      = "An error has occurred logging you in. " + err.Message;
            //Label1.Text += err.Message;
        }
    }
Example #12
0
 public void setup()
 {
     tmConfig.WindowsAuthentication.Enabled = false;
     windowsAuthentication = new WindowsAuthentication();
     userData = new TM_UserData();
 }
Example #13
0
 private bool shouldPromptForPassword(string username, string password)
 {
     return(!WindowsAuthentication.IsBuiltInUsername(username) && password.ShouldPrompt());
 }
 private bool shouldPromptForPassword()
 {
     return(!WindowsAuthentication.IsBuiltInUsername(UserName) && Password.ShouldPrompt());
 }