[WCF]Identity achterhalen

Pagina: 1
Acties:

  • Woy
  • Registratie: April 2000
  • Niet online

Woy

Moderator Devschuur®
Topicstarter
Ik ben bezig een WCF service aan het maken, deze service is beveiligd door middel van username/wachtwoord ( Die worden gecontroleerd in een custom UserNamePasswordValidator, wat ook goed werkt ).

In een aantal methodes van de service wil ik echter weten welke user er is ingelogd. Ik ben aan het zoeken geweest op internet maar ik kon niet echt vinden wat nou de juiste manier is om dat te doen.

Moet ik handmatig door alle Claims heen lopen en daar zelf mijn Username uit halen

C#:
1
2
3
4
5
6
7
8
9
10
11
12
foreach (ClaimSet claimSet in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
{
    foreach (Claim claim in claimSet)
    {
        if (    claim.ClaimType.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" )
            &&  claim.Right.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/right/identity" )
            )
        {
            Console.WriteLine(claim.Resource);
        }
    }
}

Of zijn er betere manieren om dit te achterhalen?

“Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.”


  • Woy
  • Registratie: April 2000
  • Niet online

Woy

Moderator Devschuur®
Topicstarter
Ik ben er al een beetje uit.
C#:
1
2
3
4
5
6
7
8
foreach (ClaimSet claimSet in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
{
    IEnumerable<Claim> claims = claimSet.FindClaims(ClaimTypes.Name, Rights.Identity);
    foreach (Claim claim in claims)
    {
        Console.WriteLine(claim.Resource);
    }
}

Ik heb er een goed artikel over gevonden. http://www.theserverside....=ClaimsBasedSecurityModel

Alleen de UserNameClaimSet die daar besproken word kan ik nergens terug vinden dus die zal tijdens de Beta van WCF wel verdwenen zijn.

“Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.”