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); } }
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); } }
private static void RegisterLogging(SPFeatureReceiverProperties properties, bool register) { var farm = properties.Definition.Farm; if (farm == null) { return; } var log = FoundationSync.Local; if (register) { if (log != null) { return; } log = new FoundationSync(); log.Update(); if (log.Status != SPObjectStatus.Offline) { log.Status = SPObjectStatus.Offline; } if (log.Status != SPObjectStatus.Online) { log.Provision(); } } else { if (log == null) { return; } try { log.Unprovision(); } catch { } finally { log.Delete(); } } }