Editar

Compartilhar via


ClaimTypeRequirement.IsOptional Property

Definition

Gets a value that indicates whether the claim is optional.

public:
 property bool IsOptional { bool get(); };
public bool IsOptional { get; }
member this.IsOptional : bool
Public ReadOnly Property IsOptional As Boolean

Property Value

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

Examples

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);

Remarks

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.

Applies to