Find out Farm wide Broken permission inheritance

on Tuesday, March 9, 2010




SPWebService webAppServices = (from webService in SPFarm.Local.Services.OfType<SPWebService>()

                                               where !webService.TypeName.Contains("Central")
                                               select webService).SingleOrDefault();    
                    
                
                                                    
                foreach (SPWebApplication webApp in webAppServices.WebApplications)
                {

                    Console.WriteLine(webApp.Name);
                    foreach (SPSite site in webApp.Sites)
                    {

                        Console.WriteLine("SITE URL:" +site.Url);
                        foreach (SPWeb web in site.AllWebs)
                        {

                            Console.WriteLine("Web URL" + web.Url);
                            //Use HasUniqueRoleAssignments property to check if the RoleInheritance is broken or not
                            Console.WriteLine("Role inheritance " + (web.HasUniqueRoleAssignments ==true ? "Broken" : "Not Broken")); 
                        }
                    }
                }

0 comments: