示例#1
0
        private void AuthenticationAdminForm_Shown(object sender, EventArgs e)
        {
            cbAuthenticationModes.Items.Add(new ComboBoxItem <AuthenticationModeEnum>(AuthenticationModeEnum.Off));
            cbAuthenticationModes.Items.Add(new ComboBoxItem <AuthenticationModeEnum>(AuthenticationModeEnum.OnlyPassword));
            cbAuthenticationModes.Items.Add(new ComboBoxItem <AuthenticationModeEnum>(AuthenticationModeEnum.UsernameAndPassword));

            switch (Settings.AuthenticationMode)
            {
            case AuthenticationModeEnum.OnlyPassword:
                cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[1];
                gbPassword.Enabled = true;
                pUsers.Enabled     = false;
                break;

            case AuthenticationModeEnum.UsernameAndPassword:
                cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[2];
                gbPassword.Enabled = false;
                pUsers.Enabled     = true;
                break;

            case AuthenticationModeEnum.Off:
                cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[0];
                gbPassword.Enabled = false;
                pUsers.Enabled     = false;
                break;
            }

            foreach (string username in AuthenticationHandlerModule.GetUsers())
            {
                ListViewItem item = new ListViewItem(username);
                lvUsers.Items.Add(item);
            }
        }
示例#2
0
 private void btOk_Click(object sender, EventArgs e)
 {
     if (tbUsername.Enabled)
     {
         if (tbUsername.Text.Length == 0)
         {
             MessageBox.Show(this, Resources.MsgBox_UserMandatory, Resources.MsgBox_Title_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (AuthenticationHandlerModule.GetUsers().Contains <string>(tbUsername.Text))
         {
             MessageBox.Show(this, Resources.MsgBox_UserNameExist, Resources.MsgBox_Title_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         AuthenticationHandlerModule.SetPassword(tbUsername.Text, tbUserPassword.Text);
         lvUsers.Items.Add(new ListViewItem(tbUsername.Text));
     }
     else
     {
         AuthenticationHandlerModule.SetPassword(tbUsername.Text, tbUserPassword.Text);
     }
     btCancel_Click(sender, e);
 }