Programmatically get user identity from Azure ACS

818 views Asked by At

This question is a bit noobie, but i can't find the information over the internet (perhaps i'm search wrongly?)

We have an Azure ACS configured and we using it as auth service for our website. But now we need to build an application, which, by known username and password, will receive users claims from ACS. Is this possible?

1

There are 1 answers

0
Adam Hoffman On

Yes, it's possible.

One thing to note - Using ACS, you can choose a variety of different token providers to allow (aka STS-es). Each of those provide a different set of claims to you as a default, so you might need to enrich these.

Here's a snippet of code that you can try to see what claims are coming back from ACS in your code already:

// NOTE: This code makes the assumption that you have .NET 4.5 on the machine.  It relies on 
// the new System.Security.Claims.ClaimsPrincipal and System.Security.Claims.ClaimsIdentity
// classes.

// Cast the Thread.CurrentPrincipal and Identity
System.Security.Claims.ClaimsPrincipal icp = Thread.CurrentPrincipal as System.Security.Claims.ClaimsPrincipal;
System.Security.Claims.ClaimsIdentity claimsIdentity = icp.Identity as System.Security.Claims.ClaimsIdentity;

// Access claims
foreach (System.Security.Claims.Claim claim in claimsIdentity.Claims)
{
    Response.Write("Type : " + claim.Type + "- Value: " + claim.Value + "<br/>");
}

Adam Hoffman Windows Azure Blog - http://stratospher.es Twitter - http://twitter.com/stratospher_es