Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've created an anonymous blog subsite. My root site is also anonymous. I can access default.aspx anonymously, but not /Lists/Posts/Post.aspx?ID=1

I've tried breaking permission inheritance and have tried toggling on all anonymous access options within the Comments list and even the Posts list. When navigating to these lists, I get a 401 Unauthorized error message.

Am I missing something?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Below is the solution, however the issue of anonymous users being able to see draft items has cropped up...

SPList list = curWeb.Lists["Comments"];
// check if it has unique permissions
if (!list.HasUniqueRoleAssignments)
{
    list.BreakRoleInheritance(true);
}
// make sure people logged in can edit their own items
list.WriteSecurity = 2;
// turn on moderation
list.EnableModeration = true;
list.DraftVersionVisibility = DraftVisibilityType.Approver;
// grant permissions to anonymous users
list.AnonymousPermMask64 =
  (SPBasePermissions.Open |
   SPBasePermissions.OpenItems |
   SPBasePermissions.ViewFormPages |
   SPBasePermissions.ViewListItems |
   SPBasePermissions.AddListItems);
list.Update();
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.