internal void SetPermissions(SPWeb web) { try { var list = web.GetList("UserPhotos"); var allUsers = web.EnsureUser("NT AUTHORITY\\authenticated users"); var roleAssignment = new SPRoleAssignment(allUsers); var readerRole = web.RoleDefinitions.GetByType(SPRoleType.Reader); roleAssignment.RoleDefinitionBindings.Add(readerRole); if (!list.HasUniqueRoleAssignments) { list.BreakRoleInheritance(true); } list.RoleAssignments.Add(roleAssignment); list.Update(); } catch (Exception ex) { FoundationSync.LogMessage(1003, FoundationSync.LogCategories.FoundationSync, TraceSeverity.Unexpected, string.Format("Unable to set permissions on UserPhotos list. " + "Add Authenticated Users with Read rights manually. {0}", ex.InnerException), null); } }
internal void CreateList(SPWeb web) { try { web.AllowUnsafeUpdates = true; web.Lists.Add("UserPhotos", "This library holds User Photos pulled from Active Directory and/or Exchange", SPListTemplateType.PictureLibrary); web.AllowUnsafeUpdates = false; web.Update(); var list = web.GetList("UserPhotos"); list.OnQuickLaunch = false; list.EnableThrottling = false; list.EnableFolderCreation = false; list.Hidden = true; list.Update(); } catch (Exception ex) { FoundationSync.LogMessage(1003, FoundationSync.LogCategories.FoundationSync, TraceSeverity.Unexpected, string.Format("Unable to create UserPhotos library. " + "Please create the UserPhotos library manually. {0}", ex.InnerException), null); } }