SPS2003 Lock site using command line: SPSiteManager

yeah yeah, if you are used to working with MOSS, then you will probably tell me to use the command stsadm -o setsitelock -url <url> -lock readonly or something like that.

Unfortunately back in the SharePoint Portal Server 2003 and WSS 2.0 days, this operation was no yet available with stsadm…..along with a lot of other usefull commands

I needed to lock the sps 2003 sites in a gradual upgrade project to MOSS. Of course I want to script the complete migration, which also includes locking the SPS site before starting the upgrade.

Searching the web, I found my way to the SPSiteManager project on Codeplex 

In addition to the opeartions I was looking for, you also get the following operations:

Operation

Description

analyze

Enumerate all Content Database information and generate a Site Distribution Document

repartition

Re-partition sites to different content databases

enumsites

Enumerate Site Collections

Enumsitecrawl

Enumerate URL references from the list of sites to crawl

Enumsitedirectory

Enumerate URL references from a portals site directory

enumdatabases

Enumerate Content Databases

backup

Backup site(s)

restore

Restore site(s)

deletesite

Delete site(s)

adddatabase

Add content databases to a virtual server

addfromcrawl

Add site(s) to list of sites to crawl for SharePoint Portal Server 2003

removefromcrawl

Remove site(s) to list of sites to crawl for SharePoint Portal Server 2003

addfromdirectory

Add site(s) to Portal Server 2003 Site Directories

removefromdirectory

Remove site(s) to Portal Server 2003 Site Directories

locksite

Lock site(s)

unlocksite

Unlock site(s)

resetquota

Reset quotas on site(s)

purgeversions

Purge document versions from document libraries

Although these operations look a lot like the ones we get with MOSS, nowadays, they actually are much better. For example the operation to backup a site will actually also lock the site for read/write for you and unlock it when done. So before using this tool with all the operations, be sure to check out the well written manual that is included explaining each operation.

 

6 thoughts on “SPS2003 Lock site using command line: SPSiteManager

  1. Hello Jayvardahn Patil,

    I remember when I first used the SPSiteManager tool, I encountered an undesired effect, which was that the site was both locked Read and Write, resulting in no access at all. My users still needed access to the SPS2003 site, but in read-only mode.

    If this is also the case with you, you may try to edit the AppClass.cs file in the source code and look for the following peace of code:

                   private static void SetSiteLockState(JobSettings js, bool bLocked)
                   {
                         Logging.Information(“===================================================”);
                         Logging.Information(“Setting site lock state”);
                         Logging.Information(“===================================================”);
                         Logging.Information(”       Site: ” + js.SourceUrl);

                         SPSite site = js.GetSite();
                         site.ReadLocked = site.WriteLocked = bLocked;
                         site.Close();
                         site.Dispose();
                    }

    Next ,change the line:

    site.ReadLocked = site.WriteLocked = bLocked;

    To:

           site.WriteLocked= bLocked;

    Save the file, then run the BuildSPS batch file to generate the executable (run this on a SharePoint server as it requires the SharePoint dll)

    Good Luck

    Dirk Van den Berghe

    SharePoint Blog: http://www.dirkvandenberghe.com

  2. There was a specific reason for both write AND read locking the site. THought I had placed the comment for it in the code, and trying to find the information now, but let’s just say, it can get things out of sync when backing up a 2.0 site if you don’t read AND write lock it.
    I don’t recommend only write locking it when backing up (For 2.0 that is)

  3. Hello

    I used and tested the tool for locking and unlocking SharePoint 2003 sites. It is a great tool and served my purpose. Now I am stuck in one place. I have following type of site hierarchy
    /Topsite/subsiste1/subsite11/subsite111/subsite1111

    Is ther any way that I can only lock subsite111 only. I run the spsitemanager command but it is locking site from topsite to low level site. Please let me know how can I do this, is it possible?

    I also noticed that in SP2003 Central Admin, you can only lock top level site not any subsite.

    Thanks
    Avian

Leave a Reply

Your email address will not be published. Required fields are marked *