ComponentSpace

Forums



Attributes with multiple AttributeValue


Attributes with multiple AttributeValue

Author
Message
fabio
fabio
New Member
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)

Group: Forum Members
Posts: 15, Visits: 72
Hello,
we are implementing an integration with ADFS.
We've been able to connect and obtain the response with the correct claims.

Among those, we receive this one, called Group, in which we have multiple value.


<Attribute Name="http://schemas.xmlsoap.org/claims/Group">  
 <AttributeValue>Domain Users</AttributeValue>  
 <AttributeValue>PWDStandard</AttributeValue>  
 <AttributeValue>External_Share_File</AttributeValue>  
 <AttributeValue>LDMS_External_ownHome</AttributeValue> 
 <AttributeValue>PEC_Sistemi_Informativi</AttributeValue>  
 <AttributeValue>LDMS_PECManager</AttributeValue>  
 <AttributeValue>RADIUSTest</AttributeValue>  
 <AttributeValue>RADIUS_APN_TIM</AttributeValue>  
 <AttributeValue>ITMOFS01_Uffici-Interufficio</AttributeValue>  
 <AttributeValue>guac_users</AttributeValue>  
 <AttributeValue>gruppo1</AttributeValue>  
 <AttributeValue>AllowOWA</AttributeValue>  
</Attribute>


Now, we normally get a single string value so using this method

Snippetpublic static void ReceiveSSO(HttpRequestBase httpRequest, out bool isInResponseTo, out string partnerIdP, out string authnContext, out string userName, out IDictionary<string, string> attributes, out string relayState);

we can read and parse those claims correclty.

Unfortunately, in this case we are able to read only the first one.

How can we correctly process also this one?

Thank you
Fabio
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)

Group: Administrators
Posts: 2.7K, Visits: 8.4K
Hi Fabio,

The overload that returns the IDictionary is a convenience for the majority of use cases where single-value SAML attributes are returned. There's a ReceiveSSO overload that returns a SAMLAttribute[] rather than an IDictionary<string, string>. The SAMLAttribute class gives you access to all the SAML attribute values through the SAMLAttribute.Values property.


SAMLServiceProvider.ReceiveSSO(
    Request,
    out isInResponseTo,
    out partnerIdP,
    out authnContext,
    out userName,
    out samlAttributes,
    out targetUrl);

var samlAttribute = samlAttributes.SingleOrDefault<SAMLAttribute>(
    a => a.Name == "http://schemas.xmlsoap.org/claims/Group");

foreach (var attributeValue in samlAttribute.Values)
{
  var groupName = attributeValue.ToString();
}




Regards
ComponentSpace Development
fabio
fabio
New Member
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)

Group: Forum Members
Posts: 15, Visits: 72
ComponentSpace - 3/16/2021
Hi Fabio,

The overload that returns the IDictionary is a convenience for the majority of use cases where single-value SAML attributes are returned. There's a ReceiveSSO overload that returns a SAMLAttribute[] rather than an IDictionary<string, string>. The SAMLAttribute class gives you access to all the SAML attribute values through the SAMLAttribute.Values property.


SAMLServiceProvider.ReceiveSSO(
    Request,
    out isInResponseTo,
    out partnerIdP,
    out authnContext,
    out userName,
    out samlAttributes,
    out targetUrl);

var samlAttribute = samlAttributes.SingleOrDefault<SAMLAttribute>(
    a => a.Name == "http://schemas.xmlsoap.org/claims/Group");

foreach (var attributeValue in samlAttribute.Values)
{
  var groupName = attributeValue.ToString();
}



Thak you for your fast reply!
I'll take a look at this solution this morning.

Just to be sure: can i always use this overload of the ReceviveSSO method?
I mean, since we have scenarios where different clients can send us either a single value or a multiple value (like this case) attribute and i don't want to check every time, If i use always this overload am i able to manage both these situations?

Thank you
Fabio
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)

Group: Administrators
Posts: 2.7K, Visits: 8.4K
Yes. This overload supports both single-value and multi-value SAML attributes. You can use this overload for all scenarios.

Regards
ComponentSpace Development
fabio
fabio
New Member
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)

Group: Forum Members
Posts: 15, Visits: 72
ComponentSpace - 3/17/2021
Yes. This overload supports both single-value and multi-value SAML attributes. You can use this overload for all scenarios.

Yes, I tried it and it works perfectly.

Thank you for your support.

Fabio
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)ComponentSpace Development (3.8K reputation)

Group: Administrators
Posts: 2.7K, Visits: 8.4K
You're very welcome.

Regards
ComponentSpace Development
GO


Similar Topics


Execution: 0.000. 2 queries. Compression Enabled.
Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....









Forums, Documentation & Knowledge Base - ComponentSpace


Search