ADFS and CRM RRS feed

  • Question

  • Hello,

     I have a question about using  a Security Token to Authenticate against CRM. Our Scenario is as follows, we have a ASp.Net Mvc application which uses a STS to get a SecurityToken for authentication purposes,now in this application, we  also connect to CRM. Before we were using Forms based authentication, and using the username and password to connect to CRM in the underlying code, but now as we moved on to STS authentication, we are not able to connect to CRM. I am able to get the Bootstrap Context security Token from the STS by using the following piece of code,

     BootstrapContext bootstrapContext = ClaimsPrincipal.Current.Identities.First().BootstrapContext as BootstrapContext;
                this._systemUsersRepository.StsSecurityToken = bootstrapContext?.SecurityToken;

    But after getting this token, as soon as I try to connect to CRM by using this code,

      IServiceConfiguration<IOrganizationService> serviceConfiguration =          ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(_organizationUri);
     var sts2 = serviceConfiguration.Authenticate(StsSecurityToken);

     the Authenticate function fails, with a following Error,

    "The signing token System.IdentityModel.Tokens.SamlSecurityToken has no keys. The security token is used in a context that requires it to perform cryptographic operations, but the token contains no cryptographic keys. Either the token type does not support cryptographic operations, or the particular token instance does not contain cryptographic keys. Check your configuration to ensure that cryptographically disabled token types (for example, UserNameSecurityToken) are not specified in a context that requires cryptographic operations (for example, an endorsing supporting token)."

    I don't know if I am missing a ADFS config step or wha is happening. I am not able to find any solution to this. Please help.!!

    Tuesday, August 15, 2017 2:23 PM