Provision
private void ProvisionSampleApplication(SPFarm LocalFarm, string appPoolUserName, int port){
SPWebApplicationBuilder webAppBuilder = null;
SPWebApplication newApplication = null;
SPSite mySiteCollection = null;
try
{
webAppBuilder = new SPWebApplicationBuilder(LocalFarm);
webAppBuilder.Port = port;
webAppBuilder.ApplicationPoolId = "site-apppool" + port.ToString(); // application pool
webAppBuilder.UseNTLMExclusively = true; // Use NTLM authentication
newApplication = webAppBuilder.Create(); // Create new web application
newApplication.Provision(); //Provision it into web LocalFarm
mySiteCollection = newApplication.Sites.Add("/",//Root
"Uluru Server", // site title
"Uluru Server", //description
1033, //language
"STS#1", //Blank site template
appPoolUserName, // Site owner
appPoolUserName, // Name
mySiteCollection.Close();
}
finally
{
if (mySiteCollection != null) mySiteCollection.Dispose();
}
}
Unprovision
private void UnProvisionProvisionSampleApplication(string uri){
SPWebApplication webApplication = null;
webApplication = SPWebApplication.Lookup(new Uri(uri));
// Deletes the WebApplication
webApplication.Delete();
// Deletes the Database
webApplication.Unprovision();
}
0 comments:
Post a Comment