Ads

Tuesday, 7 March 2017

Use C# code to create new Web Application in Sharepoint 2010 Enabling FBA


SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local);
webAppBuilder.Port = portNo;webAppBuilder.ApplicationPoolId = "IIS application ID";
webAppBuilder.IdentityType = IdentityType.SpecificUser;
webAppBuilder.ManagedAccount = mngAcc;
webAppBuilder.RootDirectory = new DirectoryInfo("physical path of web application"));
webAppBuilder.ServerComment = "Server comment";
webAppBuilder.UseNTLMExclusively = true;
webAppBuilder.AllowAnonymousAccess = false;
webAppBuilder.CreateNewDatabase = true;
webAppBuilder.DatabaseServer = "SQL Server name";
webAppBuilder.DatabaseName = "Database name";
if ("SQL Authentication is selected")
{
   webAppBuilder.DatabaseUsername = "username";
   webAppBuilder.DatabasePassword = "password";
}
newApplication = webAppBuilder.Create();
SPFormsAuthenticationProvider fbaAuthProvider = new SPFormsAuthenticationProvider(membershipProvider, roleManager);

newApplication.UseClaimsAuthentication = true;
newApplication.IisSettings[SPUrlZone.Default].AddClaimsAuthenticationProvider(fbaAuthProvider);
newApplication.Update();
newApplication.Provision();

No comments:

Post a Comment

Ads