In this article we will be seeing how to lock or unlock site collections in SharePoint 2010. Introduction: To prevent users from adding the contents or updating the contents to the site collection you can apply locks to a site collection. And also to prevent users from accessing the site collection temporarily you can apply locks to a site collection. Site Lock Information: To view the current lock status or to change the lock status go to Central Administration => Application Management => Site Collection => Configure quotas and locks. You could see the lock status as shown in the following Locking Options: The following are the locking options available in SharePoint Server 2010.
Not locked - Unlocks the site collection and makes it available to users. Adding content prevented -Prevents users from adding new content to the site collection. Updates and deletions are still allowed. Example: When you try to add content to the site collection you will be getting the error. I tried adding word document to the Shared Documents I was getting the following error. Read-only (prevents additions, updates, and deletions) - Prevents users from adding, updating, or deleting content. Example: You won't be getting an option to add, update or delete the contents. I tried deleting the document from Shared documents but the options were disabled in the ribbon interface and I was not able to find the options in the ECB menu. No access -Prevents users from accessing content. Users who attempt to access the site receive an access-denied message. Example: When you try to access the site collection you will be getting the following error. Lock or Unlock site collection using object model:
Adding content prevented: SPSite.WriteLocked property is used to enable "Adding content prevented" option. It is used to get or set a Boolean value that specifies whether the site collection is locked and unavailable for Write access. using (SPSite site = new SPSite("http://serverName:22222/sites/test")) { site.WriteLocked = true; site.LockIssue = "Testing Purpose"; } Note: Refer SPSite.WriteLocked for more details. No access: SPSite.ReadLocked property is used to enable "No access" option. It is used to get or set a Boolean value that specifies whether the site collection is locked and unavailable for Read access. using (SPSite site = new SPSite("http://serverName:22222/sites/test")) { site.ReadLocked = true; site.LockIssue = "Testing Purpose"; } Note: Refer SPSite.ReadLocked for more details. Read-only (prevents additions, updates, and deletions): SPSite.ReadOnly property is used to enable "Read-only (prevents additions, updates, and deletions)" option. It is used to get or set a Boolean value that specifies whether the site collection is read-only, locked, and unavailable for write access. using (SPSite site = new SPSite("http://serverName:22222/sites/test")) { site.ReadOnly = true; site.LockIssue = "Testing Purpose"; } Note: Refer SPSite.ReadOnly for more details. Lock or Unlock site collection using powershell:
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: