Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

SPS2003...can i programatically set a site lock?

  Asked By: Hiral    Date: May 23    Category: Sharepoint    Views: 2819

I would like to be able to programatically, via a windows
command script, set a "No Update" lock on a site. This would be the
same functionality as can be accomplished through Central Admin with
the "Site Lock Information....Adding content prevented" option.

I have seen the SPSiteManager utility and it appears to have the
ability to set a "No access" lock, but has anybody seen a way to allow
access, but prevent adding content????

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Timothy Hall     Answered On: May 23

That would be just a matter of setting the WriteLocked property of the SPSite
object to true, rather than how SPSiteManager currently does it in setting both
WriteLocked and ReadLocked to true (Which equates to no-access)

As far as a command script, you would need to go against the SharePoint object
model to accomplish this (PReferrably in a .Net application), but there is no
option for STSADM for V2 that allows you to just lock  a site  but there is in V3
(See STSADM -o setsitelock)

Over the next couple of days, I'll be posting ot my blog on a slimmed down "V2"
site lock/backup routine that you could leverage if you wanted, but since you've
already seen my SPSiteManager tool, you have the code there as well :)

I could probably whip up an extremely limited "SPLockSite" tool that mimics the
V3 STSADM -o setsitelock functionality  if there is a strong need for it, but it
would be a couple of days maybe before I could get to it.

 
Answer #2    Answered By: Ian Powell     Answered On: May 23

I would be happy with either getting a 'slimmed down v2 site
lock/backup routine' or editing the SPSiteManager code to get what i
need.

What is the correct location/version where I should grab
SPSitemanager? The version of code that I have has no reference to
WriteLocked, except in XML files that start with "tailspintoys". I
assume that one of the c# files would be setting the WriteLocked and
ReadLocked property and that is what I was looking for, to no
avail. Perhaps I have an old version.

 
Answer #3    Answered By: Osvaldo Winters     Answered On: May 23

You may have an old version, and I will be not doing further development
on SPSiteManager, see my blog for reasons why.

As for a "Slimmed" down simple site  Locking Backup tool for V2. I have
the code ready, just need to find the time to finish testing it before
releasing.

Seems to be working perfectly in my tests, but I don't like posting code
that I have not had the chance to test thoroughly


Once it's done, I'll be posting it on my blog.

The cool thing in V3 is, that there is a STSADM extension to lock  sites
now before a backup, so that means a shell script  would simply call

STSADM -o setsitelock -url http://server/sites/site1 -lock noaccess

STSADM -o backup -url http://server/sites/site1 -filename site1.bak
<http://server/sites/site1%20-filename%20site1.bak> -overwrite

STSADM -o setsitelock -url http://server/sites/site1 -lock none

You could get creative too, and call STSADM -o getsitelock -url
http://server/sites/site1 and persist the XML that's written to the
console to get the sites "Current' lock status (In case it's something
other than "none" and reset it back to that, but that would then be more
than three simple calls.

I was thinking that there would not be a need for a V3 version of this
SiteLockBackup tool I have, but perhaps to make it even easier, I may
look at converting the V2 version of it to V3 afterwards...dunno at this
time

 
Answer #4    Answered By: Kylie Gill     Answered On: May 23

stsadm -o setsitelock -url <site collection url> -lock
<none | noadditions | readonly | noaccess>

 
Answer #5    Answered By: Irving Hurley     Answered On: May 23

In v2, the site  gets locked from adding  content, but not content
changes. What we've done through the SP OM is change all site users
to only have read permissions and transfer site ownership to a service
account.

 
Didn't find what you were looking for? Find more on SPS2003...can i programatically set a site lock? Or get search suggestion and latest updates.




Tagged: