Much like everything I blog about, I had a requirement from a customer to programmatically set the "Show and Hide Ribbon" setting that is seen within the Navigation configuration page off of Site Settings (a.k.a. the _layouts/AreaNavigationSettings.aspx page). I looked all through the SPWeb.Navigation options and the PublishingWeb.Navigation options and couldn't find it. Then I remembered the oldest trick in the book, decompiling SharePoint! I brought up the Microsoft.SharePoint.Publishing.dll in Telerik JustDecompile and found the codebehind implementation for the page. Once there it was easy to figure out how to make the change. Fast-forward, here it is:

SPWeb web = null;
// works better if you actually set this to a valid instance
// so this property, the __DisplayShowHideRibbonActionId, doesn't exist unless it's set to No!
// so in this instance we are setting it to No, but if you want to set it to Yes you just
// want to clear the value for the property.  make it string.Empty, or just delete the
// property entirely.
web.AllProperties["__DisplayShowHideRibbonActionId"] = "False";
// Update your web, do a jig.
web.Update();