Click here to Skip to main content
12,626,517 members (34,663 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET SQL Server
I took web.config in each folder of my project like Reports,Master etc,
This is web.config code of report folder
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <authorization>
      <allow roles="Administrator,Employee" />
      <deny users="*" />
    </authorization>
  </system.web>
</configuration>
Now if i remove Administrator
      <allow roles="Employee" />
Then it don't allow me to see reports directly but i want same effect after some time/duration.So how can i do it through coding.
Posted 26-Sep-12 3:57am
mu-kul333
Updated 26-Sep-12 4:35am
v2
Comments
source.compiler 26-Sep-12 9:10am
   
you want administrator see that folder in a time range?
mu-kul 26-Sep-12 9:24am
   
at Beginning (for few days/month) administrator can see it but not after that
can i put some condition on which administrator should be remove.Just want to remove Administrator role from allow role tag.
Sergey Alexandrovich Kryukov 26-Sep-12 11:08am
   
Why would you want to abuse the nature of the Web? You should better review your design and motivation of your decision. It's the best to assume the point of view of your customer.
--SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

DateTime dt = new DateTime(2012, 10, 10);
if (DateTime.Now == dt)
{
   System.Configuration.Configuration config =                              System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("YOUR 
web.config PATH");
                System.Web.Configuration.AuthorizationRule authosecrole = new   AuthorizationRule(AuthorizationRuleAction.Deny);
 
                System.Web.Configuration.AuthorizationSection auth =(AuthorizationSection)configs.GetSection("system.web/authorization");
                auth.Rules.Add(authosecrole);
}

i hope it helps you ...
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100