This documentation is archived and is not being maintained.

SamlAttribute Class

Represents an attribute that is associated with the subject of a SamlAttributeStatement.

Namespace:  System.IdentityModel.Tokens
Assembly:  System.IdentityModel (in System.IdentityModel.dll)

Public Class SamlAttribute
Dim instance As SamlAttribute

The SamlAttribute class corresponds to the <saml:Attribute> XML element that is defined in the OASIS SAML 1.1 specification.

A SamlAttribute instance contains PossessProperty claims for the subject of a SamlAttributeStatement. For example, a SamlAttribute might contain an Over21 claim, whose type would be specified in the Namespace property and whose resource would be specified as a member of the collection in the AttributeValues property. When the CreatePolicy method is called, this Over21 claim is added to the authorization policy that is returned by returned from by the SamlAttributeStatement. When the AttributeValues property contains multiple elements then one claim is returned for each element.

SamlAttribute position in the SAML object hierarchy is:





Protected Overrides Function GetIssuedClaims(ByVal RST As RequestSecurityToken) As Collection(Of SamlAttribute)

    Dim rstAppliesTo As EndpointAddress = RST.AppliesTo

    If rstAppliesTo Is Nothing Then 
        Throw New InvalidOperationException("No AppliesTo EndpointAddress in RequestSecurityToken")
    End If 

    Dim bookName As String = rstAppliesTo.Headers.FindHeader(Constants.BookNameHeaderName, Constants.BookNameHeaderNamespace).GetValue(Of String)()

    If String.IsNullOrEmpty(bookName) Then 
        Throw New FaultException("The book name was not specified in the RequestSecurityToken")
    End If

    Dim samlAttributes As New Collection(Of SamlAttribute)()

    Dim claimSet As ClaimSet
    For Each claimSet In ServiceSecurityContext.Current.AuthorizationContext.ClaimSets
        ' Copy Name claims from the incoming credentials into the set of claims we're going to issue 
        Dim nameClaims As IEnumerable(Of Claim) = claimSet.FindClaims(ClaimTypes.Name, Rights.PossessProperty)
        If Not (nameClaims Is Nothing) Then 
            Dim nameClaim As Claim
            For Each nameClaim In nameClaims
                samlAttributes.Add(New SamlAttribute(nameClaim))
            Next nameClaim
        End If 
    Next claimSet
    ' add a purchase authorized claim
    samlAttributes.Add(New SamlAttribute(New Claim(Constants.PurchaseAuthorizedClaim, bookName, Rights.PossessProperty)))
    Return samlAttributes

End Function


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0