在 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 中获取第二个值(员工),代码看起来非常像上面所示。如何实现?

您可以使用SimpleSAMLphp's 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];