Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 9244

Issue when fetching data from CRM 2011 online version --------The authentication endpoint AsymmetricToken was not found on the configured Secure Token Service!

$
0
0

We have a custom asp.net application, in which we fetch data from CRM 2011 Online version using CRM SDK 2011. Our application was running fine and suddenly it stopped working and throwing error "The authentication endpoint AsymmetricToken was not found on the configured Secure Token Service!", we are not sure why it is throwing this error.

we did couple of things

1. IIS Reset.

2. Update IIS from Windows Components where our website is deployed.

3. Re-Installed WIF.

4. Restart Server.

Here is the code to connect CRM service and to create crm context and crm organisation proxy.

public static OrganizationServiceProxy getOrganizationService()
        {
            try
            {
                //Read the required Authentication credentials from config file and store in an object.
                AuthenticationCredentials authCredentials = new AuthenticationCredentials();
                authCredentials.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["UserName"];
                authCredentials.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["password"];

                // Set IServiceManagement for the current organization
                // This is the process to set Service Management for online Federated Authentication
                IServiceManagement<IOrganizationService> orgServiceManagement =
                             ServiceConfigurationFactory.CreateManagement<IOrganizationService>(
                             new Uri(ConfigurationManager.AppSettings.Get("URL")));

                // Get the organization service proxy.
                OrganizationServiceProxy organizationProxy = GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceManagement, authCredentials);
                organizationProxy.Timeout.Add(new TimeSpan(300000)); // Setting it to 5 Minutes
                // This statement is required to enable early-bound type support.
                organizationProxy.EnableProxyTypes();
                return organizationProxy;

            }
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
            {
                throw ex;
            }
        }

 private static TProxy GetProxy<TService, TProxy>(
            IServiceManagement<TService> serviceManagement,
            AuthenticationCredentials authCredentials)
            where TService : class
            where TProxy : ServiceProxy<TService>
        {
            Type classType = typeof(TProxy);

            AuthenticationCredentials tokenCredentials =
                serviceManagement.Authenticate(authCredentials);
            // Obtain discovery/organization service proxy for Federated, LiveId and OnlineFederated environments. 
            // Instantiate a new class of type using the 2 parameter constructor of type IServiceManagement and SecurityTokenResponse.
            return (TProxy)classType
                .GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(SecurityTokenResponse) })
                .Invoke(new object[] { serviceManagement, tokenCredentials.SecurityTokenResponse });

        }

Please help us to identify the cause of this issue, and solution.



Viewing all articles
Browse latest Browse all 9244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>