I have a webapp which does signin request/send to my ADFS server. On the return it is directed to another app url; which i configured in my IIS server. I.E. the same url is configured in ADFS server also.
This error message follows
ID1038: The AudienceRestrictionCondition was not valid because the specified Audience is not present in AudienceUris. Audience:
Here is the code. Why does it fail as such?
issuerLocation = "https://test12.login.mytest.edu/adfs/ls/";
realm = "https://domain/SSO_Test/";
this.Request.Url.AbsoluteUri.Remove(this.Request.Url.AbsoluteUri.IndexOf(this.Request.Url.Query, StringComparison.OrdinalIgnoreCase));
var contextId = Guid.NewGuid().ToString();
this.CreateContextCookie(contextId, this.Request.Url.AbsoluteUri);
var message = new SignInRequestMessage(new Uri(issuerLocation), realm)
{
CurrentTime = DateTime.UtcNow.ToString("s", CultureInfo.InvariantCulture) + "Z",
};
this.Response.Redirect(message.RequestUrl, false);
Sometimes it could be because of the trailing slash "/" ... which was the problem in my case. Copied the URL from the error message and added it to the audienceUris
, and it started working fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With