title: Security script based on Global Group?
body: <p>I'm not sure if this is possible, but I'd like to limit my users to specific areas of an Intranet site based on their membership in specific Global Groups created in SQL Server. </p>
  
  <p>For example, I've got the following menu in ASP:</p>
  
  <pre><code>    &lt;div class="clear hideSkiplink" id="MainMenu"&gt;
  
          &lt;asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" 
              IncludeStyleBlock="False" Orientation="Horizontal" 
              BackColor="#CC3300"&gt;
  
              &lt;Items&gt; 
                  &lt;asp:MenuItem  NavigateUrl="~/Default.aspx" Text="Home" Selectable="true" /&gt;
                      &lt;asp:MenuItem NavigateUrl="~/Forms/frmCensusList.aspx" Text="Census Editing"/&gt;
                      &lt;asp:MenuItem NavigateUrl="~/Forms/frmRoster.aspx" Text="Roster Editing"/&gt;
                      &lt;asp:MenuItem NavigateUrl="~/Forms/frmReportMenu.aspx" Text="Reporting"/&gt;
                      &lt;asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/&gt;
                     &lt;%-- &lt;asp:MenuItem NavigateUrl="~/WebForm1.aspx" Text="Test"/&gt;--%&gt;
              &lt;/Items&gt;
  
          &lt;/asp:Menu&gt;
      &lt;/div&gt; 
  </code></pre>
  
  <p>And then the following in the Code Behind that limits what "security level" can see the "About" page:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      string path = Request.AppRelativeCurrentExecutionFilePath;
      foreach (MenuItem item in NavigationMenu.Items)
      {
          item.Selected = item.NavigateUrl.Equals(path, StringComparison.InvariantCultureIgnoreCase);
      }
  
      // If the user isn't an Admin, hide the About menu option
      string ActiveUser = System.Web.HttpContext.Current.User.Identity.Name;
      string SecurityLevel = ActiveUser.SecLevel();
      if (SecurityLevel != "ADMIN")
      {
          MenuItem mnuItem = NavigationMenu.FindItem("About"); // Find particular item
          if (mnuItem != null)
          {
              NavigationMenu.Items.Remove(mnuItem);
          }
      }
  
  }
  </code></pre>
  
  <p>SecLevel() is a function I created that's based on a table of user's IDs, but maintaining the table is a pain, plus future projects are going to be a pain to compile the original table, and it will just be easier if I can do this based on existing Global Groups.</p>
  
  <p>Anyone got any suggestions?</p>