Adding custom XML header to your SAML response

Custom SAML XML header
Some vendors require having XML header-like added to a SAML response before sending. With the Ultimate SAML for .NET, you can accomplish that by using the method SendPostBindingForm(Stream output, string messageFormVariableName, string targetUrl, string relayState, string xmlHeader). The xmlHeader method parameter specifies the custom XML header added to the SAML message. For example, it can be "<?xml version="1.0" encoding="utf-8"?>".

The following code snippet shows you how to use that method:

SendPostBindingForm(Response.OutputStream, "SAMLResponse", "http://comsumer-service-url/consumer.aspx", "my relay state", "<?xml version=\"1.0\" encoding=\"utf-8\"?>")

For more information on how to create a SAML response, take a look at this example:

// Create SAML Response object. 
Response response = new Response();    

Assertion samlAssertion = new Assertion();
Audience aud = new Audience();
aud.Uri = "http://testuri.org";
AudienceRestriction ar = new AudienceRestriction();
ar.Audiences.Add(aud);

samlAssertion.Conditions = new Conditions();
samlAssertion.Conditions.ConditionsList.Add(ar);

// Sign the assertion. 
samlAssertion.Sign(x509Certificate);

// Add SAML Assertion 
response.Assertions.Add(samlAssertion);

After the response is created you can use the SendHttpPost method to send it.

45-Day Money Back Guarantee

We will refund your full money in 45 days
if you are not satisfied with our products

Buy Now

Dont miss out Get update on new articles and other opportunities