Monday, 26 March 2012

How to check programmatically if current user can edit a document stored in SharePoint?
 


Programmatically check current user can edit documents in document library




public static bool CanEditDocument(string DocumentURL)
        {
            if (string.IsNullOrEmpty(DocumentURL)) return false;
            using (SPSite tempSite = new SPSite(DocumentURL))
            {
                if (tempSite == null) return false;
                using (SPWeb tempWeb = tempSite.OpenWeb())
                {
                    SPFile Doc = tempWeb.GetFile(DocumentURL);
                    if (Doc == null) return false;
                    if ((Doc.Item.EffectiveBasePermissions &
                      SPBasePermissions.EditListItems)
        == SPBasePermissions.EditListItems)
                        return true;
                }
            }
            return false;
        }
How to check programmatically if current user can edit a document stored in SharePoint?
 
How to check programmatically if current user can edit a document stored in SharePoint?
 

No comments:

Post a Comment