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.

      Syntax

      public class Attribute : AbstractAttribute

      Examples

      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("http://idp.domain.org", null, null, SamlNameIdentifierFormat.Entity, null);
      samlAssertion.Subject = new Subject(new NameId("johnvu@test.com", 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.
      samlAssertion.Statements.Add(authnStatement);
      
      // Add an attribute statement.
      AttributeStatement attributeStatement = new AttributeStatement();
      // Add FirstName attribute
      attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("FirstName", SamlAttributeNameFormat.Basic, null, "John"));
      
      samlAssertion.Statements.Add(attributeStatement);
      
      attributeStatement = new AttributeStatement();
      // Add LastName attribute
      attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("LastName", SamlAttributeNameFormat.Basic, null, "Vu"));
      
      samlAssertion.Statements.Add(attributeStatement);

      Inheritance Hierarchy

               ComponentPro.Saml2.ComponentPro.Saml2.Attribute

      Framework

      .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