locked
Connect to CRM OnPremise+IFD from external .net application AcquireTokenAsync error RRS feed

  • Question

  • Hello, 

    We are trying to connect to CRM IFD deployment from a .NET app.

    https://msdn.microsoft.com/en-in/library/dn531009.aspx

    We have registered with ADFS and noted the client ID to use for obtaining token.

    The authentication code tries to acquire a token based on resource, authority, client ID. 

    AuthenticationResult result = await _authenticationContext.AcquireTokenAsync(resource, clientID, new UserCredential("username"));

    However, this code throws a 404 error in the innerException. Inner exception msg:  

     Response status code does not indicate success: 404 (NotFound).

    Stack Trace:    at Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.<GetResponseAsync>d__29.MoveNext()

    What is wrong here? I have verified the resource(my crm url) is working fine in the browser and for authority URL, I have tried both auto discovered URL as well as url of the form <servername>/adfs/ls. Both ways, I get the same error.

    Any help would be appreciated.

    Regards.

    Wednesday, December 14, 2016 12:33 PM

All replies

  • This looks like a problem with how IFD is configured, rather than your code. Can you identify which url causes the 404 error ? The ADFS authentication includes several redirects between the CRM and ADFS servers, so a key thing to identify is which of these causes the 404

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, December 14, 2016 3:22 PM
    Moderator
  • Hello David, 

    Thanks for replying. 

    We have tried the same from Java code and looks like our app is trying to redirect to the following ADFS URL which doesn't exist:

    https://<STS_Server>/common/userrealm/<username>?api-version=1.0

    Such kind of URL is used in CRM online cases. 

    Where as it should be something like:

    https://<STS_Server>/adfs/ls/?user=<username>&api-version=2.1

    Authority that we have specified : https://<STS_Server>/adfs/ls

    We are using adal4j library: http://mvnrepository.com/artifact/com.microsoft.azure/adal4j

    Is there anything missing? Any configuration that needs to specify using ADFS STS and not Online.

    Regards.



    • Edited by Tripti R Thursday, December 15, 2016 10:18 AM
    Thursday, December 15, 2016 9:20 AM
  • For the .NET app, this is the URL -> /adfs/oauth2/token that is throwing 404 not found!

    What exactly is required to be configured here?


    • Edited by Tripti R Thursday, December 15, 2016 10:18 AM
    Thursday, December 15, 2016 9:32 AM
  • How did you fix this problem?
    Friday, June 16, 2017 12:00 PM