Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to get the permissions associated to a Folder. I can get the folder by the getfolder method but the item has the .Item property null. When i Access to the .DocumentLibrary i get the RoleAssignments, but if I had a subfolder with his own RoleAssignments, the solution i'm using always returns me the parents' privileges..

here's some simplified code

Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite siteCollection = new SPSite(singleSiteBinding.Url))
                        {
                            using (SPWeb web = siteCollection.OpenWeb()) 
                            {
                                web.AllowUnsafeUpdates = true;
                                siteCollection.AllowUnsafeUpdates = true;

                                SPFolder folder = web.GetFolder(singleSiteBinding.Url);
                                //  folder.Item == null!!

                                foreach (SPRoleAssignment ruolo in folder.DocumentLibrary.RoleAssignments)
                                {
                                    //DO SOMETHING!
                                }

                            }
                        }
                    });

Thank you!!!

share|improve this question
1  
Are you sure you get the right folder? Is folder.Exists true? If this is a real folder then you should have an Item which has the RoleAssignments Property. The folder.DocumentLibrary is the doc lib which holds (or would hold) the folder and RoleAssignments of that is the doclibs roleassignments –  Per Jakobsen Mar 27 '12 at 18:42
    
Exactly.. I'm using wrong Path.. With the right one it works.. But not every time! There is a case in which i pass the right address, it gets the folder, the folder exists but the Item associated is null... This happens (in my case) for an URL who is a rootfolder URL... It's a normal behavior? I'm using the .DocumentLibrary to solve the problem! –  Ziba Leah Mar 28 '12 at 9:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.