Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello,
Any ideas on how to do the following?
Allow users in group WebAppAccess full access
Deny users in group WebAppAccessDefaultOnly to WebForm1, WebForm2, and WebForm3 (basically just allowing them to see Default.aspx)

I've gone through multiple articles and have not been able to successfully secure an ASP.NET application. The only way I've been able it to work is by adding "allow" permissions for the group within IIS Authorization on the web server. However, this grants the group full access to the site and even if I set deny permissions on specific pages within web.config, they can still be accessed. The impersonation settings are all set to false and the AppPool identity has been changed to a specific service account because it is the only way I've been able to get my powershell scripts that contain invoke-command on remote computers to run properly. When setting impersonate settings are set to true, I have problems with either logging in or running the scripts from the site.



HTML
<configuration>

  <system.web>
    <authentication mode="Windows"/>
    <identity impersonate="false"/>
    <roleManager enabled="true" />
  </system.web>
  
  <location path="Default.aspx">
    <system.web>
      <authorization>
        <allow roles="domain\WebAppAccess"/>
      </authorization>
    </system.web>
  </location>

  <location path="WebForm1.aspx">
    <system.web>
      <authorization>
        <deny roles="domain\WebAppAccessDefaultOnly"/>
      </authorization>
    </system.web>
  </location>

  <location path="WebForm2.aspx">
    <system.web>
      <authorization>
        <deny roles="domain\WebAppAccessDefaultOnly" />
      </authorization>
    </system.web>
  </location>

  <location path="WebForm3.aspx">
    <system.web>
      <authorization>
        <deny roles="domain\WebAppAccessDefaultOnly" />
      </authorization>
    </system.web>
  </location>
  
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <runtime>
    <legacyImpersonationPolicy enabled="false"/>
    <alwaysFlowImpersonationPolicy enabled="false"/>
  </runtime>
  
</configuration>
Posted

I would do this entirely inside my site. I'd have classes that worked out the permissions, but could do that from any source and then use attributes or method calls in a base class I used for all pages, to allow or deny access based on the logged in user.
 
Share this answer
 
Comments
Tyson3264 4-Aug-12 18:00pm    
Hi Christan, do you know of any articles or references that show how to implement this method? Thanks
Christian Graus 4-Aug-12 18:05pm    
No, sorry, I just worked it out for myself. I always did a base class for my pages in ASP.NET to add helper methods, so adding a security check was an easy step from there.
Found the solution at http://learn.iis.net/page.aspx/142/understanding-iis-url-authorization/[^]

XML
<configuration> 
    <system.webserver> 
        <security> 
            <authorization> 
                <remove users="*" roles="" verbs="" /> 
                <add accesstype="Allow" roles="iis7test\BobAndFriends" />             

            </authorization> 
        </security> 
    </system.webserver> 
    <location path="bobsSecret.aspx"> 
        <system.webserver> 
            <security> 
                <authorization> 
                    <remove users="" roles="iis7test\BobAndFriends" verbs="" /> 
                    <add accesstype="Allow" users="iis7test\Bob" />                  

                </authorization> 
            </security> 
        </system.webserver> 
    </location> 
</configuration> 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900