Dealing with Sharepoint locked Site Collections

1.4k views Asked by At

I am playing with an application that can crawl the contents of sharepoint server. But I got a problem while working with Locked Site collections.

There are some methods that cannot be used with locked site collections. It throws an exception telling me the contents are blocked.

So I want to handle this more gracefully by checking whether a collection is locked. How can I do this?

Update : One more addition. The site collection has been locked using stsadm NOT programatically. So the SPSite.ReadLocked property has no use.

1

There are 1 answers

0
Timores On BEST ANSWER

I looked at the source code of the setsitelock command; typing

stsadm -o setsitelock -lock readonly

results in (pseudo-code):

    SPSite.ReadLocked = false;
    SPSite.WriteLocked = false;
    SPSite.ReadOnly = true;

The ReadOnly property is interesting, because it is only true when the lock is of type 'readonly'.