Saturday, 7 July 2012

SPUnlock Tool "The file is locked for exclusive use by"

The file ""  is locked for exclusive use by domain\user
Normally you will get this when file from SharePoint library is in use in by any user in client applications that's as expected. But due to many reasons  this lock never get released even  when you are not using this file. 

SharePoint Lock and Checkout
 SharePoint lock are not same as item checkout. 

 is when user  perform through SharePoint UI for via programatically to edit a file 
 Checkout type
       Online :- The file is checked out for editing on the server.
     Offline :- The file is checked out for editing on the local computer.

Lock Type
When user open a document  in edit mode  in office client SharePoint Creates a short term  lock ( 10 min)  on the file, preventing other users from modifying it. this lock get renew by office client after every 10 min.
Lock Type 
        Exclusive: - The file is locked for editing by a single user. No other user can modify the file until the lock is released.
     Shared:- The file is locked for editing by a group who are using a collaborative application. Other users are prevented from modifying the file until the lock is released.

Note:- The checkout state of a file is independent of its locked state

Solutions for Sharepoint Accidental Lock 

  1. Wait for 10 min for lock to expire (this is true in 80 % of cases)
  2. Quick solution is to  reset  share point server ( not always feasible )
  3. Use a codeplex tool to unlock these file SPUnlock  (

SPUnlock Tool
Its a Sandbox based solution developed by me as an additional nice to have tool while working/ supporting  project issues where files get locked by user for some reason .

SPUnlock Tool Setup
  1. Download SPUnlockSandbox.wsp from
  2. Upload  SPUnlockSandbox.wsp to SP Site Collection Solution Gallery ( http:///sites//_catalogs/solutions/Forms/AllItems.aspx)
  3. Activate solution from solution gallery
  4. Confirm above step activate a  sitecollection feature "SPUnlockSandbox_Feature1" .
  5. Navigate to you site or any subsite  where and add webpart "SPFile Unlock"  to any page.
and there you go with this simple but useful tool 


Savlin said...

Very usefull feature!
Thank you so much!

Anonymous said...

Thanks for this tool but after I installed/activated and added to a web part page, I get the following error after I populate the "Document URL" field (with either: OR and then clicking either the "Get Lock Info" or the "Un-Lock File" button:

StartException :- Value does not fall within the expected range.Stack Trace:-

Server stack trace:
at Microsoft.SharePoint.SPWeb.GetWebRelativeUrlFromUrl(String strUrl, Boolean includeQueryString, Boolean canonicalizeUrl)
at Microsoft.SharePoint.SPWeb.GetFile(String strUrl)
at Microsoft.SharePoint.SPWeb_SubsetProxy.GetFile__Inner(String strUrl)
at Microsoft.SharePoint.SPWeb_SubsetProxy.GetFile(String strUrl)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.SharePoint.SPWeb_SubsetProxy.GetFile(String strUrl)
at Microsoft.SharePoint.SPWeb.GetFile__Inner(String strUrl)
at Microsoft.SharePoint.SPWeb.GetFile(String strUrl)
at SPUnlockSandbox.SPFileInfo.SPFileInfo.btnUnLockInfo_Click(Object sender, EventArgs e)

Have you seen this before? Does the tool work with only certain types of Office files (like Word only?).
The tool is installed and activated at the site collection level.

Thanks in advance

VJ said...

"Value does not fall within the expected range" With this error message i think URL to document is not correct.
1. Make sure to add the webpart to same site/sub site where you have document library
2.this works with any type of file in SharePoint library.

EnoNomi said...

I'm getting the message Is Locked Byi:USERNAME and can only be UnLocked by same user.

This would be more usefull if it didn't need to be unlocked by the user (part of the reason for the need of the tool is that person isn't available to do the unlocking.) Otherwise this looks like it could be very usefull and was easy to install.

Unknown said...
This comment has been removed by the author.
Unknown said...

Thank you for a great, but I get the notice -
Start Is Locked ByDOMAIN \ LOGIN and can only be UnLocked by same user.
What could it be?


Anonymous said...

I have uploaded the Unlock Tool but i can't activate it. Help!

VJ said...

This solution is a sharepoint sandbox solution . due to security restriction you cannot write a code which can imporsonate other users to unlock someone else lock .

this was initially desiged to unlock files get locked by me accidentaly .

to ebableunlock files locked by anyone else we need to deply it as farm solution

Vicky said...

This is great Vijay. Thanks!!. This also worked on Office 365 (SP 2013).
Can you please provide me the source code to this.
my email is

VJ said...

You can get source code from codplex

Anonymous said...

Users for our collaboration application faced the same issue frequently where some users used to leave file opened.

I provided an option Release Lock in each item's context menu to release the lock.

if (!string.IsNullOrEmpty(report.LockId))
{ report.ReleaseLock(report.LockId);

Users happy everybody happy. Cheers.

Anonymous said...

Solution is working fine, But After uploading to solutions gallery and activating it. we are Unable to open the Work flows in share point designer getting error "Unable to load workflow actions from the server. Please contact your server administrator". It became a big issue for us.

Guruprasad Marathe said...

does it work for 2013 version? i am gettng below error while adding web part
The site collection containing this sandboxed solution has exceeded its daily resource usage quota

VJ said...

@Guru You can deploy it as farm solution it will not have quota limit

CGreenTX said...

Any plans to update this to the add-in model so it will work on Office 365 again? Microsoft has disabled all sandboxed code in late 2016.