示例#1
0
        /// <summary>
        /// CreateProxy method override
        /// </summary>
        public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext)
        {
            if (null == serviceApplication)
            {
                throw new ArgumentNullException("ServiceApplication");
            }

            if (serviceApplication.GetType() != typeof(IdentityServiceApplication))
            {
                throw new NotSupportedException();
            }

            IdentityServiceProxy serviceProxy = (IdentityServiceProxy)this.Farm.GetObject(string.Empty, this.Farm.Id, typeof(IdentityServiceProxy));

            if (null == serviceProxy)
            {
                throw new InvalidOperationException("SharePoint.IdentityServiceProxy doesn't exist in the farm");
            }
            ServiceApplicationProxy applicationProxy = serviceProxy.ApplicationProxies.GetValue <ServiceApplicationProxy>(name);

            if (null == applicationProxy)
            {
                applicationProxy = new ServiceApplicationProxy(name, serviceProxy, ((IdentityServiceApplication)serviceApplication).Uri);
            }
            return(applicationProxy);
        }
 /// <summary>
 ///
 /// IdentityServiceClient constructor
 /// </summary>
 public IdentityServiceClient(string selector)
 {
     m_selector = selector;
     try
     {
         m_proxy         = GetProxy();
         m_isinitialized = true;
     }
     catch (Exception)
     {
         // Nothing
     }
 }
        /// <summary>
        /// CheckApplicationProxy metho implementation
        /// </summary>
        private bool CheckApplicationProxy(IdentityServiceApplication app, ServiceApplicationProxy prxy)
        {
            bool result = false;

            try
            {
                string   path  = app.IisVirtualDirectoryPath;
                string[] xpath = path.Split('\\');
                result = (prxy.ServiceEndpointUri.ToString().ToLower().Contains(xpath[1]));
            }
            catch
            {
                result = false;
            }
            return(result);
        }
示例#4
0
        /// <summary>
        /// Static invoke method implementation
        /// </summary>
        internal static void Invoke(SPServiceContext serviceContext, CodeToRunOnApplicationProxy codeBlock)
        {
            if (null == serviceContext)
            {
                throw new ArgumentNullException("serviceContext");
            }
            ServiceApplicationProxy proxy = (ServiceApplicationProxy)serviceContext.GetDefaultProxy(typeof(ServiceApplicationProxy));

            if (null == proxy)
            {
                throw new InvalidOperationException("SharePoint Identity Proxy not found.");
            }
            using (new SPServiceContextScope(serviceContext))
            {
                codeBlock(proxy);
            }
        }
 /// <summary>
 /// GetProxy method implementation
 /// </summary>
 private ServiceApplicationProxy GetProxy()
 {
     if (m_proxy == null)
     {
         //  if (string.IsNullOrEmpty(m_selector))
         m_proxy = GetDefaultProxy();
         //  else
         //  {
         //      m_proxy = FindProxy(m_selector);
         //  }
     }
     if (m_proxy == null)
     {
         throw new ArgumentNullException("Identity Service Proxy", "This Web Application has no Identity Service Application assigned !");
     }
     return(m_proxy);
 }
        /// <summary>
        /// GetDefaultProxy method implementation
        /// </summary>
        /// <returns></returns>
        private ServiceApplicationProxy GetDefaultProxy()
        {
            SPServiceProxyCollection proxies = SPFarm.Local.ServiceProxies;

            foreach (SPServiceProxy SPSP in proxies)
            {
                foreach (SPServiceApplicationProxy SPAP in SPSP.ApplicationProxies)
                {
                    if (SPAP is ServiceApplicationProxy)
                    {
                        ServiceApplicationProxy b = SPAP as ServiceApplicationProxy;
                        return(b);
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// FindProxy method implementation
        /// </summary>
        /// <returns></returns>
        private ServiceApplicationProxy FindProxy(string selector)
        {
            SPServiceProxyCollection proxies = SPFarm.Local.ServiceProxies;

            foreach (SPServiceProxy SPSP in proxies)
            {
                foreach (SPServiceApplicationProxy SPAP in SPSP.ApplicationProxies)
                {
                    if (SPAP is ServiceApplicationProxy)
                    {
                        ServiceApplicationProxy       b   = SPAP as ServiceApplicationProxy;
                        ProxyClaimsProviderParameters prm = b.FillClaimsProviderParameters();
                        if ((prm.ClaimProviderName != null) && (prm.ClaimProviderName.ToLower().Trim().Equals(selector.ToLower().Trim())))
                        {
                            return(b);
                        }
                    }
                }
            }
            return(null);
        }