Access denied when adding web application features programmatically

user298
  • Access denied when adding web application features programmatically user298

    My goal is to programmatically activate a Web Application scoped feature. I'm running this code from a feature receiver of a Web scoped feature. I'm logged in as a Farm Administrator. My app pool account is the same account (also Farm Admin). These two snippets don't work. In both cases, the SecurityException is thrown with a message "Access Denied."

    //using{} omitted for brevity
    
    public override void FeatureActivated(SPFeatureReceiverProperties properties) {
        SPWeb web = properties.Feature.Parent as SPWeb;
        web.Site.WebApplication.Features.Add( /*guid*/ ); //throws SecurityException
    }
    

    I also tried.

    public override void FeatureActivated(SPFeatureReceiverProperties properties) {
        SPWeb web = properties.Feature.Parent as SPWeb;
        SPSecurity.RunWithElevatedPrivileges( () =>
        {
            SPSite elevatedSite = new SPSite(web.Site.ID);
            elevatedSite.WebApplication.Features.Add( /*guid*/ ); //throws SecurityException
        });
    }
    

    I don't understand why I would be getting this error if both the app pool acct and the current user are Farm Administrators. Please help.

  • So you're trying to activate an application wide feature from within a single collection? I've never tried this, but I'm wondering if SharePoint would even let you do it since potentially a user in one isolated collection could effect all users in any collection of that app. It may only let you "manage" objects at the current level and below. Do you have any other error trapping beyond what SharePoint is dumping out by default?

Tags
2007 feature-activation
Related questions and answers
  • that the App pool user for your content web application does not have write access to the Config database, you can't create new TimerJobDefinitions from code that runs in your content web app. A bad... the Central Admin app pool account can write to the config database But then we lose the whole point - I want my site collection administrators to be able to manage the schedule! The only alternative solution... to that queue from within the content web app using the custom schedule admin page. My question is, is there another way that is both efficient and elegant?

  • isn't in the IIS metabase because it's being handled by DNS. My web application has an AAM set up and a host header on the web site in IIS. I also tried running the code without using the FQDN of the site, e.g. http: //servername:4860. Permissions: The identity of the the Silverlight application pool has db_owner permissions to my content database, and is also a site collection administrator. I can't have both web sites use the same application pool because the Silverlight application needs to run in a .NET app pool. x86 vs x64: My Silverlight application has to be compiled for x86 - I'm

  • does activate the webpart but i also want to remove it when deactivating it.(So i know i need to add something to the FeatureDeactivating So i created a Feature With Reciever template and added it to the project.Which created a folder FeatureWithReceiver with the element and feature xml files and also a FeatureCode folder with FeatureWithReceiver.cs public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPSite site = null; try { site = properties.Feature.Parent as SPSite; using (SPWeb web = site.RootWeb

  • but I still get an access denied when calling SPWebbApplication.Sites.Add(), even though all SPSite and SPWeb pbjects are being instantiated inside the elevated code block. I have tried direct... this task however this caused major headaches and even though the web service was running in an app pool using the same identity as the sharepoint app pool I could not get this to work. Also had form digest...I have a need to allow non farm administrators to be able to create site collections using a very specific site definition. These people will not have access to central admin and so require a custom

  • Im not sure if this is possible without impersonating a user/service account (and therefore hard coding credentials) that has farm level access... The situation is I want to access an SPSite in another web application (not the context web app my code is runnning in). The context web application and the web application I want to access have different application pool identities so SPSecurity.RunWithElevatedPrivileges fails (as it should). Is there a method that anyone can suggest to gain access to resources in another web application?

  • I have a standard website (one Web Application and one Site Collection) with some custom pages and webparts. The issue I'm having is that when I try to switch users, using the "Sign In As a Different User" and entering new credentials (even for another Site Collection admin account), IE tries the account three times, and then it presents a 401 Access Denied screen. After that, if I erase all the stuff of access denied page from the browser's url, I'm logged as the new account I just had entered and was not accepted. After researching for a while on google, I found a KB ( http

  • , this is the reason for my post. I cannot get this code to execute from within a console application. Does the SPList.SaveAsTemplate method require a HttpContext? If it does it is not metioned in any of the docs...\Lists\ListHelper.vb:line 111 at XXXXXX_Feature_Receiver.XXXXXXDataStructureFeatureFactory.CreateOrUpdateListInstances(SPWeb Web) in C:\TestBed\XXXXXX Feature Receiver Development\XXXXXX Feature Receiver\XXXXXXDataStructureFeatureFactory.vb:line 37 at XXXXXX_Feature_Receiver.XXXXXXDataStructureFeatureFactory.Initiate(SPWeb Web) in C:\TestBed\XXXXXX Feature Receiver

  • Crawling some external sites failed Ovidiu BecheĊŸ-Puia

    I'm using Search Server Express + WSS 3.0. I wanna crawl external public web sites. One site is : http://www.av.se/ When I try a full crawl it is throwing: http://www.av.se Access is denied. Check that the Default Content Access Account has access to this content, or add a crawl rule to crawl this content. Local sites and other public sites are getting crawled OK. What is wrong with that sit? Can you add it on Content sources and try a full crawl for testing?

  • the log file and there are a lot of entries regarding stsadmin, a few exceptions (access denied) even though I am both a server administrator and a farm administrator (everything is all and the same server... jobs running at the time, plus I tried a reboot and got the same error message. I also try to start Forefront Identity Manager Service and it stops straight away (domain account or local system...My name seems to be appearing as DOMAIN\UserName for sites that I create (and sometimes sites that others have created as well) rather than Forename Surname, why is this happening? It is on an Active

Data information