Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 603051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:53:21+00:00 2026-05-13T16:53:21+00:00

I am stuck onto a very strange situation. I have a workflow that i

  • 0

I am stuck onto a very strange situation.

I have a workflow that i use to provision new site on my web application. This workflow uses one custom workflow activity to provision the site using followoing statement.

—other code omited for clarity—-

SPSiteCollection.Add()

This statement is throwing followign exception when my applicaiton pool account is not same as Central Admin applicaiton pool account.

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at
Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException
ex) at
Microsoft.SharePoint.Library.SPRequest.CreateSite(Guid
gApplicationId, String bstrUrl, Int32
lZone, Guid gSiteId, Guid gDatabaseId,
String bstrDat

after a lot of googling and findings i have zeroed down to the Applicaiton Pool account permission.

The workflow code always runs under the System account (the applicaiton pool identity). In order to create new SharePoint site collection, the application pool requires access to “SharePoint_Config” database.

When my web application is running under the applicaiton pool credential of Central Admin, it has all the access to the configuration database. But when i am running the under any other applicaiton pool identity which has less permission. it throws exception, even if i give DBO permission to the applicaiton pool account in the Configuration database.

My applicaiton event log has following entry :-

Event Source: Windows SharePoint
Services 3 Event Category: Database
Event ID: 3760 Date: 2/3/2010
Time: 2:36:16 AM User: N/A
Computer: SHAREPOINT20 Description:
SQL Database ‘SharePoint_Config’ on
SQL Server instance ‘houspsr001’ not
found. Additional error information
from SQL Server is included below.

Cannot open database
“SharePoint_Config” requested by the
login. The login failed. Login failed
for user ‘DOMAIN\WebAppPool’.

For more information, see Help and
Support Center at
http://go.microsoft.com/fwlink/events.asp.

My question is…is it mendatory to run such code under the applicaiton pool account of central admin.

Any workaround for this….?

My question

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:53:21+00:00Added an answer on May 13, 2026 at 4:53 pm

    Finally the access denied issue has been resolved. As I motioned in my previous email, the issue was due to insufficient permission to my application pool identity.

    • Central Admin was running under a different application pool identity
    • Web applications are running under a different application pool identity.

    My workflow was using the ElevatedPrevilages to provision a site collection, and it used to get Access Denied from the database since it did not had permission to modify SharePoint_Config database.

    Resolution
    In order to resolve this issue i had to impersonate the application pool identity of Central Admin. Here is the required method for impersonating Central Admin application pool user.

       #region Application Pool Identity Impersonate
    
            protected static WindowsIdentity CreateIdentity(string User, string Domain, string Password)
            {
                // The Windows NT user token.
                IntPtr tokenHandle = new IntPtr(0);
    
                const int LOGON32_PROVIDER_DEFAULT = 0;
                const int LOGON32_LOGON_NETWORK = 3;
    
                tokenHandle = IntPtr.Zero;
    
                // Call LogonUser to obtain a handle to an access token.
                int returnValue = LogonUser(User, Domain, Password,LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT,out tokenHandle);
    
                //Check if the logon user method succeeded
                if (returnValue <= 0)
                {
                    int ret = Marshal.GetLastWin32Error();
                    throw new Exception("LogonUser failed with error code: " + ret);
                }
    
                //System.Diagnostics.Debug.WriteLine("Created user token: " + tokenHandle);
    
                //The WindowsIdentity class makes a new copy of the token.
                //It also handles calling CloseHandle for the copy.
                WindowsIdentity id = new WindowsIdentity(tokenHandle);
                CloseHandle(tokenHandle);
                return id;
            }
    
            [DllImport("advapi32.dll", SetLastError = true)]
            public static extern int LogonUser(
                string lpszUsername,
                string lpszDomain,
                string lpszPassword,
                int dwLogonType,
                int dwLogonProvider,
                out IntPtr phToken
                );
            [DllImport("advapi32.dll", SetLastError = true)]
            public static extern int ImpersonateLoggedOnUser(
                IntPtr hToken
            );
    
            [DllImport("advapi32.dll", SetLastError = true)]
            static extern int RevertToSelf();
    
            [DllImport("kernel32.dll", SetLastError = true)]
            static extern int CloseHandle(IntPtr hObject);
    
            #endregion
    

    And then my code to create site collection looks like:-

    //Impersonate the logged in user, ApplicationUser, LoginDomain and Password are exposed as property of the class.
    
    WindowsImpersonationContext wiContext = CreateIdentity(this.ApplicationPoolUser, this.LoginDomain, this.SystemPassword).Impersonate();
    
    
    
    //Provision new site collection and update the property for new site collection url.
    
    using (SPSite newSiteCollection = spSiteColl.Add(SUGGESTEDURL, TITLE, DESC, LCID, WEBTEMPLATE, PRIMARYOWNER.LoginName, PRIMARYOWNER.Name, PRIMARYOWNER.Email, SECONDARYOWNER.LoginName, SECONDARYOWNER.Name, SECONDARYOWNER.Email))
    
    {
    
    this.SUGGESTEDURL = newSiteCollection.Url;
    
    }
    
    
    
    //Reset the impersonation.
    
    wiContext.Undo();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET web site which contains some ImageButton controls that cause postbacks
Kinda stuck here... I have an application with lets say 5000 rows of data
When running javap on a very simple HelloWorld application I have some confusion on
Very confused over this. I've just started learning about pointers and have now decided
I am sure that for most this is a very easy question. But I
How can i stack images onto eachother? My problem is that i want the
When the ebp register is pushed onto the stack (this is on IA-32 architecture)
I'm implementing a stack application, however every time I push an item onto the
On occasion, I have wanted to push a closure onto ActionScript's event stack so
Stuck on KVCs in Obj-C again. I am wanting to use KVC to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.