title: SharePoint 2010 - Access denied during ApplyWebConfigModifications()
body: <p>I have SharePoint 2010 installed on a Windows Server 2008 R2 machine which is also hosting SQL Sever 2008 R2.  I am attempting to deploy a solution that includes web parts in the 2010 environment that is working fine in MOSS 2007.</p>
  
  <p>The Web Part feature has a feature receiver that updates the web.config.  When I try to activate the feature through the Site Collection Feature GUI, I receive an access denied message.  I am logged on to the server and in SharePoint with the APP Pool account which is also a member of the domain administrator group, local administrator group and SharePoint Farm Admin group.  This account is also dbo on SQL Server.</p>
  
  <p>This same feature activates fine using the stsadm command.</p>
  
  <p>I have dug into this issue at length and here is what I have found:</p>
  
  <p>Looking at the Microsoft assemblies in reflector, my error is coming from the SPWebApplication.ApplyWebConfigModifications() method.  I can see the trace statements from SPWebConfigFileChanges.RemoveModificationsWebConfigXMLDocument and SPWebConfigFileChanges.ApplyModificationsWebConfigXMLDocument.  The next line is a Save(str).</p>
  
  <p>Below is the output from the SharePoint logs that pertain to this error:</p>
  
  <blockquote>
    <p>Apply web config modifications to web
    app<br>
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    General                           8grn
    Medium      WebConfigModification:
    Applying web config modifications to
    web app in server tw-s1-m4400-007<br>
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          88gw
    Medium      WebConfigModification:
    Applying web config modifications to
    file
    C:\inetpub\wwwroot\wss\VirtualDirectories\2008\web.config
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          887b
    Medium      Removing web config node -
    Path
    configuration/system.web/httpModules
    Node name
    add[@name='JivePageController']<br>
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          887b
    Medium      Removing web config node -
    Path
    configuration/system.web/httpHandlers
    Node name
    add[@path='ScriptResource.axd']<br>
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          887b
    Medium      Removing web config node -
    Path
    configuration/runtime/*[local-name()="assemblyBinding"
    and
    namespace-uri()="urn:schemas-microsoft-com:asm.v1"]
    Node name
    <em>[local-name()="dependentAssembly"][</em>/@name="System.Web.Extensions.Design"]
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          887b
    Medium      Removing web config node -
    Path
    configuration/runtime/*[local-name()="assemblyBinding"
    and
    namespace-uri()="urn:schemas-microsoft-com:asm.v1"]
    Node name
    <em>[local-name()="dependentAssembly"][</em>/@name="System.Web.Extensions"]
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          8gp8
    Medium      WebConfigModification:
    Adding web config node - Path -
    configuration/runtime/*[local-name()="assemblyBinding"
    and
    namespace-uri()="urn:schemas-microsoft-com:asm.v1"]
    Node name -
    <em>[local-name()="dependentAssembly"][</em>/@name="System.Web.Extensions"]
    Node value -
    
    in web.config file
    C:\inetpub\wwwroot\wss\VirtualDirectories\2008\web.config
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          8gp8
    Medium      WebConfigModification:
    Adding web config node - Path -
    configuration/runtime/*[local-name()="assemblyBinding"
    and
    namespace-uri()="urn:schemas-microsoft-com:asm.v1"]
    Node name -
    <em>[local-name()="dependentAssembly"][</em>/@name="System.Web.Extensions.Design"]
    Node value -
     in web.config
    file
    C:\inetpub\wwwroot\wss\VirtualDirectories\2008\web.config
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          8gp8
    Medium      WebConfigModification:
    Adding web config node - Path -
    configuration/system.web/httpHandlers
    Node name -
    add[@path='ScriptResource.axd'] Node
    value -  in web.config file
    C:\inetpub\wwwroot\wss\VirtualDirectories\2008\web.config
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          8gp8
    Medium      WebConfigModification:
    Adding web config node - Path -
    configuration/system.web/httpModules
    Node name -
    add[@name='JivePageController'] Node
    value -  in web.config file
    C:\inetpub\wwwroot\wss\VirtualDirectories\2008\web.config
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.09     w3wp.exe
    (0x15C4)<br>
    0x1444    SharePoint Foundation<br>
    Topology                          e5mb
    Medium      WcfReceiveRequest:
    LocalAddress:
    '<a href="http://tw-s1-m4400-007.jivedemo.local:32843/15702467ece1408f881abeabac3b5077/MetadataWebService.svc" rel="nofollow noreferrer">http://tw-s1-m4400-007.jivedemo.local:32843/15702467ece1408f881abeabac3b5077/MetadataWebService.svc</a>'
    Channel:
    'System.ServiceModel.Channels.ServiceChannel'
    Action: xxx MessageId:
    'urn:uuid:4e859532-ed7f-4937-8b88-68d3af43d589'
    9f403ede-2c94-490b-a05c-e169cc5fe58d</p>
    
    <p>02/24/2010 16:05:41.10     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          f6kh
    High        WebConfigModification:
    Save of web.config file
    C:\inetpub\wwwroot\wss\VirtualDirectories\2008\web.config
    for applying modifications to web app
    SharePoint - 2008 failed. Error
    message - Access to the path
    'C:\inetpub\wwwroot\wss\VirtualDirectories\2008\web.config'
    is denied.<br>
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
    
    <p>02/24/2010 16:05:41.10     w3wp.exe
    (0x0F64)<br>
    0x1034    SharePoint Foundation<br>
    Topology                          8j2o
    High        WebConfigModification:
    Changes not applied to web application
    SharePoint - 2008 with Url xxx<br>
    5a817a37-7bf6-4d26-be51-207369e38f5b</p>
  </blockquote>
  
  <p>Any help would be appreciated!</p>