Site Collection Locks in SharePoint

Some time back, I ran into an issue where a particular site collection was in read-only mode to everyone including site collection admin, certain options such as the site action menu was in the disabled state!. Then I realized the site collection backup process was interrupted due to the disk-space issue, and it left the site collection in the “Read-only” mode! Which was documented in my post: SharePoint site is read-only to everyone

Screenshot from Read-only locked Site collection: Note that ribbon items are disabled!

SharePoint Ribbon controls are disabled in a Read-only locked Site collection

Screenshot from Unlocked site:

SharePoint Ribbon controls Enabled in a Normal SharePoint Site collection

SharePoint Site Locks can be Set/Reset in 4 ways:

  1. Using Web User Interface – Through Central Administration
  2. Using STSADM 
  3. Using PowerShell
  4. Using Object Model
    1. By .Net code
    2. By PowerShell

Let’s look at the examples:

Using Web User Interface:
Where to Look? Go to Central Administration > Application Management > Configure Quotas and Locks

SharePoint 2010 Site Collection Quotas and locks

Under Site Collection Quotas and locks, set the site collection to “Not locked” will release the site.

Setting SharePoint 2010 Site Collection Quotas and locks

STSADM to lock a SharePoint Site Collection:

To lock site collection:
stsadm -o setsitelock -url <Site-collection-url> -lock <Lock-Type>

To get site lock status information of SharePoint site collection:
stsadm -o getsitelock -url <Site-collection-url>

Where <Lock-Type> can take one of the following value:

  • none  – Removes all the locks
  • noadditions  – Prevents from Addition
  • readonly – Can’t add/Update/Delete content
  • noaccess – You can’t view the site at all

More info: http://technet.microsoft.com/en-us/library/cc262811.aspx

PowerShell to Set Site collection Lock:

To lock a site collection in SharePoint 2013 using PowerShell, use:

Set-SPSite -Identity <Site-collection-url> -LockState <Lock-State>

Where: <Lock-State> can be:

  •     ReadOnly
  •     Unlock
  •     NoAdditions
  •     NoAccess 

PowerShell to Manage SharePoint Site Collection Locks:

$SPSite = Get-SPSite -Identity http://SharePoint
#Check whether the site collection is read-only
$SPSite.readonly
#Remove the site collection's read-only lock
$SPSite.readonly = $false

SharePoint 2010 Site Collection Quotas and locks using PowerShell, Stsadm, Object Model
BTW, SharePoint Site collections may be locked automatically, when they exceed the Site collection Quota! More Info: http://technet.microsoft.com/en-us/library/cc263238.aspx

SharePoint Site Collection Locks Programmatically with Object Model:
You can Programmatically set the Lock status using SPSite object’s Properties:

  •     SPSite.ReadLocked
  •     SPSite.WriteLocked
  •     SPSite.ReadOnly

E.g:

using (SPSite site = new SPSite("http://sharepoint.com/sites/sales"))
{            
	site.ReadOnly = true;
	//Set lock comments
	site.LockIssue = "Maintenance";
}

Tail: Backup LIVE Site collection without Locks:

STSADM:   stsadm -o backup -url <Site-collection-url> -filename <Backup-File> -nositelock
PowerShell: Backup-SPSite -Identity <Site-collection-url> -Path <Backup-File> -NoSiteLock

PowerShell Script to check lock Status of All site collections: Check Lock Status for All Site Collections in SharePoint

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

10 thoughts on “Site Collection Locks in SharePoint

  • December 11, 2017 at 11:05 AM

    thanks for posting it.
    thanks a lot……

    Reply
  • March 13, 2015 at 9:27 AM

    Hi Rajak thanks for your valuable info.. You had save my life. ***** 5 Star Rating for your post. 🙂

    Reply
  • March 11, 2015 at 6:44 AM

    Hi,
    Can a site made readonly using client object model?
    I get error saying that its a readonly property.
    the Code I am using is as below:

    Site mysite = mycontext.Site;
    mycontext.Load(mysite);
    mycontext.ExecuteQuery();
    mysite.ReadOnly = false;
    mysite.LockIssue = “testing”;

    Reply
  • December 9, 2014 at 8:42 AM

    Thanks for the post

    Reply
  • February 6, 2014 at 2:21 AM

    Hi Rajak thanks for your valuable info.. is there any way I can get alerted like generate an email when site collection gets locked?

    Reply
  • December 14, 2012 at 4:22 AM

    I think you saved my job today with this post, had to let you know…

    Reply
  • August 29, 2012 at 3:59 PM

    Its very useful link,

    Reply
  • June 11, 2012 at 3:39 PM

    Thanks for pointing out this frustrating occurance! Also, is the lock / unlock of a site collection logged anywhere – ULS, etc?

    Reply
    • June 12, 2012 at 12:28 PM

      Nope! Its not getting logged 🙁

      Reply
  • May 29, 2012 at 7:58 AM

    hi..You Provide a very useful information about SharePoint. Very well done. Thanks for Sharing.

    Reply

Leave a Reply