Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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
public class SamlAttribute
public class SamlAttribute
Not applicable.

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:

SamlSecurityToken

  SamlAssertion

    SamlAttributeStatement

      SamlAttribute

protected override Collection<SamlAttribute> GetIssuedClaims(RequestSecurityToken RST)
{
    EndpointAddress rstAppliesTo = RST.AppliesTo;

    if (rstAppliesTo == null)
    {
        throw new InvalidOperationException("No AppliesTo EndpointAddress in RequestSecurityToken");
    }

    string bookName = rstAppliesTo.Headers.FindHeader(Constants.BookNameHeaderName, Constants.BookNameHeaderNamespace).GetValue<string>();
    if (string.IsNullOrEmpty(bookName))
        throw new FaultException("The book name was not specified in the RequestSecurityToken");

    EnsurePurchaseLimitSufficient(bookName);

    Collection<SamlAttribute> samlAttributes = new Collection<SamlAttribute>();

    foreach (ClaimSet claimSet in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
    {
        // Copy Name claims from the incoming credentials into the set of claims to be issued.
        IEnumerable<Claim> nameClaims = claimSet.FindClaims(ClaimTypes.Name, Rights.PossessProperty);
        if (nameClaims != null)
        {
            foreach (Claim nameClaim in nameClaims)
            {
                samlAttributes.Add(new SamlAttribute(nameClaim));
            }
        }
    }
    // Add a purchase authorized claim.
    samlAttributes.Add(new SamlAttribute(new Claim(Constants.PurchaseAuthorizedClaim, bookName, Rights.PossessProperty)));
    return samlAttributes;
}

System.Object
  System.IdentityModel.Tokens.SamlAttribute

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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft