Scenario: Created a document library which has unique permissions(doesn't inherit permissions from parent) using Object Model, and add users with Read permissions using object model.
using (SPSite site = new SPSite("http://sp13demo")) { using (SPWeb web = site.OpenWeb()) { SPListTemplateCollection collection = site.GetCustomListTemplates(web); SPListTemplate template = collection["HRTemplate"]; web.AllowUnsafeUpdates = true; Guid listGuid = web.Lists.Add("Records", "Records", template); SPList checkList = web.Lists[listGuid]; checkList.BreakRoleInheritance(false); checkList.Update(); string recordLibraryURL = checkList.RootFolder.ServerRelativeUrl; SPFolderCollection folderCollection = web.GetFolder(recordLibraryURL).SubFolders; SPFolder confidentialFolder = folderCollection.Add("Confidential"); SPFolder otherFolder = folderCollection.Add("Others"); confidentialFolder.Item.BreakRoleInheritance(false); confidentialFolder.Item.Update(); SPRoleAssignment user = new SPRoleAssignment("domain\\loginname", null, null, null); user.RoleDefinitionBindings.Add(web.RoleDefinitions.GetByType(SPRoleType.Reader)); checkList.RoleAssignments.Add(user); checkList.Update(); web.Update(); web.AllowUnsafeUpdates = false; } }
In SharePoint 2010 when you execute the above code if the user does not have access to the site, he will be provided limited access automatically by SharePoint so that user can access the document library and view documents to which he has permissions,
but this doesn't hold true any more with SharePoint 2013 RTM.
I am not sure if this is a bug or a new change or approach is required to get it working.
Any pointers from the experts will definitely help
Raghavendra Shanbhag | Blog: www.SharePointColumn.com
Please click "Propose As Answer " if a post solves your problem or "Vote As Helpful" if a post has been useful to you.
Disclaimer: This posting is provided "AS IS" with no warranties.