Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While user logging to my application by browsing default.aspx page, I know whether the user is Customor or Vendor or Employee based on EmployeeType of User object. What I would like to achieve is that I should only allow Customor users could access files and folder under the folder Protected/Customer. Similarly only Vendor users could access only the files and folders under the folder Protected/Vendor. I mean a customer should not allow to access Vendor related pages and vise-versa. How to achieve this? Please do help.

The folder structure looks like given below:

protected/customer/SomeFolder1/SomeFile1.aspx
protected/customer/SomeFolder2/SomeFile2.aspx

protected/vendor/SomeFolder1/SomeFile1.aspx
protected/vendor/SomeFolder2/SomeFile2.aspx

Please note that I'm not using Forms authentication. The authentication is done by Site Minder (By thrid party tool). They will return only UID based on that I could get user details. Users are not assigned to any roles. Based on Employee type of users I need to achieve the above mentioned scenario.
Posted
Updated 22-Oct-12 21:32pm
v2

XML
Control Authorization by Modifying the Web.config File

To restrict access to ASP.NET applications that use forms authentication, edit the <authorization> element in the application’s Web.config file. To do this, follow these steps: 1.Start a text editor, such as Notepad, and then open the Web.config file that is located in the application’s root folder.

Note If the Web.config file does not exist, create a Web.config file for the ASP.NET application.
2.If you want to control authorization for the whole application, add the <authorization> configuration element to the <system.web> element in the Web.config file.
3.In the <authorization> element, add the <allow> configuration element and the <deny> configuration element. Use the users attribute to specify a comma-delimited list of user names. You can use a question mark (?) as a wildcard character that matches any user name. For example, the following code denies access to all users except user1 and user2:

<authorization>
    <allow users="user1, user2"/>
    <deny users="?"/>
</authorization>
4.Save the Web.config file.

Note For more information about configuring directory-specific and file-specific settings, see the References section of this article.



http://asp.net.bigresource.com/How-to-Restrict-Access-to-an-specified-folder-gjhYAFCyM.html[^]
http://forums.asp.net/t/1666926.aspx/1[^]
http://stackoverflow.com/questions/10544276/how-to-restrict-access-to-web-pages-for-different-types-of-users[^]
http://weblogs.asp.net/gurusarkar/archive/2008/09/29/setting-authorization-rules-for-a-particular-page-or-folder-in-web-config.aspx[^]



Thanks,
Ambesha
 
Share this answer
 
You can use ASP.NET Authorization to restrict access to Folder

ASP.NET authentication and authorization[^]

XML
<authorization>
<deny roles="Vendor" />
</authorization>
 
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