Skip Ribbon Commands
Skip to main content
Welcome to the SharePoint Foxhole > SPFoxhole Blog > Posts > New in SP2 Get/Setsitelock Whodathunkit!
New in SP2 Get/Setsitelock Whodathunkit!

In the last post (New In SP2 Changes in Backup Operations) I went over how you can use GetSiteLock and SetSiteLock when you are working with backups.  Thinking a bit further on these  extensions i decided to do some more testing on some scenarios.   Thanks to my good friend for additional feedback and suggestions about these additions.

So Marianne asked me if the setsitelock could be used for other purposes besides during backup operations.  For instance for site archive as an example.  YES!!  This set some of my remaining brain cells to motion thinking up how this would be leveraged in a companies environment.  

Example

A company has multiple organizations that it owns and for some reason one of those companies goes under.  The information that was listed on that companies site is still something that other employees want to consume but we don't want any more data being posted to this or have any changes made.   Couple fixes come to mind to solve this.  We can change the sites security permissions giving everyone read access.   This, depending on the complexity of the sites security, can take a great deal of time.  We could also archive the data someplace else (perhaps on another portal thats being used for Archive or DR purposes)….both take time and are not alot of fun.  OR we can run a simple command and in one sweep render the site in 3 different states using the new command line tool setsitelock. 

stsadm.exe –o setsitelock –url http://portal2.sharepoint.com/sites/companya –lock (see below examples)

  • Noadditions: Permits changes that reduce the size of the data.

    For example, if you had an announcement list item whose body consisted of 50 characters, you could successfully edit the list item so that the body was reduced to 25 characters. However, if you tried to edit the list item so that they body was increased to 100 characters, that would be blocked.

# On my testing of this switch I set my site collection to –lock Noadditions and tried to add some content to an existing announcement.  I got an access denied message.  If however i wanted to modify what was already in the announcement without adding additional characters this worked fine.   So you can modify but you cant add is what this switch is doing

  • Readonly: Sets the site collection to read-only.

  • Noaccess: Sets the site collection unavailable to all users.

* Above explanations of parameters copied from Technet  http://technet.microsoft.com/en-us/library/cc262811.aspx

So in this scenario I want to just allow employees to read what is already on the site. 

stsadm.exe –o setsitelock –url http://portal2.sharepoint.com/sites/companya –lock readonly

shot1

shot3

So what are the affects of running this and then looking at a site?   My user account on this particular site collection is SCA.  Normally i can do anything i want to this site. Now look at what i can do:

shot2 

As opposed to me opening this site without the –lock readonly applied:

 

shot5

This switch doesn't just stop at your libraries and such.  Its a collection wide change.   You can enter into Site Actions and view to your hearts content but no changes will be allowed.

 

Hope you found something useful in this post  :)

Cheers

 

Technorati Tags: ,,,

Comments

Muhanad Omar

Great post Bob!!
Bob Fox at 5/4/2009 4:36 PM

John Ross

Have you tried testing with a user that's not a SCA? In the past when I've tried to use setsitelock -noadditions it locked all users out who weren't SCAs. I haven't tried with SP2 but had observed this behavior with 3 separate clients.
Bob Fox at 5/4/2009 4:36 PM

Bob

Sure.  Today.  Worked fine.  Tested adding some additional content with the -noaddtions and it did what it was supposed to. ALso allowed me to remove some content from a announcment (shortening) and that also worked as expected.  AFAIK this was new to SP2.  Dont remember this being part of any previous updates.  I could have missed that but looking at the new documentation and talking to some peeps inside this is pretty much new.
 
Ping me offline and let me know what you find with this SP2 release
Bob Fox at 5/4/2009 4:36 PM

Add Comment

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Your Name *


E-Mail


Comment *


Todays Date *

Select a date from the calendar.

Attachments