在php中从SAML获取第二个AttributeValue


Get second AttributeValue from SAML in php

<saml:Attribute
xmlns:x500="urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500"
x500:Encoding="LDAP"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1"
FriendlyName="eduPersonAffiliation">
   <saml:AttributeValue
     xsi:type="xs:string">member</saml:AttributeValue>
   <saml:AttributeValue
     xsi:type="xs:string">staff</saml:AttributeValue>
 </saml:Attribute>

我想在我的php代码中获得SAML的第二个值(staff),代码看起来与上面所示完全相同。如何才能做到这一点?

你可以使用SimpleSAMLphp的API

$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
$attributes = $as->getAttributes();
// The attribute Name is the key
$secondValue = $attributes['urn:oid:1.3.6.1.4.1.5923.1.1.1.1'][1];