This blog post introduce use two different ways to enable anonymous access in SharePoint 2010.
As a SharePoint administrator, you should be familiar with SharePoint Central Administration. So you can use the following 10 steps to set up anonymous access in SharePoint 2010.
1. Open the SharePoint 2010 Central Administration.
2. On the Central Administration home page, under Application Management, click on the Manage web applications. Then you see the list of web applications. (Figure 1)
3. Select a Web Application which you want to enable anonymous access, and then click Authentication Providers ribbon button.
4. On the Authentication Providers dialog box, click the Default zone. And then show the Edit Authentication dialog box.
5. Under Edit Authentication dialog box, check Enable anonymous access and click save. (Figure 2)
6. Go back to the Web Application Management and click Anonymous Policy ribbon button to set up Anonymous Access Restrictions. (Figure 3)
7. Under the Anonymous Access Restrictions dialog box, set up anonymous user policy for specified zone.
8. Once the above steps have been done. You selected Web Application will allow anonymous access. But until you finish the following steps, anonymous users cannot access any sites at a site collection. So you should go to the Site Permissions of the site which you want to enable anonymous access.
9. On the Site Permissions page, click Anonymous Access ribbon button. (Figure 4 and Figure 5)
10. Under the Anonymous Access dialog box, set permission for anonymous users. You can select Entire Web site and save it. (Figure 6)
Done, you can have a try to access your site without login on to make sure it has been enabled Anonymous Access successfully.
Now, you’d maybe think the process is so simple, and then what is another way?
Keep on, another way is for SharePoint developer. It will enable anonymous access in SharePoint 2010 by coding. And the following is the code snippets:
using System.Web.Configuration;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using (SPSite specifiedSite = new SPSite("You specified web url"))
{
using (SPWeb specifiedWeb = specifiedSite.OpenWeb())
{
// Enable anonymous access on web application
SPUrlZone urlZone = SPUrlZone.Default;
SPWebApplication specifiedWebApplication = specifiedSite.WebApplication;
SPIisSettings iisSettings = specifiedWebApplication.IisSettings[urlZone];
iisSettings.AuthenticationMode = AuthenticationMode.Windows;
iisSettings.AllowAnonymous = true;
specifiedWebApplication.Update();
// Enable anonymous access on website
specifiedWeb.AnonymousState = SPWeb.WebAnonymousState.On;
specifiedWeb.AnonymousPermMask64 = SPBasePermissions.Open |
SPBasePermissions.ViewPages | SPBasePermissions.ViewListItems;
specifiedWeb.Update();
// Enable anonymous acces on list
SPList specifiedList = specifiedWeb.GetList("You specified list url");
specifiedList.AnonymousPermMask64 = SPBasePermissions.ViewListItems |
SPBasePermissions.AddListItems | SPBasePermissions.EditListItems |
SPBasePermissions.DeleteListItems;
specifiedList.Update();
}
}