private void UnregisterHttpModule(SPFeatureReceiverProperties properties) { SPWebConfigModification webConfigModification = CreateWebModificationObject(); SPSecurity.RunWithElevatedPrivileges(() => { SPWebService contentService = properties.Definition.Farm.Services.GetValue <SPWebService>(); int numberOfModifications = contentService.WebConfigModifications.Count; //Iterate over all WebConfigModification and delete only those we have created for (int i = numberOfModifications - 1; i >= 0; i--) { SPWebConfigModification currentModifiction = contentService.WebConfigModifications[i]; if (currentModifiction.Owner.Equals(webConfigModification.Owner)) { contentService.WebConfigModifications.Remove(currentModifiction); } } //Update only if we have something deleted if (numberOfModifications > contentService.WebConfigModifications.Count) { contentService.Update(); contentService.ApplyWebConfigModifications(); } }); }
private void ActivateHttpHandler_Bing(SPFeatureReceiverProperties properties) { if (webApp != null) { SPWebConfigModificationExtensions.WaitForOnetimeJobToFinish(webApp.Farm, "job-webconfig-modification", 180); SPWebConfigModification mod = new SPWebConfigModification("add[@type='Hemrika.SharePresence.WebSite.Bing.BingHandler, Hemrika.SharePresence.WebSite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=11e6604a27f32a11']", "configuration/system.webServer/handlers"); mod.Owner = properties.Feature.DefinitionId.ToString(); mod.Sequence = 0; mod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; mod.Value = @"<add name=""BingHandler"" path=""BingSiteAuth.xml"" verb=""*"" type=""Hemrika.SharePresence.WebSite.Bing.BingHandler, Hemrika.SharePresence.WebSite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=11e6604a27f32a11"" />"; if (!webApp.WebConfigModifications.Contains(mod)) { webApp.WebConfigModifications.Add(mod); } try { SPWebConfigModificationExtensions.WaitForOnetimeJobToFinish(webApp.Farm, "job-webconfig-modification", 180); webApp.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications(); ////webApp.WebService.ApplyWebConfigModifications(); webApp.Update(); webApp.BlockedFileExtensions.Remove("xml"); webApp.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } } }
private static void AddAssemblies() { var configModSyncfusionAssembliesEJ = new SPWebConfigModification { Name = "add[@assembly='Syncfusion.EJ, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89']", Owner = "ClubCloud", Sequence = 0, Path = "configuration/system.web/compilation/assemblies", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add assembly='Syncfusion.EJ, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' />" }; _modifications.Add(configModSyncfusionAssembliesEJ); var configModSyncfusionAssembliesEJWeb = new SPWebConfigModification { Name = "add[@assembly='Syncfusion.EJ.Web, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89']", Owner = "ClubCloud", Sequence = 0, Path = "configuration/system.web/compilation/assemblies", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add assembly='Syncfusion.EJ.Web, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' />" }; _modifications.Add(configModSyncfusionAssembliesEJWeb); }
/// <summary> /// Incompatible with AjaxControlToolkit /// </summary> private static void AddPageCompressionHandler() { var configModSyncfusionPageCompressionHandlerWeb = new SPWebConfigModification { Name = "add[@name='HttpCompressModule'][type='Syncfusion.Web.UI.WebControls.Handler.PageCompressHandler, Syncfusion.Shared.Web, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89']", Owner = "ClubCloud", Sequence = 0, Path = "configuration/system.web/httpModules", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add name='HttpCompressModule' type='Syncfusion.Web.UI.WebControls.Handler.PageCompressHandler, Syncfusion.Shared.Web, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' />" }; _modifications.Add(configModSyncfusionPageCompressionHandlerWeb); var configModSyncfusionPageCompressionHandlerwebServer = new SPWebConfigModification { Name = "add[@name='HttpCompressModule'][type='Syncfusion.Web.UI.WebControls.Handler.PageCompressHandler, Syncfusion.Shared.Web, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89']", Owner = "ClubCloud", Sequence = 0, Path = "configuration/system.webServer/modules", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add name='HttpCompressModule' type='Syncfusion.Web.UI.WebControls.Handler.PageCompressHandler,Syncfusion.Shared.Web, Version=12.4451.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' />" }; _modifications.Add(configModSyncfusionPageCompressionHandlerwebServer); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApp = (SPWebApplication)properties.Feature.Parent; SPWebConfigModificationExtensions.WaitForOnetimeJobToFinish(webApp.Farm, "job-webconfig-modification", 180); WebSiteControllerWebConfigManager.ClearWebConfigModifications(webApp); SPWebConfigModification mod = WebSiteControllerWebConfigManager.GetHttpModuleEntry(); if (!webApp.WebConfigModifications.Contains(mod)) { webApp.WebConfigModifications.Add(mod); } mod = WebSiteControllerWebConfigManager.GetModuleEntry(); if (!webApp.WebConfigModifications.Contains(mod)) { webApp.WebConfigModifications.Add(mod); } try { webApp.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications(); webApp.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } }
/// <summary> /// Remove modifications from the web application. /// </summary> /// <param name="webApp">The web application to remove the modifications from.</param> /// <param name="owner"Remove all modifications that belong to the owner></param> private void RemoveWebConfigModificationsByOwner(SPWebApplication webApp, string owner) { Collection <SPWebConfigModification> modificationCollection = webApp.WebConfigModifications; Collection <SPWebConfigModification> removeCollection = new Collection <SPWebConfigModification>(); int count = modificationCollection.Count; for (int i = 0; i < count; i++) { SPWebConfigModification modification = modificationCollection[i]; if (modification.Owner == owner) { // Collect modifications to delete. removeCollection.Add(modification); } } // Delete the modifications from the web application. if (removeCollection.Count > 0) { foreach (SPWebConfigModification modificationItem in removeCollection) { webApp.WebConfigModifications.Remove(modificationItem); } // Commit modification removals to the specified web application. webApp.Update(); // Push modifications through the farm. webApp.WebService.ApplyWebConfigModifications(); } }
// Uncomment the method below to handle the event raised before a feature is deactivated. public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication; SPSecurity.RunWithElevatedPrivileges(delegate() { Collection <SPWebConfigModification> mods = webApplication.WebConfigModifications; int initialModificationsCount = mods.Count; for (int i = initialModificationsCount - 1; i >= 0; i--) { if (mods[i].Owner == "SampleToDeployAPage") { SPWebConfigModification modToRemove = mods[i]; mods.Remove(modToRemove); } } if (initialModificationsCount > mods.Count) { webApplication.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications(); webApplication.Update(); } }); }
private void OverrideBrowserCaps(SPFeatureReceiverProperties properties) { if (webApp != null) { SPWebConfigModificationExtensions.WaitForOnetimeJobToFinish(webApp.Farm, "job-webconfig-modification", 180); /* * <browserCaps> * <result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> * <filter>isMobileDevice=false</filter> * </browserCaps> */ SPWebConfigModification mod = new SPWebConfigModification("add[@type='System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a']", "configuration/system.web/browserCaps"); mod.Owner = properties.Feature.DefinitionId.ToString(); mod.Sequence = 0; mod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; mod.Value = @"<result type=""System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" /><filter>isMobileDevice=false</filter>"; if (!webApp.WebConfigModifications.Contains(mod)) { webApp.WebConfigModifications.Add(mod); } try { SPWebConfigModificationExtensions.WaitForOnetimeJobToFinish(webApp.Farm, "job-webconfig-modification", 180); webApp.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications(); ////webApp.WebService.ApplyWebConfigModifications(); webApp.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } } }
// Uncomment the method below to handle the event raised when a feature is upgrading. //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters) //{ //} private void RemoveAllCustomisations(SPWebApplication webApp) { if (webApp != null) { Collection <SPWebConfigModification> collection = webApp.WebConfigModifications; int iStartCount = collection.Count; // Remove any modifications that were originally created by the owner. for (int c = iStartCount - 1; c >= 0; c--) { SPWebConfigModification configMod = collection[c]; if (configMod.Owner == "SPExcelWebAppRedirecter") { collection.Remove(configMod); } } // Apply changes only if any items were removed. if (iStartCount > collection.Count) { webApp.Update(); webApp.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications(); } } }
// Uncomment the method below to handle the event raised before a feature is uninstalled. public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { SPWebApplication webApp = new SPSite("http://dave-laptop3/sites/davehome").WebApplication; Collection <SPWebConfigModification> collection = webApp.WebConfigModifications; int iStartCount = collection.Count; // Remove any modifications that were originally created by the owner. for (int c = iStartCount - 1; c >= 0; c--) { SPWebConfigModification configMod = collection[c]; if (configMod.Owner == "VWPAdventureWorks") { collection.Remove(configMod); } } // Apply changes only if any items were removed. if (iStartCount > collection.Count) { webApp.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications(); webApp.Update(); } }
public void RemoveExistingModificationsFromOwner(SPWebApplication webApplication, string owner) { var removeCollection = new Collection <SPWebConfigModification>(); var modificationCollection = webApplication.WebConfigModifications; int count = modificationCollection.Count; for (int i = 0; i < count; i++) { SPWebConfigModification modification = modificationCollection[i]; if (modification.Owner == owner) { // collect modifications to delete removeCollection.Add(modification); } } // now delete the modifications from the web application if (removeCollection.Count > 0) { foreach (SPWebConfigModification modificationItem in removeCollection) { webApplication.WebConfigModifications.Remove(modificationItem); } // Commit modification removals to the specified web application webApplication.Update(); // Push modifications through the farm webApplication.WebService.ApplyWebConfigModifications(); } }
// Uncomment the method below to handle the event raised when a feature is upgrading. //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters) //{ //} private static void ModifyWebConfig(SPWebApplication webApplication, bool remove) { const string assembly = @"Nauplius.WAS.2013, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1458f7a17eac05e9"; const string _namespace = @"Nauplius.WAS"; var modification = new SPWebConfigModification { Owner = "Nauplius.WAS", Sequence = 0, Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes/targetFx[@version='v4.0']", Name = string.Format( "authorizedType[@Assembly='{0}'][@Namespace='{1}'][@TypeName='*'][@Authorized='True']", assembly, _namespace), Value = string.Format("<authorizedType Assembly='{0}' Namespace='{1}' TypeName='*' Authorized='True'/>", assembly, _namespace) }; if (!remove) { webApplication.WebConfigModifications.Add(modification); } else { webApplication.WebConfigModifications.Remove(modification); } webApplication.Update(); webApplication.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications(); }
public void RemoveTranslatorFromWebConfig(string wwwRoot) { using (var site = new SPSite(wwwRoot)) { var webService = SPWebService.ContentService; SPWebConfigModification configModFound = null; Collection <SPWebConfigModification> modsCollection = site.WebApplication.WebConfigModifications; // Find the most recent modification of a specified owner int modsCount1 = modsCollection.Count; for (int i = modsCount1 - 1; i > -1; i--) { if (modsCollection[i].Name == "add [@name='AlphaMosaikTranslation']") { configModFound = modsCollection[i]; break; } } // Remove it and save the change to the configuration database modsCollection.Remove(configModFound); webService.Update(); webService.ApplyWebConfigModifications(); } }
private static void AddSignalRHandler() { /* * var configModSyncfusionPageCompressionHandlerWeb = new SPWebConfigModification * { * //<add name="SignalR" type="ClubCloud.SignalR.SignalRModule, ClubCloud.SignalR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e" /> * Name = "add[@name='SignalR'][type='ClubCloud.SignalR.SignalRModule, ClubCloud.SignalR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e']", * Owner = Owner, * Sequence = 0, * Path = "configuration/system.web/httpModules", * Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, * Value = "<add name='SignalR' type='ClubCloud.SignalR.SignalRModule, ClubCloud.SignalR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e' />" * * }; * _modifications.Add(configModSyncfusionPageCompressionHandlerWeb); */ var configModSyncfusionPageCompressionHandlerwebServer = new SPWebConfigModification { Name = "add[@name='SignalR'][type='ClubCloud.SignalR.SignalRModule, ClubCloud.SignalR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e']", Owner = Owner, Sequence = 0, Path = "configuration/system.webServer/modules", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add name='SignalR' type='ClubCloud.SignalR.SignalRModule, ClubCloud.SignalR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e' />" }; _modifications.Add(configModSyncfusionPageCompressionHandlerwebServer); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; SPWebConfigModification mod = new SPWebConfigModification(); mod.Path = "configuration"; mod.Name = "connectionStrings"; mod.Sequence = 0; mod.Owner = "_61528";//<--------------------------------------- Change ID mod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureSection; webApp.WebConfigModifications.Add(mod); mod = new SPWebConfigModification(); mod.Path = "configuration/connectionStrings"; mod.Name = "add[@name = 'corporateDb']"; mod.Sequence = 0; mod.Value = "<add name ='corporateDb' connectionString='blah' />"; mod.Owner = "_61528";//<--------------------------------------- Change ID mod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; webApp.WebConfigModifications.Add(mod); webApp.Update(); webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); }
private static void AddPeoplePicker() { /* * <SharePoint> * <PeoplePickerWildcards> * <clear /> * <add key="AspNetSqlMembershipProvider" value="%" /> * <add key="ZimbraMembershipProvider" value="" /> * <add key="ZimbraRoleProvider" value="" /> * </PeoplePickerWildcards> */ var ZimbraMembershipProvider = new SPWebConfigModification { Name = "add[@key='ZimbraMembershipProvider'][@value='']", Owner = Owner, Sequence = 0, Path = "configuration/SharePoint/PeoplePickerWildcards", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add key=\"ZimbraMembershipProvider\" value=\"\" />" }; _modifications.Add(ZimbraMembershipProvider); var ZimbraRoleProvider = new SPWebConfigModification { Name = "add[@key='ZimbraRoleProvider'][@value='']", Owner = Owner, Sequence = 1, Path = "configuration/SharePoint/PeoplePickerWildcards", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add key=\"ZimbraRoleProvider\" value=\"\" />" }; _modifications.Add(ZimbraRoleProvider); }
public WebFeatureReceiver() { sPWebConfigModification = new SPWebConfigModification("add[@name=\"CategorySiteMapProvider\"]", "configuration/system.web/siteMap/providers"); sPWebConfigModification.Owner = GetType().Assembly.GetName().ToString(); sPWebConfigModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; sPWebConfigModification.Value = @"<add name=""CategorySiteMapProvider"" description=""Provider for category navigation using Business Data Catalog"" type=""Contoso.PartnerPortal.ProductCatalog.Navigation.BusinessDataCatalogSiteMapProvider, Contoso.PartnerPortal.ProductCatalog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0dcd9137292eac97"" />"; }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { var capsMod = new SPWebConfigModification(); var capsXml = @"<browserCaps></browserCaps>"; capsMod.Path = "configuration/system.web"; capsMod.Name = "browserCaps"; capsMod.Owner = ModOwner; capsMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; capsMod.Value = capsXml; /* So it seems that the web.config modifications are not made in the order that they are added, but rather in alphabetical order (for whatever reason). * The <filter> element must be after the <result> element, so we add [1=1] and [2=2] onto the end of the path. These are trivially true and so don't affect * the XPath, but they do affect the ordering in which the modifications are applied. If the order were not a concern this would not be required. */ // Aparrently the inner XML needs to be in a separate modification var capsResultMod = new SPWebConfigModification(); //TODO: Check PublicKeyToken var capsResultXml = "<result type=\"System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"/>"; capsResultMod.Path = "configuration/system.web/browserCaps[1=1]"; capsResultMod.Name = "result"; capsResultMod.Owner = ModOwner; capsResultMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; capsResultMod.Value = capsResultXml; capsResultMod.Sequence = 1; // Need to do each element separately or else bits wll get left behind on retraction var capsFilterMod = new SPWebConfigModification(); var capsFilterXml = "<filter>isMobileDevice=false</filter>"; capsFilterMod.Path = "configuration/system.web/browserCaps[2=2]"; capsFilterMod.Name = "filter"; capsFilterMod.Owner = ModOwner; capsFilterMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; capsFilterMod.Value = capsFilterXml; capsFilterMod.Sequence = 2; var webConfigMod = new SPWebConfigModification(); webConfigMod.Path = "configuration/system.webServer/modules"; webConfigMod.Name = "add[@name='PageNotFoundHttpModule']"; webConfigMod.Sequence = 0; webConfigMod.Owner = ModOwner; webConfigMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; //TODO: Check PublicKeyToken webConfigMod.Value = @"<add name='PageNotFoundHttpModule' type='NRMS.Layouts.PageNotFoundHttpModule,NRMS.Layouts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d1ff616a8b0e9cd' />"; var webService = SPWebService.ContentService; webService.WebConfigModifications.Add(capsMod); webService.WebConfigModifications.Add(capsResultMod); webService.WebConfigModifications.Add(capsFilterMod); webService.WebConfigModifications.Add(webConfigMod); webService.Update(); webService.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { return; bool bApplyChanges = ApplyWebConfigMods(properties); SPSite currentSite = properties.Feature.Parent as SPSite; if (bApplyChanges) { string sExpressionBuilderType = string.Format("AlphaMosaik.SharePoint.ConfigurationStore.ConfigStoreExpressionBuilder, {0}", Assembly.GetExecutingAssembly().FullName); // add web.config entries.. SPWebConfigModification siteEntry = addAppSetting(m_SiteUrlModification, m_AppSettingsXPath, m_ConfigSiteAppSettingsKey, currentSite.Url, 100); SPWebConfigModification webEntry = addAppSetting(m_WebNameModification, m_AppSettingsXPath, m_ConfigWebAppSettingsKey, string.Empty, 200); SPWebConfigModification listEntry = addAppSetting(m_ListNameModification, m_AppSettingsXPath, m_ConfigListAppSettingsKey, m_DefaultListName, 300); SPWebConfigModification cacheFileEntry = addAppSetting(m_CacheFileModification, m_AppSettingsXPath, m_CacheFileAppSettingsKey, m_CacheDependencyFile, 400); SPWebConfigModification expressionBuilderEntry = addExpressionBuilder(m_ExpressionBuilderModification, m_ExpressionBuildersXPath, m_ExpressionBuilderPrefix, sExpressionBuilderType, 500); SPWebApplication currentWebApp = currentSite.WebApplication; currentWebApp.WebConfigModifications.Add(siteEntry); currentWebApp.WebConfigModifications.Add(listEntry); currentWebApp.WebConfigModifications.Add(webEntry); currentWebApp.WebConfigModifications.Add(cacheFileEntry); currentWebApp.WebConfigModifications.Add(expressionBuilderEntry); currentWebApp.WebService.ApplyWebConfigModifications(); currentWebApp.Update(); } // Déjà fait //// and also add list event receivers.. //SPWeb rootWeb = currentSite.RootWeb; //SPList configStoreList = null; //try //{ // configStoreList = rootWeb.Lists[m_DefaultListName]; // addEventReceivers(configStoreList); // configStoreList.Update(); //} //catch //{ // // if we can't find the list we won't try and add event receivers.. //} }
protected SPWebConfigModification GetSPWebModifSection(string name, string xpath) { SPWebConfigModification modification = new SPWebConfigModification(name, xpath); modification.Owner = OwnerModif; modification.Sequence = 0; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureSection; return(modification); }
public static void CreateAndAddWebConfigModification(IList <SPWebConfigModification> modifications, string name, string xpath, SPWebConfigModification.SPWebConfigModificationType type, string value, string owner) { SPWebConfigModification modification = new SPWebConfigModification(name, xpath); modification.Owner = owner; modification.Type = type; modification.Value = value; modifications.Add(modification); }
private void MapConfig(SPWebConfigModification config, WebConfigModificationDefinition definition) { config.Path = definition.Path; config.Name = definition.Name; config.Sequence = definition.Sequence; config.Owner = definition.Owner; config.Type = (SPWebConfigModification.SPWebConfigModificationType)Enum.Parse(typeof(SPWebConfigModification.SPWebConfigModificationType), definition.Type); config.Value = definition.Value; }
public SPWebConfigModification CreateModification(string Name, string XPath, string Value, SPWebConfigModification.SPWebConfigModificationType Type, string Owner) { SPWebConfigModification modification = new SPWebConfigModification(Name, XPath); modification.Owner = Owner; modification.Sequence = 0; modification.Type = Type; modification.Value = Value; return modification; }
private static void AddTargetFramework() { var configModcompilationTargetFramework = new SPWebConfigModification { Name = "targetFramework", Owner = "ClubCloud", Sequence = 0, Path = "configuration/system.web/compilation", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute, Value = "4.5.2" }; _modifications.Add(configModcompilationTargetFramework); var configModhttpRuntimeTargetFramework = new SPWebConfigModification { Name = "targetFramework", Owner = "ClubCloud", Sequence = 1, Path = "configuration/system.web/httpRuntime", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute, Value = "4.5.2" }; _modifications.Add(configModhttpRuntimeTargetFramework); /* * <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> * <add key="aspnet:MaxConcurrentCompilations" value="0" /> */ var UnobtrusiveValidationMode = new SPWebConfigModification { Name = "add[@key='ValidationSettings:UnobtrusiveValidationMode'][@value='None']", Owner = "ClubCloud", Sequence = 2, Path = "configuration/appSettings", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add key=\"ValidationSettings:UnobtrusiveValidationMode\" value=\"None\" />" }; _modifications.Add(UnobtrusiveValidationMode); var MaxConcurrentCompilations = new SPWebConfigModification { Name = "add[@key='aspnet:MaxConcurrentCompilations'][@value='0']", Owner = "ClubCloud", Sequence = 2, Path = "configuration/appSettings", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<add key=\"aspnet:MaxConcurrentCompilations\" value=\"0\" />" }; _modifications.Add(MaxConcurrentCompilations); }
private static void Initialize() { siteEntry = Modification("/configuration/appSettings", "SPSSiteUrl", _site.Url); listEntry = Modification("/configuration/appSettings", "SPSListName", "SPSProfessional Configuration Manager"); }
public SPWebConfigModification GetModification(string owner, uint sequence) { SPWebConfigModification modification = new SPWebConfigModification(Name, XPath); modification.Owner = owner; modification.Sequence = sequence; modification.Type = ModificationType; modification.Value = Value; return(modification); }
public static void CreateAndAddWebConfigModification(IList<SPWebConfigModification> modifications, string name, string xpath, SPWebConfigModification.SPWebConfigModificationType type, string value, string owner) { Validation.ArgumentNotNull(modifications, "modifications"); SPWebConfigModification modification = new SPWebConfigModification(name, xpath); modification.Owner = owner; modification.Type = type; modification.Value = value; modifications.Add(modification); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebConfigModification webConfMod = GetWebConfMod(); SPWebApplication parentWebApp = (SPWebApplication)properties.Feature.Parent; parentWebApp.WebConfigModifications.Add(webConfMod); parentWebApp.Update(); parentWebApp.WebService.ApplyWebConfigModifications(); }
protected SPWebConfigModification GetSPWebModifAttribut(string name, string xpath, string value) { SPWebConfigModification modification = new SPWebConfigModification(name, xpath); modification.Owner = OwnerModif; modification.Sequence = 0; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute; modification.Value = value; return(modification); }
/// <summary> /// Modifie la valeur d'un paramètre de configuration du Logger. /// Les modifications ne sont enregistrées qu'après l'appel de SaveSettings. /// </summary> /// <param name="webApp">Application Web pour laquelle sera modifié le paramètre</param> /// <param name="key">Clé unique permettant de retrouver le paramètre</param> /// <param name="value">Valeur du paramètre</param> public static void SetSetting(SPWebApplication webApp, string key, string value) { string fullKey = Properties.Settings.Default.Settings_Prefix + '.' + key; string pathEdit = "configuration/appSettings/add[@key=\"" + fullKey + "\"]"; string pathAdd = "configuration/appSettings"; bool flag = false; // On supprime d'éventuelles modifications identiques for (int i = webApp.WebConfigModifications.Count - 1; i >= 0; i--) { SPWebConfigModification configModification = webApp.WebConfigModifications[i]; // On vérifie s'il y a déjà eu édition if (configModification.Owner == Properties.Settings.Default.Settings_Owner && configModification.Name == "value" && configModification.Path == pathEdit && configModification.Type == SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute) { webApp.WebConfigModifications.RemoveAt(i); flag = true; } // On vérifie s'il y a déjà eu ajout if (configModification.Owner == Properties.Settings.Default.Settings_Owner && configModification.Name == "add[@key=\"" + fullKey + "\"]" && configModification.Path == pathAdd && configModification.Type == SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode) { flag = true; } } // On modifie le web.config SPWebConfigModification webConfigModification = new SPWebConfigModification(); if (flag) { SaveSettings(webApp); webConfigModification.Owner = Properties.Settings.Default.Settings_Owner; webConfigModification.Name = "value"; webConfigModification.Value = value; webConfigModification.Path = pathEdit; webConfigModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute; } else { webConfigModification.Owner = Properties.Settings.Default.Settings_Owner; webConfigModification.Name = "add[@key=\"" + fullKey + "\"]"; webConfigModification.Value = "<add key=\"" + fullKey + "\" value=\"" + value + "\"/>"; webConfigModification.Path = pathAdd; webConfigModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; } webApp.WebConfigModifications.Add(webConfigModification); }
public void addConnectionString() { SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://litware")); SPWebConfigModification mod = new SPWebConfigModification("add[@name=\"MyConnectionString\"]", "configuration/connectionStrings"); mod.Owner = "AnOwner"; //WebConfigModificationFeatureReceiver.OwnerId mod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; mod.Value = String.Format("<add name=\"{0}\" connectionString=\"{1}\" providerName=\"{2}\">", "MyConnectionString", "connstring goes here", "provider goes here"); webApp.WebConfigModifications.Add(mod); webApp.Update(); webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); }
private static void AddSection() { /* * <configSections> * <sectionGroup name="Zimbra"> * <section name="Configuration" type="ClubCloud.Zimbra.Service.ZimbraConfigurationHandler,ClubCloud.Zimbra, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e" /> * </sectionGroup> */ //*[local-name()='sectionGroup'][*/@name='Zimbra'] var sectionGroup = new SPWebConfigModification { Name = "sectionGroup[@name='Zimbra']", Owner = Owner, Sequence = 0, Path = "configuration/configSections", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<sectionGroup name=\"Zimbra\"></sectionGroup>" }; _modifications.Add(sectionGroup); var sectionConfiguration = new SPWebConfigModification { Name = "section[@name='Configuration'][type='ClubCloud.Zimbra.Service.ZimbraConfigurationHandler,ClubCloud.Zimbra, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e']", Owner = Owner, Sequence = 2, Path = "configuration/configSections/sectionGroup[@name='Zimbra']", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<section name=\"Configuration\" type=\"ClubCloud.Zimbra.Service.ZimbraConfigurationHandler,ClubCloud.Zimbra, Version=1.0.0.0, Culture=neutral, PublicKeyToken=144fd205e283172e\" />" }; _modifications.Add(sectionConfiguration); /* * <Zimbra> * <Configuration> * <Server Name="ClubCloud" ServerName="mail.clubcloud.nl" UserName="******" Password="******" IsAdmin="true" Encoded="false" /> * <Binding MaxReceivedMessageSize="2147483647" /> * </Configuration> * </Zimbra> */ var Zimbra = new SPWebConfigModification { Name = "Zimbra", Owner = Owner, Sequence = 1, Path = "configuration", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = "<Zimbra><Configuration><Server Name=\"ClubCloud\" ServerName=\"mail.clubcloud.nl\" UserName=\"[email protected]\" Password=\"rjm557308453!\" IsAdmin=\"true\" Encoded=\"false\" /><Binding MaxReceivedMessageSize=\"2147483647\" /></Configuration></Zimbra>" }; _modifications.Add(Zimbra); }
/// <summary> /// Modifies Web.Config file /// </summary> /// <param name="name">Node Name</param> /// <param name="path">Location of the Node in Web.Config file</param> /// <param name="isAttribute">Attribute of the Node</param> /// <param name="content">Content to add in the Web.Config file</param> /// <param name="smtpServer">SMTP Server Name</param> private void ModifyWebConfigData(string name, string path, string content) { SPWebConfigModification myModification = new SPWebConfigModification(name, path); myModification.Sequence = 0; myModification.Owner = WebConfigModificationOwner; myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; myModification.Value = content; spWeb.Site.WebApplication.WebConfigModifications.Add(myModification); }
/// <summary> /// Removes if owned by the give <paramref name="owner"/> /// </summary> /// <param name="this"> /// The this. /// </param> /// <param name="owner"> /// The owner. /// </param> public static void RemoveIfIsOwnedBy(this Collection <SPWebConfigModification> @this, string owner) { for (int i = @this.Count - 1; i >= 0; i--) { SPWebConfigModification webConfigModification = @this[i]; if (webConfigModification.Owner == owner) { @this.Remove(webConfigModification); } } }
/// <summary> /// Creates the necessary web config modification for running the custom web controls /// </summary> /// <returns></returns> private SPWebConfigModification createWebConfigModification() { SPWebConfigModification myModification = new SPWebConfigModification(); myModification.Path = "configuration/system.web/pages/controls"; myModification.Name = @"add[@tagPrefix='aroth'][@namespace='aroth.sharepoint.controls'][@assembly='aroth.sharepoint.controls.SPUserGroupTrimmedControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7f26d7ca086c312']"; myModification.Sequence = 0; myModification.Owner = "Admin"; myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; myModification.Value = "<add tagPrefix='aroth' namespace='aroth.sharepoint.controls' assembly='aroth.sharepoint.controls.SPUserGroupTrimmedControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7f26d7ca086c312' /> "; return myModification; }
private static SPWebConfigModification GetConfigModification(string name, string path) { string fileHandlerTypeName = typeof(DownloadFileHandler).AssemblyQualifiedName; SPWebConfigModification modification = new SPWebConfigModification($"add[@name=\"{name}\"]", "configuration/system.webServer/handlers"); modification.Value = $"<add name=\"{name}\" verb=\"*\" path=\"{path}\" type=\"{fileHandlerTypeName}\" preCondition=\"integratedMode\" />"; modification.Sequence = 1; modification.Owner = fileHandlerTypeName; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; return(modification); }
private static void RegisterHttpModule(SPWebApplication webApp) { var httpModuleType = typeof(IronHttpModule); SPWebConfigModification httpModuleMod = new SPWebConfigModification(); httpModuleMod.Path = "configuration/system.webServer/modules"; httpModuleMod.Name = String.Format("add[@name='IronHttpModule'][@type='{0}']", httpModuleType.AssemblyQualifiedName); httpModuleMod.Sequence = 0; httpModuleMod.Owner = modificationOwner; httpModuleMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; httpModuleMod.Value = String.Format("<add name='IronHttpModule' type='{0}' />", httpModuleType.AssemblyQualifiedName); webApp.WebConfigModifications.Add(httpModuleMod); }
private static void RegisterExpressionBuilder(SPWebApplication webApp) { var expressionBuilderType = typeof(IronExpressionBuilder); SPWebConfigModification expressionBuilderMod = new SPWebConfigModification(); expressionBuilderMod.Path = "configuration/system.web/compilation/expressionBuilders"; expressionBuilderMod.Name = String.Format("add[@expressionPrefix='Iron'][@type='{0}']", expressionBuilderType.AssemblyQualifiedName); expressionBuilderMod.Sequence = 0; expressionBuilderMod.Owner = modificationOwner; expressionBuilderMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; expressionBuilderMod.Value = String.Format("<add expressionPrefix='Iron' type='{0}' />", expressionBuilderType.AssemblyQualifiedName); webApp.WebConfigModifications.Add(expressionBuilderMod); }
private static void RegisterHttpHandlerFactory(SPWebApplication webApp) { var httpHandlerType = typeof(IronHttpHandler); SPWebConfigModification httpHandlerFacotry = new SPWebConfigModification(); httpHandlerFacotry.Path = "configuration/system.webServer/handlers"; httpHandlerFacotry.Name = String.Format("add[@type='{0}']", httpHandlerType.AssemblyQualifiedName); httpHandlerFacotry.Sequence = 0; httpHandlerFacotry.Owner = modificationOwner; httpHandlerFacotry.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; httpHandlerFacotry.Value = String.Format("<add name='IronHttpHandler' path='_iron/*' verb='*' type='{0}' />", httpHandlerType.AssemblyQualifiedName); webApp.WebConfigModifications.Add(httpHandlerFacotry); }
private SPWebConfigModification CreateWebModificationObject() { var name = String.Format("add[@name=\"{0}\"]", typeof(FedAuthDebuggerHttpModule).Name); var xpath = "/configuration/system.webServer/modules"; var modification = new SPWebConfigModification(name, xpath); modification.Owner = "FedAuthDebugger"; modification.Sequence = 0; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; modification.Value = String.Format("<add name=\"{0}\" type=\"{1}\" />", typeof(FedAuthDebuggerHttpModule).Name, typeof(FedAuthDebuggerHttpModule).AssemblyQualifiedName); return modification; }
private SPWebConfigModification GetConfigKey(string owner) { SPWebConfigModification webConfigModifications = new SPWebConfigModification(); webConfigModifications = new SPWebConfigModification(); webConfigModifications.Path = WebCofigNode; webConfigModifications.Name = string.Format("add[@name='{0}']", WebCofigKeyName); webConfigModifications.Sequence = 0; webConfigModifications.Owner = owner; webConfigModifications.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; webConfigModifications.Value = string.Format("<add name=\"{0}\" preCondition=\"integratedMode\" type=\"{1}\" />", WebCofigKeyName, assemblyValue); return webConfigModifications; }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication wappCurrent = (SPWebApplication)properties.Feature.Parent; SPWebConfigModification modAuthorizedType = new SPWebConfigModification(); modAuthorizedType.Name = "AuthType"; modAuthorizedType.Owner = "SPDActivityDemo"; modAuthorizedType.Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes"; modAuthorizedType.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; modAuthorizedType.Value = "<authorizedType Assembly=\"SPDActivityDemo, " + "Version=1.0.0.0, Culture=neutral, PublicKeyToken=a66e91d2ee2fa8f8\" " + "Namespace=\"SPDActivityDemo\" TypeName=\"*\" Authorized=\"True\" />"; wappCurrent.WebConfigModifications.Add(modAuthorizedType); wappCurrent.WebService.ApplyWebConfigModifications(); }
//this event receiver will add sitemap to web.config at /inetpub/wwwroot/wss/VirtualDirectories/TARGET WEB APP public override void FeatureActivated(SPFeatureReceiverProperties properties) { var webapp = properties.Feature.Parent as SPWebApplication; SPWebConfigModification modification = new SPWebConfigModification(); modification.Path = "configuration/system,web/siteMap/providers"; modification.Name = modName; modification.Sequence = 0; modification.Owner = "*****@*****.**"; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; modification.Value = "<add name = 'TestSiteProvider' siteMapFile='_layouts/15/Navigation Provider/testSiteMap' type='Microsoft.SharePoint.Navigation.SPXmlContentMapProvider, Micorosoft.SHarePoint, Version=15.0.0.0, Culture=neutral, PublicKeyoken=71e9bce111e9429c' />";//GAC Properties webapp.WebConfigModifications.Add(modification); webapp.Update(); webapp.WebService.ApplyWebConfigModifications(); }
/// <summary> /// Ensures the BLOB cache is enabled or disabled in the specified Web Application. /// This method Updates the web application web.config file in order to enable or disable BLOB Cache. /// </summary> /// <param name="webApplication">The SharePoint web application.</param> /// <param name="enabled">Enable or disable the BLOB Cache.</param> public void EnsureBlobCache(SPWebApplication webApplication, bool enabled) { SPWebConfigModification modification = new SPWebConfigModification(); modification.Path = "configuration/SharePoint/BlobCache"; modification.Name = "enabled"; modification.Value = enabled ? "true" : "false"; modification.Sequence = 0; modification.Owner = "Dynamite-BlobCache"; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute; var modifications = new Collection<SPWebConfigModification>(); modifications.Add(modification); this.webConfigModificationHelper.AddAndCleanWebConfigModification(webApplication, modifications); }
/// <summary> /// Adds the key/value pair as an appSettings entry in the web application's /// SPWebConfigModification collection /// </summary> /// <param name="webApp">Current web application context</param> /// <param name="key">appSettings node key</param> /// <param name="value">appSettings node value</param> public void AddWebConfigNode(SPWebApplication webApp, string webConfigModxPath, XmlNode node, XmlAttributeCollection attributes) { SPWebConfigModification webConfigMod; string webConfigModName; webConfigModName = GetWebConfigModName(node.Name, attributes); webConfigMod = new SPWebConfigModification(webConfigModName, webConfigModxPath); webConfigMod.Owner = this.Owner; webConfigMod.Sequence = 0; webConfigMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; webConfigMod.Value = node.OuterXml; webApp.WebConfigModifications.Add(webConfigMod); webApp.Update(); }
/// <summary> /// Create the SPWebConfigModification object for the signalr module /// </summary> /// <returns>SPWebConfigModification object for the http module to the web.config</returns> private SPWebConfigModification CreateWebModificationObject() { string name = String.Format("add[@name=\"{0}\"]", typeof(FriendlyUrlHttpModule).Name); string xpath = "/configuration/system.webServer/modules"; SPWebConfigModification webConfigModification = new SPWebConfigModification(name, xpath) { Owner = "Practices.Publishing", Sequence = 0, Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode }; //reflection safe webConfigModification.Value = String.Format("<add name=\"{0}\" type=\"{1}\" />", typeof(FriendlyUrlHttpModule).Name, typeof(FriendlyUrlHttpModule).AssemblyQualifiedName); return webConfigModification; }
private SPWebConfigModification GetAuthorizedTypeConfigNode(string assembly, string assemblyNamespace) { SPWebConfigModification newAuthorizedType = null; newAuthorizedType = new SPWebConfigModification(); newAuthorizedType.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; newAuthorizedType.Name = string.Format("authorizedType[@Assembly='{0}'][@Namespace='{1}'][@TypeName='*'][@Authorized='True']", assembly, assemblyNamespace); newAuthorizedType.Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes"; newAuthorizedType.Owner = assemblyNamespace; newAuthorizedType.Sequence = 0; newAuthorizedType.Value = string.Format("<authorizedType Assembly='{0}' Namespace='{1}' TypeName='*' Authorized='True' />", assembly, assemblyNamespace); return newAuthorizedType; }
public static void AddEntryIntoWebConfig(String webConfigFilePath, String path, SPWebConfigModification.SPWebConfigModificationType type, String value) { XmlTextReader reader = null; XmlNode compareNode = null; string[] nodePath = null; try { reader = new XmlTextReader(webConfigFilePath); nodePath = path.Split('/'); var notificationDataXmlDocument = new XmlDocument(); notificationDataXmlDocument.LoadXml(value); compareNode = notificationDataXmlDocument.DocumentElement; _nodeAttributesFound = new List<bool>(); if (compareNode != null) if (compareNode.Attributes != null) #pragma warning disable 168 foreach (object t in compareNode.Attributes) #pragma warning restore 168 _nodeAttributesFound.Add(false); } catch (Exception) { _isValueExists = false; } if (nodePath != null) if (nodePath.GetUpperBound(0) > -1 && compareNode != null) { while (reader.NodeType != XmlNodeType.Element) reader.Read(); _isValueExists = false; IsXmlEntryFoundInWebConfig(path, reader.ReadSubtree(), 0, compareNode); try { reader.Close(); } catch { reader.Close(); } if (_isValueExists == false) AddEntrytoWebConfig(webConfigFilePath, path, value); } }
private void DeployDefinition(WebApplicationModelHost modelHost, SPWebApplication webApp, WebConfigModificationDefinition definition) { var existingWebConfig = GetCurrentSPWebConfigModification(webApp, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingWebConfig, ObjectType = typeof(SPWebConfigModification), ObjectDefinition = definition, ModelHost = modelHost }); if (existingWebConfig != null) webApp.WebConfigModifications.Remove(existingWebConfig); existingWebConfig = new SPWebConfigModification(); MapConfig(existingWebConfig, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingWebConfig, ObjectType = typeof(SPWebConfigModification), ObjectDefinition = definition, ModelHost = modelHost }); webApp.WebConfigModifications.Add(existingWebConfig); webApp.Update(); //webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); webApp.WebService.ApplyWebConfigModifications(); }
/// <summary> /// Removes the key from the appSettings the web application's /// SPWebConfigModification collection /// </summary> /// <param name="webApp">Current web application context</param> /// <param name="key">appSettings node key</param> public void RemoveWebConfigNodes(SPWebApplication webApp) { Collection<SPWebConfigModification> collection; SPWebConfigModification[] tempCollection; //string webConfigModName; int iStartCount; SPWebConfigModification webConfigMod; collection = webApp.WebConfigModifications; tempCollection = new SPWebConfigModification[collection.Count]; collection.CopyTo(tempCollection, 0); iStartCount = collection.Count; // Remove any modifications that were originally created by the owner. for (int c = iStartCount - 1; c >= 0; c--) { webConfigMod = collection[c]; if (webConfigMod.Owner == this.Owner) collection.Remove(webConfigMod); } }
protected SPWebConfigModification GetSPWebModifChild(string name, string xpath, string scriptResource,SPWebConfigModification.SPWebConfigModificationType type,int sequence ) { SPWebConfigModification modification = new SPWebConfigModification(name, xpath); modification.Owner = this.OwnerModify; modification.Sequence = (uint)sequence; modification.Type = type; modification.Value = scriptResource; return modification; }
public WebConfigEntry(string name, string xPath, string value, SPWebConfigModification.SPWebConfigModificationType modificationType, bool keepOnDeactivate) { Name = name; XPath = xPath; Value = value; ModificationType = modificationType; KeepOnDeactivate = keepOnDeactivate; }
// Uncomment the method below to handle the event raised after a feature has been installed. //public override void FeatureInstalled(SPFeatureReceiverProperties properties) //{ // var wap = properties.Feature.Parent as SPWebApplication; // if (wap == null) // throw new ArgumentException("Missing parent SPWebApplication!", "properties"); // wap.CreateUnityConfig(); //} // Uncomment the method below to handle the event raised before a feature is uninstalled. //public override void FeatureUninstalling(SPFeatureReceiverProperties properties) //{ // var wap = properties.Feature.Parent as SPWebApplication; // if (wap == null) // throw new ArgumentException("Missing parent SPWebApplication!", "properties"); // wap.DeleteUnityConfig(); //} // Uncomment the method below to handle the event raised when a feature is upgrading. //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters) //{ //} static WebAppEventReceiver() { Type = typeof(UnityHttpHandler).AssemblyQualifiedName; Mod = new SPWebConfigModification { Path = "configuration/system.webServer/modules", Name = String.Format("add[@name='{0}'][@type='{1}']", Name, Type), Sequence = 0, Owner = Name, Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Value = String.Format("<add name='{0}' type='{1}' />", Name, Type) }; }
protected SPWebConfigModification GetSPWebModifAttribut(string name, string xpath, string value) { SPWebConfigModification modification = new SPWebConfigModification(name, xpath); modification.Owner = this.OwnerModify; modification.Sequence = 0; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute; modification.Value = value; return modification; }
protected void AddNodeValue(string name, string xpath, string scriptResource, SPWebConfigModification.SPWebConfigModificationType type, int sequence) { this.mListModifications.Add(this.GetSPWebModifChild(name, xpath, scriptResource,type, sequence)); }
public SPWebConfigModification Prepare() { var modification = new SPWebConfigModification(Name, XPath) { Owner = ConfigModsOwnerName, Sequence = 0, Type = ModificationType, Value = Value }; return modification; }
protected SPWebConfigModification GetSPWebModifChild(string name, string xpath, string scriptResource) { // name: Make sure that the name is a unique XPath selector for the element we are adding. This name is used for removing the element. // xpath: The XPath to the location of the parent node in web.config SPWebConfigModification modification = new SPWebConfigModification(name, xpath); // Owner: The owner of the web.config modification, useful for removing a group of modifications modification.Owner = OwnerModif; // Sequence: is important if there are multiple equal nodes that can't be identified with an XPath expression modification.Sequence = 0; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; // Value: The XML to insert as child node, make sure that used names match the Name selector modification.Value = scriptResource; return modification; }
protected SPWebConfigModification GetSPWebModifSection(string name, string xpath) { SPWebConfigModification modification = new SPWebConfigModification(name, xpath); modification.Owner = this.OwnerModify; modification.Sequence = 0; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureSection; return modification; }