IsOptional Property
Collapse the table of content
Expand the table of content

ClaimTypeRequirement.IsOptional Property

 

Gets a value that indicates whether the claim is optional.

Namespace:   System.ServiceModel.Security.Tokens
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public bool IsOptional { get; }

Property Value

Type: System.Boolean

true if this instance of the class is for an optional claim; false if it specifies a required claim.

An example of how to use this property is the scenario in which the service asks for some information but does not require it. For instance, you are required to enter your first name, last name, and address, but your phone number is optional.

The following code shows how to get this property.

WSFederationHttpBinding binding = new WSFederationHttpBinding();
binding.Security.Message.ClaimTypeRequirements.Add
   (new ClaimTypeRequirement
   ("http://schemas.microsoft.com/ws/2005/05/identity/claims/EmailAddress"));
binding.Security.Message.ClaimTypeRequirements.Add
   (new ClaimTypeRequirement
   ("http://schemas.microsoft.com/ws/2005/05/identity/claims/UserName", true));
ClaimTypeRequirement cr = new ClaimTypeRequirement
   ("http://schemas.microsoft.com/ws/2005/05/identity/claims/UserName", true);
Console.WriteLine(cr.ClaimType);
Console.WriteLine(cr.IsOptional);

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft