Blog Site in Anonymous Use

December 22 2010 119 comments

Anonymous user cannot enter a blog entry in a SharePoint site if ViewFormPagesLockDown feature is active at site collection level and ViewFormPagesLockDown feature is active if site collection is based on publishing portal. After googling we came accross plenty of resources considering this matter:

We didn’t want use the solutions suggested in the links above. To disable the ViewFormPagesLockDown “…leaves you wide open from a security perspective…”. To have our blog site in another site collection. Well that’s just not what we want to do to solve this tiny little thing with permissions.

Me and Aapo dug with reflector into ViewFormPagesLockDown feature and found out what the feature receiver does.

The highlighted sections of the feature receiver show what happens to Guest’s permissions at rootweb level when you disable ViewFormPagesLockDown site collection level feature.

So why not just take the solution from where it is and develop a web scoped feature which does the exactly same thing to the blog site but not to all webs in the site collection because that’s not what we want.

Develop a feature receiver as follows:

using System;
using Microsoft.SharePoint;

namespace My.Assembly
{
    public class FormPagesLockDownReleaseReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties
        properties)
        {
            using (var web = (SPWeb)properties.Feature.Parent)
            {
                var anonymousState = web.AnonymousState;
                // continue only if anonymous use is enabled
                if (anonymousState == SPWeb.WebAnonymousState.Disabled)
                    return;
                web.AllowUnsafeUpdates = true;
                 // break inheritance to set permissions per site
                web.RoleDefinitions.BreakInheritance(true, true);
                // permission granting from LockDownViewFormPages
                var byType = web.RoleDefinitions.GetByType(SPRoleType.Guest);
                byType.BasePermissions |= SPBasePermissions.EmptyMask |
                SPBasePermissions.ViewFormPages;
                byType.BasePermissions |= SPBasePermissions.UseRemoteAPIs;
                byType.Update();
                // reset the anonymous state programmatically
                web.AnonymousState = SPWeb.WebAnonymousState.Disabled;
                web.AnonymousState = anonymousState;
                web.Update();
                web.AllowUnsafeUpdates = false;
            }
        }
    }
}

Resetting the anonymous state is just a thing you would have to do from UI when you toggle permissions. Lockdown Mode in SharePoint 2010: “If anonymous is already setup, you may need to disable\re-enable anonymous on the site.”

Then a web scoped feature that consumes the receiver:

<?xml version="1.0" encoding="utf-8" ?>
<Feature  
  Id="{6189C7B4-6FDC-4BAA-95FD-03DD318031E5}"
  Title="Blog Anonymous Access Staplee"
  Description="Enables Anonymous Access to Blog Entries"
  Scope="Web"
  ReceiverAssembly="My.Assembly,
  Version=1.0.0.0,
  Culture=neutral,
  PublicKeyToken=e3e48257ada349c4"

  ReceiverClass="My.Assembly.FormPagesLockDownReleaseReceiver"
  Hidden="FALSE"
  xmlns="http://schemas.microsoft.com/sharepoint/">
</Feature>

You could set the feature hidden to avoid accidental feature activations.

Then a stapling mechanism at site collection level to staple the feature to Blog sites by default.

Stapling.xml

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!--BLOG#0-->
      <!--Staple FormPagesLockDownReleaseReceiver to Blog sites -->
      <FeatureSiteTemplateAssociation
    Id="6189C7B4-6FDC-4BAA-95FD-03DD318031E5"
    TemplateName="BLOG#0" />
</Elements>
<?xml version="1.0" encoding="utf-8" ?>
<Feature
    Id="{7DF309A4-7E3B-488A-9D2A-F3B88D656465}"
    Title="Blog Anonymous Enabling Stapler"
    Description="Staples Anonymous Access to Created Blog Sites"
    Version="1.0.0.0"
    Scope="Site"
    xmlns="http://schemas.microsoft.com/sharepoint/"
    ActivateOnDefault="FALSE">
    <ElementManifests>
        <ElementManifest Location="Stapling.xml" />
    </ElementManifests>
</Feature>

Voila, you have a mechanism to allow viewing form pages only in blog sites when you activate the stapler feature at site collection level. Of course, if you want, you could even set the needed permissions at list level in the Blog site, I suppose, but that’s not what we’ve done here.

Popularity: 4% [?]

119 comments to “Blog Site in Anonymous Use”

  1. Anne says:

    Great content, excellent! towing service

  2. James A says:

    I went through this website and found it very impressive. Keep sharing. Middle River Tow Truck

  3. Calum S says:

    Well written content. Thank you for sharing. tow truck

  4. Katy says:

    Interesting piece, thanks for sharing! tow truck

  5. Andrew says:

    Well done on this post towing service

  6. Taylor says:

    This is an interesting article. tow truck

  7. mshahid says:

    You might comment on the order system of the blog. You should chat it’s splendid. Your blog audit would be swell up your visitors. I was very pleased to find this site. Scott Dietrich Gainesville VA

  8. Roanoke says:

    You did a great job on this excellent site tow truck

  9. Staunton says:

    I am glad seeing this nice website. towing service

  10. Keep sharing great post, I like them. tow truck

  11. Waynesboro says:

    I personally like your post towing service

  12. Winchester says:

    I’m really impressed with your article tow truck

  13. Kissimmee says:

    Thanks for sharing this! This looks pretty informative! towing service

  14. Orlando says:

    This is an impressive and informative site. Keep it up tow truck

  15. Sanford says:

    Thanks for sharing this! This is very insightful! towing service

  16. Thanks for this information. I appreciate it tow truck

  17. Chesapeake says:

    Content is really nice, it is well written. towing service

  18. Hampton says:

    To me this a is very nice site. tow truck

  19. Glad to see this awesome post here.

  20. Thanks for sharing this awesome information.

  21. Fence says:

    “Never give up, for that is just the place and time that the tide will turn.” – Harriet Beecher Stow Fencing Company Whetstone

  22. Fence says:

    “Don’t let yesterday take up too much of today.” – Will Rodgers Fence Installation Services Childs Hill

  23. RR says:

    “You can make something of your life. It just depends on your drive.” – Eminem Rubbish Removal Amblecote

  24. RR says:

    “Take up one idea. Make that one idea your life. Think of it, dream of it, live on that idea. Let the brain, muscles, nerves, every part of your body, be full of that idea, and just leave every other idea at home. This is the way to success.” – Swami Vivekananda Junk Removal South Hackney

  25. RR says:

    “How wonderful it is that nobody need wait a single moment before starting to improve the world.” – Anne Frank Waste Collection World’s End

  26. Tile says:

    “Nothing is impossible, the word itself says “Im possible!”” – Audrey Hepburn Commercial Tilers Whitechapel

  27. Property says:

    “The future depends on what you do today.” – Mahatma Gandhi Structural Survey Frognal

  28. Towing says:

    “Even when I was close to defeat, I rose to my feet.” – Dr. Drev Tow Truck Chadwell Heath

  29. Fencing says:

    “What if I fall? Oh, but my darling, what if you fly? – Erin Hanson Fencing East Finchley,

  30. Fencing says:

    “Every strike brings me closer to the next homerun.” – Babe Ruth Fence Fitter Lower Clapton

  31. Great Blog. Thanks for sharing your thoughts about your blog post. I look forward to more blog posts from you.

  32. Carrie says:

    This can surely help people who want to learn to code. https://www.richmondrubbishremovalpros.com/

  33. Albert says:

    This can be used as a resource for learning to code. rubbish removal Mill Meads

  34. Victoria says:

    Coding would be easier with the help of online resources. car tow Shadwell

  35. Rozette says:

    Thanks for the time and effort that you put into publishing this. fence contractors WEHM

  36. Cury says:

    I appreciate people who love to share their knowledge. windscreen repair Dalston

  37. Ram says:

    Someone would be happy to see this type of article. windshield service Swale

  38. John Hartman says:

    Thanks for these details. Find out more info at this site http://www.a1treeservicespokane.com

  39. Anonymous web browsing refers to the utilization of the World Wide Web that hides a user’s personally identifiable information from websites visited.

  40. here says:

    That is why Facebook advertisements specialists
    are high in demand.

  41. Our Cast Iron Square Collars and Bushes are known for high-quality durability.

  42. I found many interesting things on this site. Great site! Fredericksburg Lawn Care

  43. Tree Service says:

    Good content with interesting intent! keep it up

  44. Today, Culpeper Tow Truck is one of the top towing companies in the state and can provide a wide range of towing and roadside assistance services.

  45. Sexomercado says:

    Sexomercado tiene un aspecto limpio y elegante, para que puedas navegar por el perfil de cualquier escort con facilidad. Además, puedes utilizar los filtros para una búsqueda avanzada.

Leave a Reply