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

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

  •  10-12-2019
  •  | 
  •  

Question

I have been having trouble with Secure Store. When I deploy, or IISRESET my Secure Store works for a few hours, then Secure Store Dies as I get this 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)

I am running out of options, that's why I am asking here.

I have already looking into Nulling objects ... as from what I read here: http://davidlozzi.com/tag/secure-store-service/

Here is my code to retrieve my Secure Store Credentials..

   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;
    }

.. But it doesnt seem to work either.

Any Suggestions would be very helpful. Thanks!

Was it helpful?

Solution

(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;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top