Set No access (ReadLocked) Programmatically for a Site Collection (SPSite)

SPUser

user = SPContext.Current.Web.CurrentUser;
//NOTE: The account which runs the application pool needs to be a farm administrator
SPSecurity.RunWithElevatedPrivileges(delegate()
{

using (SPSite site = new SPSite("Your Site Utl"))

   {

     site.WebApplication.FormDigestSettings.Enabled = false;
     site.AllowUnsafeUpdates = true;
     site.WriteLocked = false;
     site.ReadOnly = false;
     site.LockIssue = "The site was disabled by: " + user.Name + " (e-mail: " + user.Email + ")";
     site.ReadLocked = true;

   }

});

Previous
Next Post »
1 Komentar
avatar

Hi alon.

Thanks for the detailed explainantion. But i am checking thro object model is it possible to set the Readonly property to false(Assumption site has been locked)

Balas