Saturday, August 6, 2011

Sharepoint Document library - Access denied while reading draft

In your custom code, you might have written a logic to read all documents from a document library. Sometimes you might get access denied for some files in library.

The reason behind this is the version setting of the document library, especially when you have "major & minor" versioning setting enabled. When you track major and minor versions, the major versions are whole numbers, and the minor versions are decimals. Minor versions are the draft versions, major versions are the published ones.
For example, 0.1 is the first minor version of a file, 1.4 is the fourth minor version of a file that was published once, and 3.0 is the third major version of a published file.


The version is stored by default is a minor version. When you save a file and close it, the version is tracked as a minor version. Minor versions are considered drafts that are still being developed.
You must first publish the file in order for it to become a major version. You can publish the file by using drop-down commands in a library

In your API, if lock a sitecollection and then try to read your draft document, obviously you will get "access denied", meaning, the content DB is in read only mode when the site collection is locked


The reason behind this was that, documents were never published [they were in draft mode only]. So documents have to be published with at least one major version to prevent this error.

No comments:

Post a Comment