protected void OnApplicationPoolValidate(object source, ServerValidateEventArgs e) { if (e != null && e.IsValid) { string uniqueID = DialogMaster.OkButton.UniqueID; string eventTarget = Request.Params["__EVENTTARGET"]; if (!string.IsNullOrEmpty(eventTarget) && eventTarget == uniqueID) { try { IisWebServiceApplicationPoolSection section = ApplicationPoolSection as IisWebServiceApplicationPoolSection; _applicationPool = (section == null) ? null : section.GetOrCreateApplicationPool(); } catch (Exception ex) { if (ex is SPDuplicateObjectException) { ApplicationPoolValidator.ErrorMessage = "Application Pool with the given name already exists"; } else { ApplicationPoolValidator.ErrorMessage = "Application Pool could not be created"; } e.IsValid = false; } } } }
/// <summary> /// This method gets invoked when the command is called /// </summary> protected override void InternalProcessRecord() { SPIisWebServiceApplicationPool resolvedApplicationPool = this.ApplicationPool.Read(); if (resolvedApplicationPool == null) { this.ThrowTerminatingError(new InvalidOperationException("Could not find the specified application pool."), ErrorCategory.InvalidOperation, this); } if (this.ShouldProcess(this.Name)) { // Get or create the service ClubCloudService service = ClubCloudService.GetOrCreateService(); // Get or create the service proxy ClubCloudServiceProxy.GetOrCreateServiceProxy(); // Install the service instances to servers in this farm ClubCloudServiceInstance.CreateServiceInstances(service); // Create the service application ClubCloudServiceApplication application = new ClubCloudServiceApplication(this.Name, service, resolvedApplicationPool); application.Update(); application.Provision(); // Database settings if (string.Equals(this.ParameterSetName, "DB", StringComparison.OrdinalIgnoreCase)) { NetworkCredential databaseCredentials = null; if (this.DatabaseCredentials != null) { databaseCredentials = (NetworkCredential)this.DatabaseCredentials; } SPDatabaseParameters databaseParameters = SPDatabaseParameters.CreateParameters(this.DatabaseName, this.DatabaseServerName, databaseCredentials, this.DatabaseFailoverServerName, SPDatabaseParameterOptions.None); // Create the database ClubCloudDatabase database = new ClubCloudDatabase(databaseParameters); // Provision the database (runs the Create scripts) database.Provision(); // Grant the database the proper permissions database.GrantApplicationPoolAccess(resolvedApplicationPool.ProcessAccount.SecurityIdentifier); // Add the failover server instance (the base class does not do this for you) if (!string.IsNullOrEmpty(this.DatabaseFailoverServerName)) { database.AddFailoverServiceInstance(this.DatabaseFailoverServerName); } // Establish a relationship between the service application and the database application.Database = database; application.Update(); } this.WriteObject(application); } }
public static NodeServiceApplication Create(string name, NodeService service, SPIisWebServiceApplicationPool appPool) { if (name == null) { throw new ArgumentNullException("name"); } if (service == null) { throw new ArgumentNullException("service"); } if (appPool == null) { throw new ArgumentNullException("appPool"); } // Create the service application. NodeServiceApplication serviceApplication = new NodeServiceApplication(name, service, appPool); serviceApplication.Update(); // Register the supported endpoints. serviceApplication.AddServiceEndpoint("http", SPIisWebServiceBindingType.Http); serviceApplication.AddServiceEndpoint("https", SPIisWebServiceBindingType.Https, "secure"); return serviceApplication; }
/// <summary> /// UpdateServiceApp method implementation /// </summary> private void UpdateServiceApp() { using (var operation = new SPLongOperation(this)) { operation.Begin(); NetworkCredential cred = null; string name = null; try { name = this.txtServiceApplicationName.Text.Trim(); ContentDatabaseSection db = this.DatabaseSection; if (db.UseWindowsAuthentication) { cred = CredentialCache.DefaultNetworkCredentials; } else { cred = new NetworkCredential(db.DatabaseUserName, db.DatabasePassword); } SPIisWebServiceApplicationPool ap = (this.ApplicationPoolSection == null) ? null : this.ApplicationPoolSection.GetOrCreateApplicationPool(); Utilities.UpdateServiceApplicationAndProxy(true, this.ServiceApplication, name, ap, db.DatabaseName.Trim(), db.DatabaseServer.Trim(), db.FailoverDatabaseServer, cred, false, CBReplaceDB.Checked); Utilities.CreateUpdateDeleteClaimProvider(name, this.InputClaimProviderDropBox.SelectedValue, this.txtInputFormDisplayClaimName.Text, this.txtInputFormTextClaimDesc.Text, this.visibilityCB.Checked, this.CanUpdateProvider()); } catch (Exception ex) { // new SPException(String.Format("Failed to update service applicaton {0}", name), ex); RedirectToErrorPage(String.Format("Failed to create service applicaton {0} \n Execption : {1}", name, ex.Message)); } } }
public SPIisWebServiceApplicationPoolInstance(ObjectInstance prototype, SPIisWebServiceApplicationPool iisWebServiceApplicationPool) : this(prototype) { if (iisWebServiceApplicationPool == null) { throw new ArgumentNullException("iisWebServiceApplicationPool"); } m_iisWebServiceApplicationPool = iisWebServiceApplicationPool; }
/// <summary> /// InternalProcessRecord method override /// </summary> protected override void InternalProcessRecord() { SPIisWebServiceApplicationPool applicationPool = this.ApplicationPool.Read(); if (null == applicationPool) { WriteError(new InvalidOperationException("The specified application pool could not be found."), ErrorCategory.InvalidArgument, this); SkipProcessCurrentRecord(); } this.WriteObject(Utilities.CreateServiceApplicationAndProxy(ShouldProcess(this.Name), this.Name, applicationPool, this.DatabaseName, this.DatabaseServer, this.FailoverDatabaseServer, (null == this.DatabaseCredentials ? null : this.DatabaseCredentials.GetNetworkCredential()), (this.m_resolvedb.IsPresent), this.m_useexistingdb.IsPresent)); }
/// <summary> /// Creates the service application. /// </summary> private void CreateApplication() { using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "CreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "CreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); try { ClubCloudService service = ClubCloudService.GetOrCreateService(); ClubCloudServiceProxy serviceProxy = ClubCloudServiceProxy.GetOrCreateServiceProxy(); // Create the application pool IisWebServiceApplicationPoolSection applicationPoolSectionCasted = this.applicationPoolSection as IisWebServiceApplicationPoolSection; SPIisWebServiceApplicationPool applicationPool = applicationPoolSectionCasted.GetOrCreateApplicationPool(); // Create the service application ClubCloudServiceApplication application = new ClubCloudServiceApplication( this.textBoxServiceName.Text.Trim(), service, applicationPool); application.Update(); application.Provision(); // Create the service application proxy ClubCloudServiceApplicationProxy proxy = new ClubCloudServiceApplicationProxy( string.Format( CultureInfo.CurrentCulture, HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ServiceApplicationProxyNameTemplate", CultureInfo.CurrentCulture).ToString(), this.textBoxServiceName.Text.Trim()), serviceProxy, application.Uri); proxy.Update(); proxy.Provision(); if (this.checkBoxIncludeInDefaultProxy.Checked) { SPServiceApplicationProxyGroup group = SPServiceApplicationProxyGroup.Default; group.Add(proxy); group.Update(); } operation.EndScript("window.frameElement.commitPopup();"); } catch (Exception ex) { SPUtility.TransferToErrorPage(ex.ToString()); } } }
private static void WaitAppPoolJob(SPIisWebServiceApplicationPool pool) { bool wait = true; var timeOut = DateTime.Now.AddMinutes(10); while (wait) { if (DateTime.Now > timeOut) { throw new TimeoutException(); } SPJobDefinition job = GetJob(pool.Id); if (job == null) { wait = false; } //FarmExtensions.ClearFarmCache(); Thread.Sleep(1000); } }
public static OutputQueue GetOrCreateApplicationPool(string name, string username, string password, out SPIisWebServiceApplicationPool applicationPool) { var outputQueue = new OutputQueue(); applicationPool = null; try { outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.CheckingExistingServiceApplicationPool, name)); applicationPool = LocalFarm.Get().GetObject(name, Guid.Empty, typeof(SPIisWebServiceApplicationPool)) as SPIisWebServiceApplicationPool; if (applicationPool != null) { outputQueue.Add(UserDisplay.ExistingServiceApplicationPoolFound); return(outputQueue); } outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.CreatingServiceApplicationPool, name)); Type appPoolType = null; Type optionsType = null; appPoolType = Type.GetType(string.Format(CultureInfo.InvariantCulture, "Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool, Microsoft.SharePoint, Version={0}.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", LocalFarm.Get().BuildVersion.Major)); optionsType = Type.GetType(string.Format(CultureInfo.InvariantCulture, "Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPoolProvisioningOptions, Microsoft.SharePoint, Version={0}.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", LocalFarm.Get().BuildVersion.Major)); if ((appPoolType != null) && (optionsType != null)) { var noneOption = optionsType.GetField("None").GetValue(optionsType); SPProcessAccount processAccount = LocalFarm.Get().DefaultServiceAccount; if (!string.IsNullOrEmpty(username)) { NTAccount account = new NTAccount(username); outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.CheckingExistingManagedAccount, username)); SPProcessAccount lookupAccount = SPProcessAccount.LookupManagedAccount((SecurityIdentifier)account.Translate(typeof(SecurityIdentifier))); if (lookupAccount != null) { processAccount = lookupAccount; } else if (!string.IsNullOrEmpty(password)) { outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.CreatingManagedAccount, username)); var securePassword = password.ToSecureString(); var accountConstructor = typeof(SPProcessAccount).GetConstructor(new[] { typeof(NTAccount), typeof(SecureString) }); processAccount = (SPProcessAccount)accountConstructor.Invoke(new object[] { account, securePassword }); Reflection.ExecuteMethod(processAccount.GetType(), processAccount, "FindOrCreateManagedAccount", new Type[] { }, null); } } MethodInfo beginProvision = appPoolType.GetMethod("BeginProvision", BindingFlags.Instance | BindingFlags.NonPublic); outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.ProvisioningServiceApplicationPool, name)); applicationPool = (SPIisWebServiceApplicationPool)Reflection.ExecuteMethod(appPoolType, "Create", new Type[] { typeof(SPFarm), typeof(String), typeof(SPProcessAccount) }, new object[] { LocalFarm.Get(), name, processAccount }); applicationPool.Update(); beginProvision.Invoke(applicationPool, new object[] { noneOption }); WaitAppPoolJob(applicationPool); outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.ProvisioningServiceApplicationPoolComplete, name)); } else { throw new InvalidOperationException("ApplicationPool"); } } catch (Exception exception) { outputQueue.Add(string.Format(CultureInfo.CurrentUICulture, NewsGator.Install.Resources.Exceptions.ApplicationPoolException, name, exception.Message), OutputType.Error, exception.ToString(), exception); } return(outputQueue); }
private OceanikServiceApplication(string name, OceanikService service, SPIisWebServiceApplicationPool appPool) : base(name, service, appPool) { }
private DayNamerServiceApplication(string name, DayNamerService service, SPIisWebServiceApplicationPool appPool) : base(name, service, appPool) { }
/// <summary> /// This method gets invoked when the command is called /// </summary> protected override void InternalProcessRecord() { SPServiceApplication resolvedApplication = null; ClubCloudServiceApplication castedApplication = null; resolvedApplication = this.Identity.Read(); if (resolvedApplication == null) { this.ThrowTerminatingError(new InvalidOperationException("No service application was found."), ErrorCategory.InvalidOperation, this); } castedApplication = resolvedApplication as ClubCloudServiceApplication; if (castedApplication == null) { this.ThrowTerminatingError(new InvalidOperationException("The service application provided was not of the correct type."), ErrorCategory.InvalidOperation, this); } if (this.ShouldProcess(castedApplication.Name)) { // Update the name if (!string.IsNullOrEmpty(this.Name) && (!string.Equals(this.Name.Trim(), castedApplication.Name, StringComparison.OrdinalIgnoreCase))) { // Get the service ClubCloudService service = SPFarm.Local.Services.GetValue <ClubCloudService>(); if (service != null) { // Check for duplicate name SPServiceApplication duplicateApplication = service.Applications[this.Name.Trim()]; if (duplicateApplication != null) { this.ThrowTerminatingError(new InvalidOperationException("A service application with that name already exists."), ErrorCategory.InvalidOperation, this); } } castedApplication.Name = this.Name.Trim(); } // Update the application pool if (this.ApplicationPool != null) { SPIisWebServiceApplicationPool resolvedApplicationPool = this.ApplicationPool.Read(); if (resolvedApplicationPool != null) { castedApplication.ApplicationPool = resolvedApplicationPool; } } if (this.DatabaseCredentials != null) { NetworkCredential databaseCredentials = (NetworkCredential)this.DatabaseCredentials; castedApplication.Database.Username = databaseCredentials.UserName; castedApplication.Database.Password = databaseCredentials.Password; } else if (!string.IsNullOrEmpty(castedApplication.Database.Username)) { castedApplication.Database.Username = null; castedApplication.Database.Password = null; } if (!string.IsNullOrEmpty(this.DatabaseFailoverServerName)) { castedApplication.Database.AddFailoverServiceInstance(this.DatabaseFailoverServerName); } else if (castedApplication.Database.FailoverServer != null) { castedApplication.Database.AddFailoverServiceInstance(null); } castedApplication.Database.Update(); castedApplication.Update(); } }
internal static SPPersistedObject Create(string name, SPPersistedObject service, SPIisWebServiceApplicationPool pool, SPDatabaseParameters dbParameters) { return((SPPersistedObject)Utilities.Reflection.ExecuteMethod(ServiceApplicationType, ServiceApplicationType, "Create", new[] { typeof(string), InnovationService.ServiceType, typeof(SPIisWebServiceApplicationPool), typeof(SPDatabaseParameters) }, new object[] { name, service, pool, dbParameters })); }
protected override void InternalProcessRecord() { #region validation stuff // ensure can hit farm SPFarm farm = SPFarm.Local; if (farm == null) { ThrowTerminatingError(new InvalidOperationException("SharePoint farm not found."), ErrorCategory.ResourceUnavailable, this); SkipProcessCurrentRecord(); } // ensure can hit local server SPServer server = SPServer.Local; if (server == null) { ThrowTerminatingError(new InvalidOperationException("SharePoint local server not found."), ErrorCategory.ResourceUnavailable, this); SkipProcessCurrentRecord(); } // ensure can hit service application CalcService service = farm.Services.GetValue <CalcService>(); if (service == null) { ThrowTerminatingError(new InvalidOperationException("Wingtip Calc Service not found (likely not installed)."), ErrorCategory.ResourceUnavailable, this); SkipProcessCurrentRecord(); } // ensure can hit app pool SPIisWebServiceApplicationPool appPool = this.ApplicationPool.Read(); if (appPool == null) { ThrowTerminatingError(new InvalidOperationException("Application pool not found."), ErrorCategory.ResourceUnavailable, this); SkipProcessCurrentRecord(); } #endregion // verify a service app doesn't already exist CalcServiceApplication existingServiceApp = service.Applications.GetValue <CalcServiceApplication>(); if (existingServiceApp != null) { WriteError(new InvalidOperationException("Wingtip Calc Service Application already exists."), ErrorCategory.ResourceExists, existingServiceApp); SkipProcessCurrentRecord(); } // create & provision the service app if (ShouldProcess(this.Name)) { CalcServiceApplication serviceApp = CalcServiceApplication.Create( this.Name, service, appPool); // provision the service app serviceApp.Provision(); // pass service app back to the PowerShell WriteObject(serviceApp); } }
public CvrServiceApplication(string name, CvrService service, SPIisWebServiceApplicationPool applicationPool) : base(name, service, applicationPool) { }
/// <summary> /// Initializes a new instance of the <see cref="ClubCloudServiceApplication"/> class. Use this constructor when creating a new Service Application (e.g. from code in your Create page) /// </summary> /// <param name="name">The name of the service application.</param> /// <param name="service">The <see cref="ClubCloudService" />.</param> /// <param name="customDatabase">A custom database to associate with this service application.</param> /// <param name="applicationPool">The application pool.</param> internal ClubCloudServiceApplication(string name, ClubCloudService service, ClubCloudDatabase customDatabase, SPIisWebServiceApplicationPool applicationPool) : base(name, service, applicationPool) { if (customDatabase == null) { throw new ArgumentNullException("customDatabase"); } this.database = customDatabase; }
/// <summary> /// Initializes a new instance of the <see cref="ClubCloudServiceApplication"/> class. Use this constructor when creating a new Service Application (e.g. from code in your Create page) /// </summary> /// <param name="name">The name of the service application.</param> /// <param name="service">The <see cref="ClubCloudService" />.</param> /// <param name="applicationPool">The application pool.</param> internal ClubCloudServiceApplication(string name, ClubCloudService service, SPIisWebServiceApplicationPool applicationPool) : base(name, service, applicationPool) { }
private BaristaServiceApplication(string name, BaristaService service, SPIisWebServiceApplicationPool appPool) : base(name, service, appPool) { }
public static DayNamerServiceApplication Create(string name, DayNamerService service, SPIisWebServiceApplicationPool appPool) { //This method creates the custom service application #region validation checks if (name == null) { throw new ArgumentNullException("name"); } if (service == null) { throw new ArgumentNullException("service"); } if (appPool == null) { throw new ArgumentNullException("appPool"); } #endregion //Create the service application DayNamerServiceApplication serviceApplication = new DayNamerServiceApplication(name, service, appPool); serviceApplication.Update(); //Register the supported endpoints serviceApplication.AddServiceEndpoint("http", SPIisWebServiceBindingType.Http); serviceApplication.AddServiceEndpoint("https", SPIisWebServiceBindingType.Https, "secure"); return(serviceApplication); }
ParagoServiceApplication(string name, ParagoService service, SPIisWebServiceApplicationPool applicationPool) : base(name, service, applicationPool) { _settings = new Dictionary <string, string>(); }
public static ParagoServiceApplication Create(string name, ParagoService service, SPIisWebServiceApplicationPool applicationPool) { if (null == name) { throw new ArgumentNullException("name"); } if (null == service) { throw new ArgumentNullException("service"); } if (null == applicationPool) { throw new ArgumentNullException("applicationPool"); } ParagoServiceApplication serviceApplication = new ParagoServiceApplication(name, service, applicationPool); serviceApplication.Update(); serviceApplication.AddServiceEndpoint("http", SPIisWebServiceBindingType.Http); serviceApplication.AddServiceEndpoint("https", SPIisWebServiceBindingType.Https, "secure"); // NOTE: It seems redundant, but update needs to be called before AND after the endpoint gets provisioned. serviceApplication.Update(); return(serviceApplication); }
public static CalcServiceApplication Create(string name, CalcService service, SPIisWebServiceApplicationPool appPool) { #region validation if (name == null) { throw new ArgumentNullException("name"); } if (service == null) { throw new ArgumentNullException("service"); } if (appPool == null) { throw new ArgumentNullException("appPool"); } #endregion // create the service application CalcServiceApplication serviceApplication = new CalcServiceApplication(name, service, appPool); serviceApplication.Update(); // register the supported endpoints serviceApplication.AddServiceEndpoint("http", SPIisWebServiceBindingType.Http); serviceApplication.AddServiceEndpoint("https", SPIisWebServiceBindingType.Https, "secure"); return(serviceApplication); }
internal static SPPersistedObject Create(string name, SPPersistedObject service, SPIisWebServiceApplicationPool pool) { return((SPPersistedObject)Utilities.Reflection.ExecuteMethod(ServiceApplicationType, ServiceApplicationType, "Create", new[] { typeof(string), InterCommService.ServiceType, typeof(SPIisWebServiceApplicationPool) }, new object[] { name, service, pool })); }
/// <summary> /// Initializes a new instance of the <see cref="RepoServiceApplication"/> class. Use this constructor when creating a new Service Application (e.g. from code in your Create page) /// </summary> /// <param name="name">The name of the service application.</param> /// <param name="service">The <see cref="Navertica.SharePoint.RepoService.Service" />.</param> /// <param name="applicationPool">The application pool.</param> internal RepoServiceApplication(string name, RepoService service, SPIisWebServiceApplicationPool applicationPool) : base(name, service, applicationPool) { }
private NodeServiceApplication(string name, NodeService service, SPIisWebServiceApplicationPool appPool) : base(name, service, appPool) { }
public static NodeServiceApplication Create(string name, NodeService service, SPIisWebServiceApplicationPool appPool) { if (name == null) { throw new ArgumentNullException("name"); } if (service == null) { throw new ArgumentNullException("service"); } if (appPool == null) { throw new ArgumentNullException("appPool"); } // Create the service application. NodeServiceApplication serviceApplication = new NodeServiceApplication(name, service, appPool); serviceApplication.Update(); // Register the supported endpoints. serviceApplication.AddServiceEndpoint("http", SPIisWebServiceBindingType.Http); serviceApplication.AddServiceEndpoint("https", SPIisWebServiceBindingType.Https, "secure"); return(serviceApplication); }
private NodeServiceApplication(string name, NodeService service, SPIisWebServiceApplicationPool appPool) : base(name, service, appPool) { }
public static OceanikServiceApplication Create(string name, OceanikService service, SPIisWebServiceApplicationPool appPool) { // ... validation code omitted ... // create the service application var serviceApplication = new OceanikServiceApplication(name, service, appPool); serviceApplication.Update(); // register the supported endpoints serviceApplication.AddServiceEndpoint("http", SPIisWebServiceBindingType.Http); serviceApplication.AddServiceEndpoint("https", SPIisWebServiceBindingType.Https, "secure"); return(serviceApplication); }