title: ASP.NET Active Directory role provider
body: <p>This is my first time working with ASP.NET Role membership in active directory.</p>
  
  <p>So far i've got a website running, and im able to log in with a active directory user.</p>
  
  <p>My problem is: I cant get "Roles.IsUserInRole" to trigger. It's like it dosent even look at the logged in user for group memberships.</p>
  
  <p>I have been searching for a solution, but the only solution i can find is to write my own membership provider. Is this really neccesary? </p>
  
  <p>I want to control what the users can access with their memberships.
  Like if a user is in the "students" security group in the AD then they can only access pages in a student fold in my ASP.NET solution.</p>
  
  <p>I am useing form authentication.</p>
  
  <p>Here is a sample of my webconfig for my rolemanager:</p>
  
  <pre><code>    &lt;system.web&gt;
    &lt;roleManager defaultProvider="WindowsProvider"
                 enabled="true"
                 cacheRolesInCookie="false"&gt;
      &lt;providers&gt;
        &lt;add
          name="WindowsProvider"
          type="System.Web.Security.WindowsTokenRoleProvider" /&gt;
      &lt;/providers&gt;
    &lt;/roleManager&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>and here im trying the IsUserInRole</p>
  
  <pre><code>        protected void Login2_LoggingIn(object sender, LoginCancelEventArgs e)
          {
              if (Roles.IsUserInRole("Students"))
              {
              Response.Redirect("../Students/StartPage.aspx");
              }
          }
  </code></pre>
  
  <p>Bonus question: I am only able to login with users from the "Users" container ind my AD. Why cant i login with a user from a OU some levels down? </p>