title: How can I check a current logged in user security level so i can disable features?
body: <p><strong>PRE</strong>
  I'm using SQLExpress to store information.</p>
  
  <p>I have a very basic user set-up in my app. I have a Login table that contains only three fields, these are Username, Password and Security Level. There are only three security levels; High, Medium and Low.</p>
  
  <p>On my login form, I have the following code to save the user that is logging into a <code>Settings.Default[]</code>, so I can read it later.</p>
  
  <pre><code>private void Loginbtn_Click(object sender, EventArgs e)
  {
      SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=MySupportHub;Integrated Security=True");
      SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [dbo].[Login] Where Username='" + usernameTextBox.Text + "' and Password='" + passwordTextBox.Text + "'", con);
      DataTable dt = new DataTable();
      sda.Fill(dt);
      if (dt.Rows.Count == 1)
      {
          Settings.Default["CurrentUserName"] = usernameTextBox.Text;
          Settings.Default.Save();
  
          this.Hide();
          Home home = new Home();
          home.Show();
      }
      else
      {
          MessageBox.Show("Invalid Username and/or Password..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
          Clearbtn_Click(sender, e);
      }
  }
  </code></pre>
  
  <p>Then on the Home page, I have the following code to get the value and display the current logged in user in the bottom status bar. On page load.</p>
  
  <pre><code>//Identify and display current logged in user
  
  CurrentUser.Caption = Settings.Default["CurrentUserName"].ToString();
  </code></pre>
  
  <p>What I would like to be able to do now is check the current logged in users security level (User value would be stored here "<code>CurrentUser.Caption</code>" on the main form) and be able to disable features like creating a new user etc.</p>
  
  <p>So I would need to be able to read the <code>CurrentUser.Caption</code> value, check that against the (SQL Express) [dbo].[Login] table and find the user's security level and limit features based on the result.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks</p>
  
  <p>Phil</p>