以下のスクリプトはIdPバージョン2時代のものでありIdPv3では未検証です。またJava 7向けのものです。動作報告をお待ちしております。
異なるツリー上の情報をスクリプトで取得する方法、ならびにツリーごとに取得する属性を変える方法について、attribute-resolver.xmlのスクリプト中で以下のように記述できます。
各属性の値は、JavaScript(ECMAScript)の構文中で文字列のリストのような形で扱うことができます。
https://wiki.shibboleth.net/confluence/display/IDP30/ScriptedAttributeDefinition
例:
ActiveDirectoryのドメイン:example.ac.jp
ツリー1:Account/tree1/ ユーザアカウント:users1
ツリー2:Account/tree2/ ユーザアカウント:users2
↓
アカウントのツリー情報は、属性「distinguishedName」に
以下の形式で格納されています。
#OU以降がツリー情報です。
CN=users1,OU=tree1,OU=Account,DC=example,DC=ac,DC=jp
CN=users2,OU=tree2,OU=Account,DC=example,DC=ac,DC=jp
下記のスクリプトでは、スクリプト中で「distinguishedName」という属性の情報を取得し、文字列を比較してツリー情報を取っていま す。またtree1のアカウントは「attr1」属性、tree2のアカウントは「attr2」属性をeduPersonAffiliationの値とし て返しています。
attribute-resolver:
<resolver:AttributeDefinition id="eduPersonAffiliation" xsi:type="Script" xmlns="urn:mace:shibboleth:2.0:resolver:ad" sourceAttributeID="eduPersonAffiliation"> <resolver:Dependency ref="myLDAP-AD" /> <!-- snip --> <Script> <![CDATA[ importPackage(Packages.edu.internet2.middleware.shibboleth.common.attribute.provider); // Create attribute to be returned from definition eduPersonAffiliation = new BasicAttribute("eduPersonAffiliation"); // Get attribute if (typeof distinguishedName != "undefined" && distinguishedName != null) { for (i = 0; distinguishedName != null && i < distinguishedName.getValues().size(); i++) { tree = distinguishedName.getValues().get(i); // tree1 if (tree.indexOf("OU=tree1,OU=Account,DC=example,DC=ac,DC=jp") > 0) { if (typeof attr1!= "undefined" && attr1!= null && attr1.getValues().size()> 0) { eduPersonAffiliation.getValues().add(attr1.getValues().get(0)); } } // tree2 if (tree.indexOf("OU=tree2,OU=Account,DC=example,DC=ac,DC=jp") > 0) { if (typeof attr2!= "undefined" && attr2!= null && attr2.getValues().size()> 0) { eduPersonAffiliation.getValues().add(attr2.getValues().get(0)); } } } //for } // if ]]> </Script> </resolver:AttributeDefinition>