El servicio de tienda seguro no realizó la operación.System.Servicemodel.endpointNotFoundException:

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/74909

  •  10-12-2019
  •  | 
  •  

Pregunta

He estado teniendo problemas con la tienda segura.Cuando se despliegue, o Iisreset, mi tienda segura funciona durante unas horas, luego segure la tienda muere ya que recibo este error:

System.ServiceModel.EndpointNotFoundException: Secure Store Service did not 
performed the operation. 


System.ServiceModel.EndpointNotFoundException: Secure Store Service did not 
performed the operation. at    Microsoft.Office.SecureStoreService.Server.
SecureStoreServiceApplicationProxy.Execute[T](String operationName, Boolean 
validateCanary, ExecuteDelegate`1 operation) at icrosoft.Office.SecureStoreService.
Server.SecureStoreServiceApplicationProxy.GetCredentials(Guid rawPartitionId, 
String applicationId) at 
Microsoft.Office.SecureStoreService.Server.SecureStoreProvider.
GetCredentials(String appId)

Me estoy quedando sin opciones, es por eso que estoy preguntando aquí.

Ya he estado buscando en los objetos nulantes ... Como de lo que leí aquí: http://davidlozzi.com/tag/secure-store-service/

Aquí está mi código para recuperar mis credenciales de tienda segura.

   public static Dictionary<string, string> GetCredentials(string applicationID)
    {
        var credentialMap = new Dictionary<string, string>();
        var serviceContext = SPServiceContext.Current;
        var secureStoreProvider = new SecureStoreProvider { Context = serviceContext };

        using (var credentials = secureStoreProvider.GetCredentials(applicationID))
        {
            var fields = secureStoreProvider.GetTargetApplicationFields(applicationID);
            for (var i = 0; i < fields.Count; i++)
            {
                var field = fields[i];
                var credential = credentials[i];
                var decryptedCredential = ToClrString(credential.Credential);

                credentialMap.Add(field.Name, decryptedCredential);
                credentials[i].Dispose();
            }

        }
        serviceContext = null;
        secureStoreProvider = null;
        return credentialMap;
    }

.. Pero parece que tampoco parece funcionar.

Cualquier sugerencia sería muy útil.¡Gracias!

¿Fue útil?

Solución

(for someone who is fighting with the same problem)

In my case (I got the same error description) the https connection (that is used to internal call to SecureStore service) is failed on certificate check. It is strange, but the error does not occur on the first call of SecureStore routines, but later, for example after Session is expired and your code call the Secure Store service the second time.

//my class to get credentials
class SecureStoreAccessProvider
{
    private Uri SiteUri;
    private Uri AdminSiteUri;
    private bool MyCertHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors error)
    {
        // Ignore errors
        if (sender is HttpWebRequest)
        {
            HttpWebRequest request = (HttpWebRequest)sender;

            if (SiteUri.Host.Equals(request.RequestUri.Host) || AdminSiteUri.Host.Equals(request.RequestUri.Host))
            {
                return true; //alway 'true' reslut
            }
        }
        return SslPolicyErrors.None.Equals(error);
    }

    /// <summary>
    /// ctor
    /// </summary>
    public SecureStoreAccessProvider()
    {
        SiteUri = new Uri(SPContext.Current.Web.Url);
        AdminSiteUri = new Uri (GetCentralAdminSite().Url);
        ServicePointManager.ServerCertificateValidationCallback += MyCertHandler;
    }

    ~SecureStoreAccessProvider()
    {
        ServicePointManager.ServerCertificateValidationCallback -= MyCertHandler;
    }

    public IAppSecuredCredentials GetCredentials(string appId)
    {
        //here the similar code like yours
    }

   //I have found this function in MSDN sample
   public static SPSite GetCentralAdminSite()
    {
        SPAdministrationWebApplication adminWebApp = SPAdministrationWebApplication.Local;
        if (adminWebApp == null)
        {
            throw new InvalidProgramException("Unable to get the admin web app");
        }

        SPSite adminSite = null;
        Uri adminSiteUri = adminWebApp.GetResponseUri(SPUrlZone.Default);
        if (adminSiteUri != null)
        {
            adminSite = adminWebApp.Sites[adminSiteUri.AbsoluteUri];
        }
        else
        {
            throw new InvalidProgramException("Unable to get Central Admin Site.");
        }

        return adminSite;
    }
}
Licenciado bajo: CC-BY-SA con atribución
scroll top