English 中文(简体)
SPWebConfigModification班将不会更新中央排雷应用网。 简讯
原标题:SPWebConfigModification class will not update Central Admin application s web.config file

采用“2010年共享点” 我正试图利用SPWebConfig Modification等课程,对包括中央行政管理网在内的农场应用的网络文件进行一些基本改动。 采用网络应用特征的组合文档,由处理修改内容的接收器进行:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
        String ownerId = properties.Feature.DefinitionId.ToString();
        List<SPWebConfigModification> modsToAdd = new List<SPWebConfigModification>();

        #region Authentication Providers

        modsToAdd.Add(new SPWebConfigModification()
        {
            Name = "defaultProvider",
            Owner = ownerId,
            Path = "configuration/system.web/membership",
            Sequence = 0,
            Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute,
            Value = "FBA_AD_MP"
        });

        modsToAdd.Add(new SPWebConfigModification()
        {
            Name = "add [@name="FBA_AD_MP"] [@type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"] [@connectionStringName="ADFBAConnectionString"] [@enableSearchMethods="true"] [@attributeMapUsername="userPrincipalName"]",
            Owner = ownerId,
            Path = "configuration/system.web/membership/providers",
            Sequence = 0,
            Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode,
            Value = "<add name="FBA_AD_MP" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADFBAConnectionString" enableSearchMethods="true" attributeMapUsername="userPrincipalName" />"
        });

        #endregion

        #region Connection Strings

        modsToAdd.Add(new SPWebConfigModification()
        {
            Name = "connectionStrings",
            Owner = ownerId,
            Path = "configuration",
            Sequence = 0,
            Type = SPWebConfigModification.SPWebConfigModificationType.EnsureSection,
            Value = "<connectionStrings />"
        });

        modsToAdd.Add(WebConfigModificationsUtility.CreateConnectionStringModification(ownerId, 1, "ADFBAConnectionString", properties.Feature.Properties["ADFBAConnectionString"].Value));

        #endregion

        WebConfigModificationsUtility.AddWebConfigModifications(webApp, modsToAdd.ToArray());
    }

网络校正班是这些专题接收器共用的简单用途:

public static void AddWebConfigModifications(SPWebApplication webApp, params SPWebConfigModification[] modificationsToAdd)
    {
        AddWebConfigModifications(webApp, true, modificationsToAdd);
    }
public static void AddWebConfigModifications(SPWebApplication webApp, Boolean persistChanges, params SPWebConfigModification[] modificationsToAdd)
    {
        foreach (SPWebConfigModification curMod in modificationsToAdd)
        {
            SPWebService.ContentService.WebApplications[webApp.Id].WebConfigModifications.Add(curMod);                
        }

        if (persistChanges)
        {
            PersistWebConfigModifications(webApp);
        }
    }
public static void PersistWebConfigModifications(SPWebApplication webApp)
    {
        SPWebService.ContentService.WebApplications[webApp.Id].Update();                        
        SPWebService.ContentService.ApplyWebConfigModifications();
    }

在内容申请方面,所有项目都在进行罚款,但在试图在中央行政网络应用上激活特征时,SPWebConfig Modificaiton项目从来都不在网上书写。 我已经核实,该守则毫无例外地得到执行。 此外,我的特稿接收人试图取消任何改动,以取消:

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
            String ownerId = properties.Feature.DefinitionId.ToString();
            WebConfigModificationsUtility.RemoveWebConfigModifications(webApp, ownerId);
        }
public static void RemoveWebConfigModifications(SPWebApplication webApp, String ownerId, Boolean persistChanges)
        {            
            RemoveWebConfigModifications(webApp, persistChanges, webApp.WebConfigModifications.Where(x => x.Owner == ownerId).ToArray());
        }
public static void RemoveWebConfigModifications(SPWebApplication webApp, Boolean persistChanges, params SPWebConfigModification[] modificationsToRemove)
        {
            foreach (SPWebConfigModification curMod in modificationsToRemove)
            {
                SPWebService.ContentService.WebApplications[webApp.Id].WebConfigModifications.Remove(curMod);                
            }

            if (persistChanges)
            {
                PersistWebConfigModifications(webApp);
            }
        }

当该守则在中央集束网络应用上运行时,它发现在功能启动方面产生了四项修改,并成功地消除了这些修改,但这些行动中的neither实际上正在改变网络。 浏览网络申请的专栏;甚至连字都没有触及,最后编辑日期的印记在整个过程中始终不变。

我发现各种博客,谈到SPWebConfig Modification等级的继承陷阱,大多数问题都是妥善使用姓名和所有权,以及适当坚持使用SPWebservice固定财产进行变革,但我能按照所有建议的做法告诉Im。 我开始怀疑安普兰有了一个 b子,但我很想知道,在2010年“共同点”中,是否有任何人成功这样做,或者我是否应该打开反镜,试图看到什么?

最佳回答

同内容服务一样,SPWeb Services有一个行政服务标,还有网上复制品收集。 利用行政服务局进入你中央排雷网。

问题回答

SPWebConfig Mondification将不会更新中央行政管理网站。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签