Add your own Claims to your ADFS Provider

Following on from my previous blog on “Creating your own identity provider …” The following changes can be made to add in your own claims.

Firstly in the App_Data\CustomSecurityTokenService.cs file of your identity provider web site I changed the following code

outputIdentity.Claims.Add( new Claim( System.IdentityModel.Claims.ClaimTypes.Name, principal.Identity.Name ) );
if (principal.Identity.Name.Equals("Steve") == true)
{
outputIdentity.Claims.Add(new Claim(ClaimTypes.Role, "Administrator"));

outputIdentity.Claims.Add(new Claim("http://schemas.BlackMarble/Identity/Claims/Business",
"Black Marble"));

}
else
{
outputIdentity.Claims.Add(new Claim(ClaimTypes.Role, "User"));
}

 

 
The first parameter of the Claim constructor needs to be in the format of a namespace and I added this one up as it was an internal name we are using.
The second parameter of the Claim constructor is the value you want to pass through.
 
Next go to the appfabric portal and add in the following rule to your STS provider. You need to make sure that the schema string you have in your code matches the Input Claim Type you added in your rule.
 
 
 
image
Now you should be passing through the Business claim to your website. To get access to the claim use the following code:
 
using System.Threading;
using Microsoft.IdentityModel.Claims;

IClaimsPrincipal principal = (IClaimsPrincipal)Thread.CurrentPrincipal;
var business = "";
foreach (Claim claim in principal.Identities[0].Claims)
{
if (claim.ClaimType.Equals("http://schemas.BlackMarble/Identity/Claims/Business"))
{
business = claim.Value;
break;
}
}

if (!String.IsNullOrEmpty(business))
{
// we have a claim value for School so lets display it
BusinessLabel.Text = business;
}
else
{
BusinessLabel.Text = "No business claim found";
}

Again, note that the claim type namespace is the same as you specified previously.

The following claims are passed through to my website:

image

31 Replies to “Add your own Claims to your ADFS Provider”

  1. Coming into an place with a pursuit close by will pop up a alert on your mini-map and a brief details will appear, like for example, your personality is getting effort rather than droning on and doing only what some exclusive individual on the globe claims to do. Personally, the use of Waypoints allows me more inclination to keep exploring, since I don't need to worry about how long it could take me to get here we are at my main quest. You can see the documentaries on DISH channels like Animal Planet channel. Review my site … guild wars 2 fast leveling – http://www.youtube.com/watch?v=PfTzTgxDe4A

  2. Howdy would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I'm looking for something unique. P.S Sorry for being off-topic but I had to ask! Look into my website – gyms in perrysburg ohio – http://www.hvacsimulator.net/index.php/User:VeolaVogtyye

  3. Howdy! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having trouble finding one? Thanks a lot! Also visit my page: acnenomorereviewblog.com ( Johnette – http://acnenomorereviewblog.com )

  4. I'm really impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you customize it yourself? Anyway keep up the excellent quality writing, it is rare to see a nice blog like this one nowadays. Also visit my site :: frederick md moving ( greengangmovers.com – http://greengangmovers.com/about/ )

  5. Hello there! This is kind of off topic but I need some guidance from an established blog. Is it hard to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to begin. Do you have any ideas or suggestions? Appreciate it Feel free to visit my blog post: air conditioning phoenix – http://airconditioning-phoenix.info/

  6. Definitely believe that that you said. Your favorite reason seemed to be at the internet the simplest factor to take into accout of. I say to you, I certainly get annoyed while folks consider issues that they plainly don't know about. You managed to hit the nail upon the highest as neatly as defined out the entire thing with no need side-effects , other people could take a signal. Will likely be again to get more. Thank you Here is my website miami criminal lawyer – http://criminallawyermiami.me

  7. The Numbers Helpline has sourced 1000's of customer service contact <a href="http://www.numbershelpline.co.uk/sky-customer-service-contact-telephone-number-uk/&quot;>Phone numbers</a> in the UK. We know how hard it can be to find those <a href="http://www.numbershelpline.co.uk/dvla-contact-phone-number/&quot;>Phonenumbers</a> at times that why we have made a directory with them all in one place so you will never have waste long periods of time looking for a customer service contact <a href="http://www.numbershelpline.co.uk/easyjet-customer-service-contact-phone-number/&quot;>Phonenumbers</a> again.

  8. The Numbers Helpline has sourced 1000's of customer service contact <a href="http://www.numbershelpline.co.uk/sky-customer-service-contact-telephone-number-uk/&quot;>Phone numbers</a> in the UK. We know how hard it can be to find those <a href="http://www.numbershelpline.co.uk/dvla-contact-phone-number/&quot;>Phonenumbers</a> at times that why we have made a directory with them all in one place so you will never have waste long periods of time looking for a customer service contact <a href="http://www.numbershelpline.co.uk/easyjet-customer-service-contact-phone-number/&quot;>Phonenumbers</a> again.

Leave a Reply to Johnette Cancel reply

Your email address will not be published. Required fields are marked *