Pergunta

i am using this sample application provided in http://technet.microsoft.com/en-us/library/cc753987%28WS.10%29.aspx to play around with ADFS claim aware application. my question is how can i get all the roles that the user is in using ADFS, the code above only has an example to check for the roles using User.IsInRole(role).

Foi útil?

Solução

Refer How to: Access Claims in an ASP.NET Page

Edit: To answer the comment for WIF:

For supported Operating Systems: Windows 7, Windows Server 2008 R2, Windows Server 2008 Service Pack 2, Windows Vista Service Pack 2

  • Microsoft® Internet Information Services (IIS) 7.0
  • Microsoft® .NET Framework 3.5

For supported Operating Systems: Windows Server 2003 Service Pack 2

  • Microsoft® Internet Information Services (IIS) 6.0
  • Microsoft® .NET Framework 3.5

Outras dicas

For a full listing you could look here and I would also point you to this answer .

IClaimsPrincipal principal = (IClaimsPrincipal)this.Context.User;
IClaimsIdentity identity = principal.Identites[0];

var roles = identity.Claims
                .Where( c => c.ClaimType == ClaimTypes.Role )
                .Select( c => c.Value );
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top