private void DeployManagedAccount(object modelHost, SPFarm farm, ManagedAccountDefinition managedAccountDefinition) { var currentAccount = GetManagedAccount(farm, managedAccountDefinition); var loginName = managedAccountDefinition.LoginName; var accounts = new SPFarmManagedAccountCollection(farm); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = currentAccount, ObjectType = typeof(SPManagedAccount), ObjectDefinition = managedAccountDefinition, ModelHost = modelHost }); if (currentAccount == null) { TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new managed account"); currentAccount = accounts.FindOrCreateAccount(loginName); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentAccount, ObjectType = typeof(SPManagedAccount), ObjectDefinition = managedAccountDefinition, ModelHost = modelHost }); currentAccount.Update(); } else { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing managed account"); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentAccount, ObjectType = typeof(SPManagedAccount), ObjectDefinition = managedAccountDefinition, ModelHost = modelHost }); currentAccount.Update(); } }
private void DeployManagedAccount(object modelHost, SPFarm farm, ManagedAccountDefinition managedAccountDefinition) { var currentAccount = GetManagedAccount(farm, managedAccountDefinition); var loginName = managedAccountDefinition.LoginName; var accounts = new SPFarmManagedAccountCollection(farm); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = currentAccount, ObjectType = typeof(SPManagedAccount), ObjectDefinition = managedAccountDefinition, ModelHost = modelHost }); if (currentAccount == null) { TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new managed account"); currentAccount = accounts.FindOrCreateAccount(loginName); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentAccount, ObjectType = typeof(SPManagedAccount), ObjectDefinition = managedAccountDefinition, ModelHost = modelHost }); currentAccount.Update(); } else { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing managed account"); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentAccount, ObjectType = typeof(SPManagedAccount), ObjectDefinition = managedAccountDefinition, ModelHost = modelHost }); currentAccount.Update(); } }
private void DeployWebApplication(FarmModelHost farmModelHost, SPFarm farm, WebApplicationDefinition webApplicationDefinition) { var webApps = SPWebService.ContentService.WebApplications; var webAppBuilder = new SPWebApplicationBuilder(farm); webAppBuilder.Port = webApplicationDefinition.Port; webAppBuilder.ApplicationPoolId = webApplicationDefinition.ApplicationPoolId; if (!string.IsNullOrEmpty(webApplicationDefinition.ManagedAccount)) { webAppBuilder.IdentityType = IdentityType.SpecificUser; var managedAccounts = new SPFarmManagedAccountCollection(SPFarm.Local); var maccount = managedAccounts.FindOrCreateAccount(webApplicationDefinition.ManagedAccount); webAppBuilder.ManagedAccount = maccount; } else { webAppBuilder.ApplicationPoolUsername = webApplicationDefinition.ApplicationPoolUsername; var password = new SecureString(); foreach (char c in webApplicationDefinition.ApplicationPoolPassword.ToCharArray()) { password.AppendChar(c); } webAppBuilder.ApplicationPoolPassword = password; } webAppBuilder.CreateNewDatabase = webApplicationDefinition.CreateNewDatabase; webAppBuilder.DatabaseName = webApplicationDefinition.DatabaseName; webAppBuilder.DatabaseServer = webApplicationDefinition.DatabaseServer; webAppBuilder.UseNTLMExclusively = webApplicationDefinition.UseNTLMExclusively; webAppBuilder.HostHeader = webApplicationDefinition.HostHeader; webAppBuilder.AllowAnonymousAccess = webApplicationDefinition.AllowAnonymousAccess; webAppBuilder.UseSecureSocketsLayer = webApplicationDefinition.UseSecureSocketsLayer; var webApp = webAppBuilder.Create(); webApp.Provision(); }
private void DeployWebApplication(FarmModelHost farmModelHost, SPFarm farm, WebApplicationDefinition webApplicationDefinition) { var webApps = SPWebService.ContentService.WebApplications; var webAppBuilder = new SPWebApplicationBuilder(farm); webAppBuilder.Port = webApplicationDefinition.Port; webAppBuilder.ApplicationPoolId = webApplicationDefinition.ApplicationPoolId; if (!string.IsNullOrEmpty(webApplicationDefinition.ManagedAccount)) { webAppBuilder.IdentityType = IdentityType.SpecificUser; var managedAccounts = new SPFarmManagedAccountCollection(SPFarm.Local); var maccount = managedAccounts.FindOrCreateAccount(webApplicationDefinition.ManagedAccount); webAppBuilder.ManagedAccount = maccount; } else { webAppBuilder.ApplicationPoolUsername = webApplicationDefinition.ApplicationPoolUsername; var password = new SecureString(); foreach (char c in webApplicationDefinition.ApplicationPoolPassword.ToCharArray()) password.AppendChar(c); webAppBuilder.ApplicationPoolPassword = password; } webAppBuilder.CreateNewDatabase = webApplicationDefinition.CreateNewDatabase; webAppBuilder.DatabaseName = webApplicationDefinition.DatabaseName; webAppBuilder.DatabaseServer = webApplicationDefinition.DatabaseServer; webAppBuilder.UseNTLMExclusively = webApplicationDefinition.UseNTLMExclusively; webAppBuilder.HostHeader = webApplicationDefinition.HostHeader; webAppBuilder.AllowAnonymousAccess = webApplicationDefinition.AllowAnonymousAccess; webAppBuilder.UseSecureSocketsLayer = webApplicationDefinition.UseSecureSocketsLayer; var webApp = webAppBuilder.Create(); webApp.Provision(); }
private void DeployWebApplication(FarmModelHost farmModelHost, SPFarm farm, WebApplicationDefinition definition) { var webApps = SPWebService.ContentService.WebApplications; var existingWebApp = FindWebApplication(definition, webApps); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingWebApp, ObjectType = typeof(SPWebApplication), ObjectDefinition = definition, ModelHost = farmModelHost }); if (existingWebApp == null) { var webAppBuilder = new SPWebApplicationBuilder(farm); webAppBuilder.Port = definition.Port; webAppBuilder.ApplicationPoolId = definition.ApplicationPoolId; if (!string.IsNullOrEmpty(definition.ManagedAccount)) { webAppBuilder.IdentityType = IdentityType.SpecificUser; var managedAccounts = new SPFarmManagedAccountCollection(SPFarm.Local); var maccount = managedAccounts.FindOrCreateAccount(definition.ManagedAccount); webAppBuilder.ManagedAccount = maccount; } else { webAppBuilder.ApplicationPoolUsername = definition.ApplicationPoolUsername; var password = new SecureString(); foreach (char c in definition.ApplicationPoolPassword.ToCharArray()) { password.AppendChar(c); } webAppBuilder.ApplicationPoolPassword = password; } webAppBuilder.CreateNewDatabase = definition.CreateNewDatabase; webAppBuilder.DatabaseName = definition.DatabaseName; webAppBuilder.DatabaseServer = definition.DatabaseServer; webAppBuilder.UseNTLMExclusively = definition.UseNTLMExclusively; webAppBuilder.HostHeader = definition.HostHeader; webAppBuilder.AllowAnonymousAccess = definition.AllowAnonymousAccess; webAppBuilder.UseSecureSocketsLayer = definition.UseSecureSocketsLayer; var webApp = webAppBuilder.Create(); webApp.Provision(); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = webApp, ObjectType = typeof(SPWebApplication), ObjectDefinition = definition, ModelHost = farmModelHost }); } else { InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingWebApp, ObjectType = typeof(SPWebApplication), ObjectDefinition = definition, ModelHost = farmModelHost }); } }