none
How to grant anonymous access on sharepoint document library/list only not for web application RRS feed

  • Question

  • Hello

    How to grant anonymous access on sharepoint document library/list only not for web application.I have claim based sharepoint site and has to be but i want to grant access on document library/list only.Is this possible?

    Thanks


    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    Monday, July 22, 2013 12:22 PM

Answers

  • Hi Rajesh,

    Yes, you could do that. But first, you should enable anonymous at web application level, then site collection level for lists and libraries not entire web site. Then go to list permissions to enable anonymous access.

    For more information, see

    http://blog.cloudshare.com/2012/10/15/how-to-enable-anonymous-access-to-a-sharepoint-2013-site/

    Best Regards.


    Kelly Chen
    TechNet Community Support

    Tuesday, July 23, 2013 3:03 AM
    Moderator
  • Hi Rajesh,

    You MUST have anonymous access enabled at the web application level, in order for you to activate it at the site level. The type of access you define in your site will define the actual access they will have.

    Enable-ing anonymous access at the Web Application DOES NOT give users anonymous access to your site. It is however required in order to be able to select the 'Anonymous access' section if the permission management in your site.

    If you specify 'Lists and Libraries' as Kelly suggested, you can enable access to anonymous users to only those lists and libraries.

    Cheers,
    Vincent


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, July 23, 2013 6:02 AM

All replies

  • Hi Rajesh,

    Yes, you could do that. But first, you should enable anonymous at web application level, then site collection level for lists and libraries not entire web site. Then go to list permissions to enable anonymous access.

    For more information, see

    http://blog.cloudshare.com/2012/10/15/how-to-enable-anonymous-access-to-a-sharepoint-2013-site/

    Best Regards.


    Kelly Chen
    TechNet Community Support

    Tuesday, July 23, 2013 3:03 AM
    Moderator
  • Hello Chen,

    I don't want to  enable anonymous at web application level causing anonymous access on site.

    suppose i enable anonymous at web application programmatically, it causing anonymous access on site?

    I just want to enable list and libraries for site only.


    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    Tuesday, July 23, 2013 5:17 AM
  • Hi Rajesh,

    NO, you should also enable anonymous access on site after you enable it at web application level.

    Best Regards.


    Kelly Chen
    TechNet Community Support

    Tuesday, July 23, 2013 5:52 AM
    Moderator
  • Hi Rajesh,

    You MUST have anonymous access enabled at the web application level, in order for you to activate it at the site level. The type of access you define in your site will define the actual access they will have.

    Enable-ing anonymous access at the Web Application DOES NOT give users anonymous access to your site. It is however required in order to be able to select the 'Anonymous access' section if the permission management in your site.

    If you specify 'Lists and Libraries' as Kelly suggested, you can enable access to anonymous users to only those lists and libraries.

    Cheers,
    Vincent


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, July 23, 2013 6:02 AM
  • As i am using following code

    SPSite site = SPContext.Current.Site;
                SPWeb web = SPContext.Current.Web;
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite ospSite = new SPSite(site.ID))
                    {
                        using (SPWeb webs = ospSite.OpenWeb(web.ID))
                        {

                            // Enable anonymous access on web application
                            webs.AllowUnsafeUpdates = true;
                            SPUrlZone urlZone = SPUrlZone.Default;
                            SPWebApplication specifiedWebApplication = ospSite.WebApplication;
                            SPIisSettings iisSettings = specifiedWebApplication.IisSettings[urlZone];
                            //iisSettings.AuthenticationMode = AuthenticationMode.Windows;
                            iisSettings.AllowAnonymous = true;                       
                            specifiedWebApplication.Update();
                            // Get document library collection here and fetch all the document urls
                            SPDocumentLibrary docLib = (SPDocumentLibrary)web.Lists["Documents"];

                            if (docLib != null)
                            {
                                docLib.BreakRoleInheritance(true, false);
                                docLib.AllowEveryoneViewItems = true;
                                docLib.AnonymousPermMask64 = SPBasePermissions.ViewPages | SPBasePermissions.OpenItems | SPBasePermissions.ViewVersions
                                    | SPBasePermissions.Open | SPBasePermissions.UseClientIntegration | SPBasePermissions.ViewFormPages | SPBasePermissions.ViewListItems;
                                //docLib.AnonymousPermMask64 = SPBasePermissions.EmptyMask;
                                docLib.Update();
                            }
                        }
                    }
                });

    Should working but getting access denied......i am totally stuck at this point.


    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    Tuesday, July 23, 2013 10:01 AM
  • above code working very fine in console application but it is not working from visual webpart.I don't know how?

    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    Tuesday, July 23, 2013 11:40 AM
  • Hi,

    It must be a permission issue. When you run a console application it's using current user but when you run it on sharepoint it uses application pools identity. I'm guessing that you're a farm admin while app pools identity is not.

    Tuesday, July 23, 2013 12:14 PM
  • my App Pool a/c :spadmin

    and this is also added under farm administrator group.

    spadmin has right to  do everything on my dev env but......


    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.


    Tuesday, July 23, 2013 12:21 PM
  • SPDocumentLibrary docLib = (SPDocumentLibrary)web.Lists["Documents"];

    Here might be your problem. You're accessing web instead of elevated webs. Thought would be easier if you posted which update is causing the "access denied" error.


    • Edited by Valdas Jusaitis Tuesday, July 23, 2013 12:29 PM Text correction
    Tuesday, July 23, 2013 12:29 PM
  • I have allready corrected.I am accessing elevated webs.

     SPDocumentLibrary docLib = (SPDocumentLibrary)webs.Lists["Documents"];

    specifiedWebApplication.Update();

    above causing access denied.


    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    Tuesday, July 23, 2013 12:38 PM
  • My main concern is that 

    Granting Anonymous Access to Sharepoint List / Library Programtically


    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    Tuesday, July 23, 2013 12:51 PM
  • HI rajesh,

    Check the below URl exact what you want, in the screen last screen you should select "Lists and Libraries"

    http://blog.cloudshare.com/2012/10/15/how-to-enable-anonymous-access-to-a-sharepoint-2013-site/

    Regards,

    Jithendar

    Sunday, December 29, 2013 10:00 AM