Tuesday 9 December 2014

Site Collection Locks in SharePoint 2010


Some time back, I ran into a issue where a particular site collection was in read-only mode to every one including site collection admin, certain options such as site action menus were in disabled state!. Then I realized site collection backup process was interrupted due to disk-space issue and it left the site collection in "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 2010 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
Lets 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 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:
Set-SPSite -Identity <Site-collection-url> -LockState <Lock-State>

Where: <Lock-State> can be:
  •     ReadOnly
  •     Unlock
  •     NoAdditions
  •     NoAccess 
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";
            }

PowerShell To Handle 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 exceeds the Site collection Quota!

Backup LIVE Site collection with out 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: http://salaudeen.blogspot.com/2012/12/check-lock-status-for-all-site.html
Reference:

http://www.sharepointdiary.com/2012/05/site-collection-locks-in-sharepoint.html

1 comment:

  1. http://camaragenbandarq.blogspot.com/2017/05/membahas-macam-macam-judi-di-indonesia.html
    http://agenbandarqcamarqq.blogspot.com/2017/05/mengetahui-4-tempat-judi-termewah-di.html
    http://agendomino99camarqq.blogspot.com/2017/06/trik-curang-main-bandarq.html
    http://agendominocamar.blogspot.com/2017/06/mengetahui-warnet-di-jepang-yang.html
    http://agendominocamarqq.blogspot.com/2017/06/cara-mendaftar-di-shioqq-situs-agen.html
    http://www.jakartatercinta.com/2017/05/mengenal-situs-shioqq-agen-bandarq.html
    http://www.jakartatercinta.com/2017/05/shioqqnet-agen-bandarq-yang-memberi.html

    ReplyDelete