Click here to Skip to main content
16,005,339 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I took web.config in each folder of my project like Reports,Master etc,
This is web.config code of report folder
XML
<?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
Updated 26-Sep-12 3:35am
v2
Comments
ali_heidari_ 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

C#
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 ...
 
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