internal void LoadSettings() { try { if (FoundationSyncSettings.Local.UseExchange) { tBox2.Text = FoundationSyncSettings.Local.EwsUrl.AbsoluteUri; } } catch (Exception) { FoudationSync.LogMessage(1002, FoudationSync.LogCategories.FoundationSync, TraceSeverity.Unexpected, string.Format("Unable to retrieve EwsUrl when loading settings."), null); } try { if (FoundationSyncSettings.Local.PictureStorageUrl != null) { var uri = FoundationSyncSettings.Local.PictureStorageUrl.AbsoluteUri; if (uri.EndsWith("/UserPhotos")) { tBox1.Text = uri.Replace("/UserPhotos", string.Empty); } } } catch (Exception) { FoudationSync.LogMessage(1002, FoudationSync.LogCategories.FoundationSync, TraceSeverity.Unexpected, string.Format("Unable to retrieve PictureStorageUrl when loading settings."), null); } }
internal void ValidateExchangeConnection() { if (!Uri.IsWellFormedUriString(tBox2.Text, UriKind.Absolute)) { FoundationSyncSettings.Local.UseExchange = false; FoundationSyncSettings.Local.EwsUrl = null; FoundationSyncSettings.Local.Update(); } else { try { FoundationSyncSettings.Local.UseExchange = true; var tbox2Uri = new Uri(tBox2.Text); FoundationSyncSettings.Local.EwsUrl = tbox2Uri; FoundationSyncSettings.Local.Update(); } catch (Exception ex) { FoudationSync.LogMessage(1002, FoudationSync.LogCategories.FoundationSync, TraceSeverity.Unexpected, string.Format("Unable to set UseExchange or EwsUrl values with error {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) { FoudationSync.LogMessage(1003, FoudationSync.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) { FoudationSync.LogMessage(1003, FoudationSync.LogCategories.FoundationSync, TraceSeverity.Unexpected, string.Format("Unable to create UserPhotos library. " + "Please create the UserPhotos library manually. {0}", ex.InnerException), null); } }
private static void RegisterLogging(SPFeatureReceiverProperties properties, bool register) { var farm = properties.Definition.Farm; if (farm == null) { return; } var log = FoudationSync.Local; if (register) { if (log != null) { return; } log = new FoudationSync(); 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(); } } }