I am trying to create a SharePoint web application (on SharePoint2007) in C#. How differently I tried, it ends up with the same access denied error in the Provisioning step. The error message does not contain much details. It only says COM Error : Access Denied. Below is my code.
SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local);
webAppBuilder.ServerComment = "App1";
webAppBuilder.Port = 81;
webAppBuilder.RootDirectory = new DirectoryInfo(@"C:\Inetpub\wwwroot\wss\VirtualDirectories\81");
webAppBuilder.UseNTLMExclusively = true;
webAppBuilder.AllowAnonymousAccess = false;
webAppBuilder.UseSecureSocketsLayer = false;
webAppBuilder.ApplicationPoolId = "SharePoint - 81";
webAppBuilder.IdentityType = IdentityType.NetworkService;
webAppBuilder.CreateNewDatabase = true;
webAppBuilder.DatabaseServer = "abcdef"; //Database server
webAppBuilder.DatabaseName = "WebApp81"; // Database name
SPWebApplication newApplication = webAppBuilder.Create();
newApplication.Provision(); //Provision it into web farm
The last line is the one that gives the error. Access Denied.
I'm using a domain account. When I investigated a little bit more I saw,
- The database and the set of tables are created.
- At SharePoint admin page web application lists, the application is listed.
- But I can't create a site collection in it (Since Provisioning has not properly been completed)
Have someone got any idea of what I am missing here?
Thanks a lot...