.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to make a Site Collection Read-Only in SharePoint

Posted By:Jean Paul       Posted Date: June 30, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article, we can explore how to make a Site Collection read-only in SharePoint
 

In this article, we can explore how to make a Site Collection read-only?

Why making Site Collection Read-Only?

During phases like development, requirement cut off, release the Administrator might require to make the Site-Collection read-only to prevent future add/edit/delete of contents.

What are the ways to make Site Collection Read-Only?

We can employ the following ways:

1. Central Administration by Administrator

2. PowerShell by Administrator

3. Server Object Model by Developer

Depending on the requirement, we can use the above 3 ways.

Let us explore all the 3 ways.

Create Site Collection

For playing with, I prefer you create a new site collection from Central Administration.

clip_image001

In the appearing page, enter the site collection details.

clip_image003

Open the site & ensure you can add contents.

clip_image005

Option 1: Making Read-Only through Central Administration

Go to Central Administration > Application Management > Configure quotas and locks

clip_image007

In the appearing page, choose the site collection & select the option Read-only.

clip_image009

Enter the lock information & Click the Ok button to continue.

Testing Read-only

Now we are ready to test the read-only functionality. Open the site collection main site & try adding a document. You should see the following error message.

clip_image011

This makes sure that you cannot add/edit/delete contents. The site is read-only.

Unlocking

Please go back to the Central Administration Lock Page & choose the Not locked option.

clip_image013

Now the site collection will be back to writeable mode.

Option 2: Making Read-Only through PowerShell

Now let us try the PowerShell option. Open SharePoint enabled PowerShell from start menu.

clip_image014

Enter the following command for locking the SharePoint site collection by URL.

Set-SPSite -Identity "http://hp/sites/sc2? -LockState "ReadOnly"

Testing Read-only

Open the site collection main site & try adding a document. You should see the same error message.

clip_image015

This confirms the site collection is now read-only.

Unlocking

No make the site back to writeable, use the following code in PowerShell window.

Set-SPSite -Identity "http://hp/sites/sc2? -LockState "Unlock"

Now the site collection will be back to writeable mode.

Option 3: Making Read-Only through Code

Now we can try the Server Object Model way of making site collection read-only.

Create a new console application, add reference to Microsoft.SharePoint assembly & execute the following code.

SPSite site = new SPSite("http://hp/sites/sc2?);

site.ReadOnly = true;

Testing Read-only

Open the site collection main site & try adding a document. You should see the following error message.

clip_image011[1]

This confirms the site collection is now read-only.

Unlocking

No make the site back to writeable, use the following code.

SPSite site = new SPSite("http://hp/sites/sc2?);

site.ReadOnly = false;

Now the site collection will be back to writeable mode.

clip_image017

Please note that there are 3 lock options:

· Read-Only where add/edit/delete of contents are prevented

· Adding content prevented where adding is prevented, but edit/delete is still possible

· No Access where even reading is prevented.

clip_image018

References

http://technet.microsoft.com/en-us/library/ff631148(v=office.14).aspx

Summary

In this article we have explored a real world scenario of making site collection read-only, through multiple options possible.


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend