The Attribute element identifies an attribute by name and optionally includes its value(s). It has the AttributeType complex type. It is used within an attribute statement to express particular attributes and values associated with an assertion subject. It is also used in an attribute query to request that the values of specific SAML attributes be returned.


      public class Attribute : AbstractAttribute


      Shows how to create an AuthnStatement and add it to an Assertion.

      using System;
      using ComponentPro.Saml2;
      // Create SAML Assertion.
      Assertion samlAssertion = new Assertion();
      // Set Issuer
      samlAssertion.Issuer = new Issuer("", null, null, SamlNameIdentifierFormat.Entity, null);
      samlAssertion.Subject = new Subject(new NameId("", null, null, SamlNameIdentifierFormat.EmailAddress, null));
      samlAssertion.Conditions = new Conditions(new TimeSpan(1, 0, 0));
      // Create SAML AuthnStatement.
      ComponentPro.Saml2.AuthnStatement authnStatement = new ComponentPro.Saml2.AuthnStatement();
      authnStatement.AuthnContext = new AuthnContext();
      authnStatement.SessionNotOnOrAfter = DateTime.UtcNow.AddDays(1);
      authnStatement.AuthnContext.AuthnContextClassRef = new AuthnContextClassRef(SamlAuthenticationContext.InternetProtocolPassword);
      // Add it to the assertion.
      // Add an attribute statement.
      AttributeStatement attributeStatement = new AttributeStatement();
      // Add FirstName attribute
      attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("FirstName", SamlAttributeNameFormat.Basic, null, "John"));
      attributeStatement = new AttributeStatement();
      // Add LastName attribute
      attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("LastName", SamlAttributeNameFormat.Basic, null, "Vu"));

      Inheritance Hierarchy



      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.Saml (in ComponentPro.Saml.dll)

      See Also