none
[SharePointOnline 2013] The file [filename] is locked for exclusive use by [account-name]

    Question

  • I have encountered a problem when I try to delete a file on OneDrive for business (office 365) using CSOM program, it is about exclusive lock on SharePint.

    Here is the error message:

    The file [filename] is locked for exclusive use by [account-name]

    Here is the scenario:

    I have two account on office 365rainbow is the GA, rainbow_1 is a normal user. And I have added rainbow as administrator in rainbow_1’s OneDrive for business. It means rainbow have full control permission of rainbow_1’s onedrive for business.

    • Raibow_1 receive a mail which contain a file in outlook

    • Then  I try to save this file in rainbow_1’s OneDrive for business

    • Then I try to delete this file using rainbow’s credential, but it return this error message

    The file [filename] is locked for exclusive use by [account-name]

     

    Here is the information about this error, but it is all about On-premise SharePoint but not SharePoint Online(office 365)

    Root Cause:

    When users edit the document in client applications such as Microsoft Office, SharePoint places a locks and renews it for every 10 minutes to prevent other users from modifying it. This lock is released automatically when the client application is closed, or after 10 minutes.

    Solution:  

    But in some scenarios, lock retains due to reasons like: Client application crash, Network connectivity issues, etc.  So, the simplest solution would be wait for 10 minutes for the lock to expire. But if you want the lock to be released immediately, You can unlock it programmatically!

    Read more: http://www.sharepointdiary.com/2014/12/the-file-FILEURL-is-locked-for-exclusive-user-by-USER.html#ixzz3VNXjp2sL

     

    Here is my research :

    1. After testing, I found 10 minutes is not accurate.

    Rainbow_1 upload the file in onedrive for business through ipad, but rainbow still can not delete the file after 10 minutes.

    1. I found microsoft.sharepoint.client.file does not have this properties:  file.LockType

    And does not have this method too: File.ReleaseLock

    https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.file_members.aspx

     

    My Question:

             I believe the solution above can work in SharePoint(On-premise) , but for SharePoint Online, what should I do, if I want to delete that file with rainbow credential who has full control with rainbow_1’s OneDrive for business?

             Or only I can do is waiting until the exclusive lock is released?

             Can anyone give a hand, I will appreciate that.

     

    Thanks

     



    • Edited by SimonChenTM Wednesday, March 25, 2015 7:41 AM
    Wednesday, March 25, 2015 7:35 AM

All replies

  • Hi Simon,

    If the file.releaseLock method isn't provided by CSOM microsoft.sharepoint.client, I think we can be unable to release the file lock via CSOM method programmatically, we have to wait until the exclusive lock is released.

    Thanks

    Daniel Yang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Thursday, March 26, 2015 11:04 AM
    Moderator
  • Hi Daniel,

    Thank you for your replying, i really appreciate that.

    I think MS should resolve this issue or give a workaround about exclusive lock, if SPO acts as you said.

    Or this issue will make our solution base on "OneDrive for business" complex and unefficiency , we need do start a task to try to delete the file until we can do that. and maybe this is useless, because we need to delete the file in time.

    Thanks again 

    Wednesday, April 1, 2015 2:30 AM
  • Hi Simon,

    I'm sorry for the inconvience, since this method is not provided in the CSOM currently, we cannot use it to fullfill the requirement.

    I would suggest you submit a feedback to the Office Developer Platform if there any expectation about the future version of Office 365:
    http://officespdev.uservoice.com/ 
    It is a place for customers provide feedback about Microsoft Office products. What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

    Thanks

    Daniel Yang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Wednesday, April 1, 2015 3:29 AM
    Moderator
  • Hi Daniel,

    As i know, there is a property of ExchangeService , this is the detail info:

    The application can change the ImpersonatedUserId property to impersonate multiple accounts

    This is the example:

     

    void ImpersonationSample() { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new NetworkCredential(appName, appPassword, emailDomain); service.AutodiscoverUrl(appEmail); service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, user1Email); Folder newFolder = new Folder(service); newFolder.DisplayName = "TestFolder1"; newFolder.Save(WellKnownFolderName.Inbox); service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, user2Email); Folder newFolder2 = new Folder(service); newFolder2.DisplayName = "TestFolder1"; newFolder2.Save(WellKnownFolderName.Inbox); }

    read this link if you want to know detail info:

    https://msdn.microsoft.com/en-us/library/office/dd633680%28v=exchg.80%29.aspx?f=255&MSPPError=-2147217396

    So, is there similar API or method to do impersonate in sharepoint online ?

    BR

    Wednesday, April 15, 2015 8:58 AM