/// <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);
            }
            IdentityServiceProxy serviceProxy = farm.ServiceProxies.GetValue <IdentityServiceProxy>();

            if (null == serviceProxy)
            {
                ThrowTerminatingError(new InvalidOperationException("Identity Web Service proxy not found."), ErrorCategory.ResourceUnavailable, this);
            }
            ServiceApplicationProxy existingServiceApplicationProxy = serviceProxy.ApplicationProxies.GetValue <ServiceApplicationProxy>();

            if (null != existingServiceApplicationProxy)
            {
                WriteError(new InvalidOperationException("Identity Web service application proxy exists."), ErrorCategory.ResourceExists, existingServiceApplicationProxy);
                SkipProcessCurrentRecord();
            }
            Uri serviceApplicationUri = null;

            if (this.ParameterSetName == UriParameterSetName)
            {
                serviceApplicationUri = m_Uri;
            }
            else if (this.ParameterSetName == ServiceApplicationParameterSetName)
            {
                SPServiceApplication serviceApplication = m_ServiceApplicationPipeBind.Read();
                if (null == serviceApplication)
                {
                    WriteError(new InvalidOperationException("Service application not found."), ErrorCategory.ResourceExists, serviceApplication);
                    SkipProcessCurrentRecord();
                }
                ISharedServiceApplication sharedServiceApplication = serviceApplication as ISharedServiceApplication;
                if (null == sharedServiceApplication)
                {
                    WriteError(new InvalidOperationException("Connecting to the specified service application is not supported."), ErrorCategory.ResourceExists, serviceApplication);
                    SkipProcessCurrentRecord();
                }
                serviceApplicationUri = sharedServiceApplication.Uri;
            }
            else
            {
                ThrowTerminatingError(new InvalidOperationException("Invalid parameter set."), ErrorCategory.InvalidArgument, this);
            }
            if ((null != serviceApplicationUri) && (ShouldProcess(this.Name)))
            {
                ServiceApplicationProxy serviceApplicationProxy = new ServiceApplicationProxy(this.Name, serviceProxy, serviceApplicationUri);
                serviceApplicationProxy.Provision();
                WriteObject(serviceApplicationProxy);
            }
        }
Пример #2
0
 /// <summary>
 /// ExecuteOnProxy method implementation
 /// </summary>
 public void ExecuteOnProxy(bool clearcache)
 {
     try
     {
         SPFarm farm = SPFarm.Local;
         IdentityServiceProxy serviceProxy = farm.ServiceProxies.GetValue <IdentityServiceProxy>();
         if (null != serviceProxy)
         {
             foreach (SPServiceApplicationProxy prxy in serviceProxy.ApplicationProxies)
             {
                 if (prxy is ServiceApplicationProxy)
                 {
                     if (CheckApplicationProxy(ServiceApplication, prxy as ServiceApplicationProxy))
                     {
                         if (clearcache)
                         {
                             foreach (SPServer srv in farm.Servers)
                             {
                                 IdentityServiceApplication app = srv.ServiceInstances.GetValue <IdentityServiceApplication>(new Guid(this.GetID()));
                                 if ((app != null) && (app.Status == SPObjectStatus.Online))
                                 {
                                     ((ServiceApplicationProxy)prxy).LaunchClearCacheCommand(srv.Name);  // Only on one valid Server
                                     break;
                                 }
                             }
                         }
                         else
                         {
                             foreach (SPServer srv in farm.Servers)
                             {
                                 IdentityServiceApplication app = srv.ServiceInstances.GetValue <IdentityServiceApplication>(new Guid(this.GetID()));
                                 if ((app != null) && (app.Status == SPObjectStatus.Online))
                                 {
                                     ((ServiceApplicationProxy)prxy).LaunchReloadCommand(srv.Name);   // On Each Servers
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch
     {
         // Do Nothing
     }
 }
Пример #3
0
 public AccountController(ILogger <HomeController> logger, IConfiguration config, IHttpClientFactory httpClient)
 {
     _logger = logger;
     _proxy  = new IdentityServiceProxy(config, httpClient);
 }
Пример #4
0
        public UserController(ILogger <HomeController> logger, IConfiguration config, IHttpClientFactory httpClient, IHttpContextAccessor accessor)
        {
            var token = accessor.HttpContext.User.Claims.First(x => x.Type == "token").Value;

            this._proxy = new IdentityServiceProxy(config, httpClient, token);
        }