Beispiel #1
0
        /// <summary>
        /// InternalProcessRecord method override
        /// </summary>
        protected override void InternalProcessRecord()
        {
            SPFarm farm = SPFarm.Local;

            if (null == farm)
            {
                ThrowTerminatingError(new InvalidOperationException("SharePoint server farm not found."), ErrorCategory.ResourceUnavailable, this);
            }
            AdministrationService service = farm.Services.GetValue <AdministrationService>();

            if (null == service)
            {
                ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service not found."), ErrorCategory.ResourceUnavailable, this);
            }
            IdentityServiceApplication existingServiceApplication = service.Applications.GetValue <IdentityServiceApplication>(this.Name);

            if (null == existingServiceApplication)
            {
                ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service Application not found."), ErrorCategory.ResourceUnavailable, this);
            }
            if (this.ParameterSetName == AssemblyParameterSetName)
            {
                this.WriteObject(existingServiceApplication.GetAssemblyConfiguration());
            }
            else if (this.ParameterSetName == ConfigurationParameterSetName)
            {
                this.WriteObject(existingServiceApplication.GetConnectionConfiguration(m_connection));
            }
            else if (this.ParameterSetName == AllConfigurationParameterSetName)
            {
                this.WriteObject(existingServiceApplication.GetConnectionConfigurationList());
            }
            else if (this.ParameterSetName == DomainParameterSetName)
            {
                this.WriteObject(existingServiceApplication.GetDomainConfiguration(m_domain));
            }
            else if (this.ParameterSetName == AllDomainParameterSetName)
            {
                this.WriteObject(existingServiceApplication.GetDomainConfigurationList());
            }
            else if (this.ParameterSetName == AllGlobalParameterSetName)
            {
                this.WriteObject(existingServiceApplication.FillGeneralParameters());
            }
            else if (this.ParameterSetName == ReloadParameterSetName)
            {
                this.WriteObject(existingServiceApplication.Reload());
            }
            else
            {
                throw new NotSupportedException("Parameter set not supported.");
            }
        }
        /// <summary>
        /// Select method implementation
        /// </summary>
        public static IEnumerable <ConnectionConfigurationWrapper> Select(IdentityServiceApplication serviceapplication)
        {
            List <ConnectionConfigurationWrapper> lst = new List <ConnectionConfigurationWrapper>();
            List <ConnectionConfiguration>        src = serviceapplication.GetConnectionConfigurationList().ToList <ConnectionConfiguration>();

            foreach (ConnectionConfiguration dom in src)
            {
                lst.Add(new ConnectionConfigurationWrapper(dom.ConnectionName, dom.Username, dom.Password, dom.Timeout, dom.Secure, dom.Maxrows, dom.ConnectString));
            }
            if (lst.Count == 0)
            {
                lst.Add(new ConnectionConfigurationWrapper());
            }
            return(lst);
        }