Click here to Skip to main content
11,708,312 members (70,927 online)
Click here to Skip to main content

Tagged as

Granting Anonymous Access to Sharepoint List / Library Programtically

, 2 Apr 2013 CPOL 15K 2
Rate this:
Please Sign up or sign in to vote.
CodeProjectIn this post we will see how to enable and disable Anonymous access to a List or Document library from a sharepoint feature (C# code).There are 3 different steps involved in granting Anonymous access to a List/Library in a right way.Step 1: Enabling the anonymous accesss to the Web applic
In this post we will see how to enable and disable Anonymous access to a List or Document library from a sharepoint feature (C# code).

There are 3 different steps involved in granting Anonymous access to a List/Library in a right way.

Step 1: Enabling the anonymous accesss to the Web application from Central Admin. This does not mean that the whole web application is now anonymous. This step signifies that, this web application has ability to host resources that can be accessed by Anonymous user.


Now click save and close Central Admin. I am pointing again that the above step will not make whole webapplication accessible to anonymous users. This will create scope for hosting something that can be accessible by anonymous user.

Step 2: Enabling the Anonymous permissions in Web application settings. Go to Site Permission screen. As you have already enabled Anonymous access for this web application from central admin, a new button "Anonymnous Access" will be appeared on the ribbon.


This will open a popup with 3 options shown below specifying whether you want to enable access on whole site, or only lists and libraries or nothing.

I selected Lists and Libraries. Even now it doesnt mean that Lists and libraries in my web application are accessible to Anonymous user. here comes the next step.

Step 3: Now open the List / Library for which you want Anonymous access, and go to List / Library Permissions.

Now, click on Anonymous Access button on ribbon, and a popup will appear where you can select which kind of permissions you want to give for Unauthenticated user.

Now, the list can be accessed by unauthenticated / anonymous users.

But, in real time scenarios, the step 3 is not recomended as it involves manual intervention in granting access, which is not possible in most of the PRODUCTION scenarios.

So, it is recomended to perform step 3 using a feature activation or de-activation.
Here is the code for making a Document library anonymous while activating a feature.

Here is the code for removing Anonymous access to a Document library while de-activating a feature.

Happy Coding !

License

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

Share

About the Author


You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 2 Apr 2013
Article Copyright 2013 by PratapReddyP
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid