DRAG DROP
You are developing an ASP.NET MVC application that authenticates a user by using claims‐based
authentication.
The application must:
Use Windows Identity Foundation 4.5.
Support the Windows Azure Access Control Service.
You need to implement authentication.
How should you build the class constructor? (To answer, drag the appropriate code segment to the
correct location or locations in the answer area. Each code segment may be used once, more than
once, or not at all. You may need to drag the split bar between panes or scroll to view content.)
Answer: See the explanation
Explanation:
Box 1: IClaimsIdent
Box 2: ClaimType
Box 3: ClaimTypes
Box 4: ClaimType
Similar example:
For Box 1, see line 15.
For Box 2, see line 22.
For Box 3, see line 22.
For Box 4, see line 26.
using System;
02using System.Collections.Generic;
03using System.Linq;
04using System.Web;
05using Microsoft.IdentityModel.Claims;
06
07namespace MVC3MixedAuthenticationSample.Models
08{
09 public class IdentityClaim
10 {
11 private string _identityProvider;
12 private string _identityValue;
13 public const string ACSProviderClaim
=”http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider”;14
15 public IdentityClaim(IClaimsIdentity identity)
16 {
17
18 if (identity != null)
19 {
20 foreach (var claim in identity.Claims)
21 {
22 if (claim.ClaimType == ClaimTypes.NameIdentifier)
23 {
24 _identityValue = claim.Value;
25 }
26 if (claim.ClaimType == ACSProviderClaim)
27 {
28 _identityProvider = claim.Value;
29 }
30
31 }
32 }
33
34 }
Duplicated with Q.64 http://www.aiotestking.com/microsoft/how-should-you-build-the-class-constructor-7/