Oracle® Fusion Middleware Identity Governance Frameworkによるアプリケーションの開発 12c (12.2.1.1) E79304-01 |
|
前へ |
次へ |
次の各トピックで、Identity Governance Framework、アイデンティティ・ディレクトリAPIおよびIdentity Directory Serviceのアーキテクチャと主要な機能について説明します。
注意:
Oracle® Fusion Middleware Oracle Platform Security Servicesによるアプリケーションの保護
アイデンティティ・ディレクトリAPIは、アイデンティティ管理アプリケーションがアイデンティティ情報にアクセスし、管理するためのサービスを提供します。柔軟性のあるこのAPIは、クライアントによって完全に構成可能であり、標準および固有のスキーマを持つ様々なアイデンティティ・ストアをサポートします。さらに堅牢であり、高可用性およびフェイルオーバー・サポートの両方を提供します。
このAPIは、Identity Governance Frameworkを使用し、Identity Governanceによるアイデンティティ情報の規制および制御がもたらすすべての利点を提供します。このAPIはJava EEおよびJava SEの両方のモードで使用できます。Identity Governance Frameworkの詳細は、Identity Governance Frameworkの概要を参照してください。
APIでサポートされるアクションは次のとおりです。
ユーザー、グループ、組織のエンティティおよび汎用エンティティに対する作成/読取り/更新/削除(CRUD)操作の実行
ユーザー・アカウント状態の取得操作
アイデンティティ・ディレクトリAPIの構成の共有
Oracle Internet Directory、Oracle Unified Directory、Oracle Directory Server EE、Active Directoryなどのディレクトリ・サーバーのサポート
Identity Directory Serviceには次のものが含まれます。
アイデンティティ・ディレクトリAPI
ドメイン・アイデンティティ・ストアであるディレクトリ・サーバー内でアイデンティティ情報にアクセスし、管理する方法を提供します。エンティティ定義、エンティティ・リレーションシップ、およびその物理的なアイデンティティ・ストアの詳細は、アイデンティティ・ディレクトリの構成APIまたはMbeanを使用して構成できます。ディレクトリ・サービス・インスタンスの機能は、ゲッター・メソッドを使用して問い合せることができます。
アイデンティティ・ディレクトリAPIの構成
アイデンティティ・ディレクトリAPIの構成には、論理的なエンティティ構成と物理的なアイデンティティ・ストア構成が含まれます。
この項では、次の項目について説明します。
Identity Directory Serviceの初期化にはアイデンティティ・ディレクトリAPIを使用します。
Identity Directory Serviceは、アイデンティティ管理製品がアイデンティティ・ディレクトリにアクセスし、管理するために使用する共通サービスです。Identity Directory Serviceは、異なるアイデンティティ・ストアに格納されているユーザーおよびグループ情報にアクセスし、それらを変更するためのインタフェースを提供します。アイデンティティ・ディレクトリはIdentity Directory Serviceのインスタンスであり、次のものが含まれています。
一意の名前 (IDS名)
論理的なエンティティ構成
物理的なアイデンティティ・ストア構成
アイデンティティ・ストア・サービスとも呼ばれるIdentity Directory Serviceの詳細は、Oracle® Fusion Middleware Oracle Platform Security Servicesによるアプリケーションの保護を参照してください。
アイデンティティ・ディレクトリAPIは、異なるアイデンティティ・ストアに格納されているユーザーおよびグループ情報にアクセスし、それらを変更するためのインタフェースを提供します。
Identity Directory Serviceの構成は、論理的なエンティティ構成、物理的なアイデンティティ・ストア構成およびオペレーション構成の組合せになります。
論理的なエンティティ構成およびオペレーション構成は、ids-config.xmlに格納されています。このファイルは、jps-config.xmlと同じディレクトリにあります。たとえば、Java EE環境では次の場所にあります。
DOMAIN_HOME/config/fmwconfig/ids-config.xml
物理的なアイデンティティ・ストア構成は、ovd/ids/adapters.os.xmlにあります。たとえば、ovdディレクトリは、Java EE環境では次の場所にあります。
DOMAIN_HOME/config/fmwconfig
この項では、次の項目について説明します。
Identity Directory Serviceの構成は、論理的なエンティティ構成、物理的なアイデンティティ・ストア構成およびオペレーション構成の組合せになります。
次の各トピックで、Identity Directory Serviceの論理的なエンティティ構成について説明します。
論理的なエンティティ構成のプロパティに留意する必要があります。
名前 | 説明 |
---|---|
|
Identity Directory Serviceを一意に識別する名前です。 |
|
Identity Directory Serviceの詳細な説明です。 |
|
有効な値は |
|
Identity Directory Serviceの構成対象である特定のアプリケーションを指定するプロパティです(オプション)。 |
次の表に、論理的なエンティティ属性を示します。
名前 | 説明 |
---|---|
|
論理的な属性の名前です。 |
|
有効なデータ・タイプの値は、 |
|
論理的な属性の詳細な説明です。 |
|
デフォルトは |
|
デフォルトは |
注意:
12c (12.1.3)リリース以降、アイデンティティ・ディレクトリAPIは、エンティティ属性パススルーをサポートします。パススルーをサポートする場合、属性定義(論理的なエンティティ構成の属性で説明)およびエンティティ定義の下の属性参照(論理的なエンティティ定義のプロパティで説明)に各属性をすべて含める必要はありません。
IDS APIでは、追加、変更、リクエスト済属性、または検索フィルタ操作での任意の属性を許可します。エンティティ定義は、バックエンド・アイデンティティ・ストアとは異なる論理的な属性名を使用してエンティティ関係を定義するための、または属性のデフォルトのフェッチのための、属性の最小限のセットを保持できます。
入力属性がアイデンティティ・ストア・スキーマにない場合、IDS APIはアイデンティティ・ストアによってスローされたエラーを返します。
論理的なエンティティ定義ごとに必要なプロパティに留意する必要があります。
名前 | 説明 |
---|---|
|
エンティティの名前。 |
|
有効なエンティティの値は、 |
|
エンティティを一意に識別する論理的な属性です。 |
|
このエンティティの作成が許可されている場合は |
|
このエンティティの変更が許可されている場合は |
|
このエンティティの削除が許可されている場合は |
|
このエンティティの検索が許可されている場合は |
|
次の詳細を含むエンティティ属性のリファレンスのリストです。
|
論理的なエンティティ・リレーションシップ定義ごとに必要なプロパティに留意する必要があります。
名前 | 説明 |
---|---|
|
エンティティ・リレーションシップの名前です。 |
|
有効なエンティティの値は、 |
|
エンティティ・リレーションシップの最初のエンティティの名前です。 |
|
最初のエンティティの属性です。この属性値は、リレーションシップの2番目のエンティティに関連します。 |
|
エンティティ・リレーションシップの2番目のエンティティの名前です。 |
|
2番目のエンティティの属性です。 |
|
エンティティ・リレーションシップが再帰的な場合は |
Identity Directory Serviceの物理的なアイデンティティ・ストア構成に留意する必要があります。
次の表に、物理的なアイデンティティ・ストア構成のプロパティを示します。
名前 | 説明 |
---|---|
|
アイデンティティ・ストアのホストおよびポートの情報です。フェイルオーバー用に代替ホストおよびポートの詳細を設定することもできます。 |
|
ディレクトリのタイプです。有効な値は、 |
|
ディレクトリに接続するための資格証明です。 |
Identity Directory Serviceのオペレーション構成を参照する必要があります。
オペレーション構成には、主に、各エンティティのbase
、name attribute
およびobjectclass
の構成が含まれます。
次の表に、オペレーション構成のエンティティを示します。
名前 | 説明 |
---|---|
|
エンティティを検索する必要のあるコンテナです。 |
|
新しいエンティティが作成されるコンテナです。 |
|
エンティティのRDN属性です。 |
|
このエンティティの検索時に使用される |
|
この新しいエンティティの作成時に追加される |
新しいアイデンティティ・ディレクトリAPIを設計するときは、推奨事項に留意する必要があります。
次の各トピックで、推奨事項について説明します。
新しいアイデンティティ・ディレクトリを構成するときは、エンティティ属性の数をできるかぎり少なくする必要があります。
エンティティ属性はdefaultFetch
の値によって定義されます。また、jpegphoto
のように値が大きい属性は、defaultFetch
の値をfalseで構成します。これは、エンティティをバックエンドから読み取るたびに、すべてのdefaultFetch
属性がバックエンド・ディレクトリから取得されるためです。defaultFetch
属性が多すぎるとパフォーマンスに影響を与えます。
アイデンティティ・ディレクトリAPIに関連する各種の操作を実行するには、次のサンプル・コードを使用します。
次の各トピックで、アイデンティティ・ディレクトリAPIに関連する操作について説明します。
アイデンティティ・ディレクトリへのハンドルを初期化して取得するには、次のコード・サンプルを使用します。
import oracle.igf.ids.UserManager; import oracle.igf.ids.GroupManager; import oracle.igf.ids.config.OperationalConfig; import oracle.igf.ids.IdentityDirectoryFactory; import oracle.igf.ids.IdentityDirectory; import oracle.igf.ids.IDSException; public class IdsSample { private IdentityDirectory ids; private UserManager uMgr; private GroupManager gMgr; public IdsSample() throws IDSException { // Set Operational Config OperationalConfig opConfig = new OperationalConfig(); // Set the application credentials (optional). This overrides the credentials set in // physical ID store configuration opConfig.setApplicationUser("cn=user1,dc=us,dc=example,dc=com"); opConfig.setApplicationPassword("password".toCharArray()); // Set search/crate base, name, objclass, etc. config (optional). This overrides default operational configuration in IDS opConfig.setEntityProperty("User", opConfig.SEARCH_BASE, "dc=us,dc=example,dc=com"); opConfig.setEntityProperty("User", opConfig.CREATE_BASE, "dc=us,dc=example,dc=com"); opConfig.setEntityProperty("User", opConfig.FILTER _OBJCLASSES, "person"); opConfig.setEntityProperty("User", opConfig.CREATE _OBJCLASSES, "inetorgperson"); opConfig.setEntityProperty("Group", opConfig.SEARCH _BASE, "cn=groups,dc=us,dc=example,dc=com"); opConfig.setEntityProperty("Group", opConfig.CREATE _BASE, "cn=groups,dc=us,dc=example,dc=com"); opConfig.setEntityProperty("Group", opConfig.FILTER _OBJCLASSES, "groupofuniquenames"); opConfig.setEntityProperty("Group", opConfig.CREATE _OBJCLASSES, "groupofuniquenames"); // Get IdentityDirectory "ids1" configured in IDS config IdentityDirectoryFactory factory = new IdentityDirectoryFactory(); ids = factory.getIdentityDirectory("ids1", opConfig); // Get UserManager and GroupManager handles uMgr = ids.getUserManager(); gMgr = ids.getGroupManager(); } }
注意:
認証プロバイダとしてTivoliを使用する場合は、認証プロバイダのタイプとしてOPEN_LDAP
を選択する必要があります。これは、Oracle WebLogic ServerでTivoliがサポートされていないためです。
Tivoliのディレクトリ・ハンドルを取得するようにIdentity Governance FrameworkまたはIdentity Directory Serviceを初期化すると、生成されたadapters.os_xmlファイルに次のパラメータが含まれています。
<param name="mapAttribute" value="orclGUID=entryUUID"/>
このTivoliのシナリオでは、次のようにorclGUID
属性をibm-entryUUID
にマップする必要があります。
<param name="mapAttribute" value="orclGUID=ibm-entryUUID"/>
これらの変更を反映するため、adapters.os_xmlファイルを手動で更新する必要があります。さらに、属性マッピングの更新を有効にするためにOracle WebLogic Serverを再起動する必要があります。
JPSコンテキストからアイデンティティ・ディレクトリ・ハンドルを初期化して取得するには、次のコード・サンプルを使用します。
import oracle.igf.ids.UserManager; import oracle.igf.ids.GroupManager; import oracle.igf.ids.config.OperationalConfig; import oracle.igf.ids.IdentityDirectoryFactory; import oracle.igf.ids.IdentityDirectory; import oracle.igf.ids.IDSException; import oracle.security.jps.JpsContext; import oracle.security.jps.JpsContextFactory; import oracle.security.jps.service.idstore.IdentityStoreService; public class IdsSample { private IdentityDirectory ids; private UserManager uMgr; private GroupManager gMgr; public IdsSample() throws IDSException { // Get IdentityDirectory from JpsContext try { JpsContext context = JpsContextFactory.getContextFactory().getContext(); IdentityStoreService idstore = (IdentityStoreService) context.getServiceInstance(IdentityStoreService.class); ids = idstore.getIdentityStore(); } catch (Exception e) { throw new IDSException(e); } // Get UserManager and GroupManager handles uMgr = ids.getUserManager(); gMgr = ids.getGroupManager(); } }
メモリー内アイデンティティ・ディレクトリ・ハンドルを初期化して取得するには、次のコード・サンプルを使用します。
import java.util.ArrayList; import java.util.List; import oracle.igf.ids.UserManager; import oracle.igf.ids.GroupManager; import oracle.igf.ids.config.AttributeDef; import oracle.igf.ids.config.AttributeRef; import oracle.igf.ids.config.EntityDef; import oracle.igf.ids.config.EntitiesConfig; import oracle.igf.ids.config.EntityRelationship; import oracle.igf.ids.config.IdentityStoreConfig; import oracle.igf.ids.config.OperationalConfig; import oracle.igf.ids.IdentityDirectoryFactory; import oracle.igf.ids.IdentityDirectory; import oracle.igf.ids.IDSException; public class IdsSample { private IdentityDirectory ids; private UserManager uMgr; private GroupManager gMgr; public IdsSample() throws IDSException { // Add Attribute definitions List<AttributeDef> attrDefs = new ArrayList<AttributeDef>(); attrDefs.add(new AttributeDef("cn", AttributeDef.DataType.STRING)); attrDefs.add(new AttributeDef("firstname", AttributeDef.DataType.STRING)); attrDefs.add(new AttributeDef("sn", AttributeDef.DataType.STRING)); attrDefs.add(new AttributeDef("telephonenumber", AttributeDef.DataType.STRING)); attrDefs.add(new AttributeDef("uid", AttributeDef.DataType.STRING)); attrDefs.add(new AttributeDef("uniquemember", AttributeDef.DataType.STRING)); // Add User entity definition List<EntityDef> entityDefs = new ArrayList<EntityDef>(); EntityDef userEntityDef = new EntityDef("User", EntityDef.EntityType.USER, "cn"); userEntityDef.addAttribute(new AttributeRef("cn")); userEntityDef.addAttribute(new AttributeRef("firstname")); userEntityDef.addAttribute(new AttributeRef("sn")); userEntityDef.addAttribute(new AttributeRef("telephonenumber")); userEntityDef.addAttribute(new AttributeRef("uid")); entityDefs.add(userEntityDef); // Add Group entity definition EntityDef groupEntityDef = new EntityDef("Group", EntityDef.EntityType.GROUP, "cn"); groupEntityDef.addAttribute(new AttributeRef("cn")); groupEntityDef.addAttribute(new AttributeRef("uniquemember", false, AttributeRef.FilterType.EQUALS)); entityDefs.add(groupEntityDef); // Add Entity relationship definition List<EntityRelationship> entityRelations = new ArrayList<EntityRelationship>(); entityRelations.add(new EntityRelationship("user_memberOfGroup", EntityRelationship.RelationshipType.MANYTOMANY, "User", "principal", "Group", "uniquemember")); entityRelations.add(new EntityRelationship("group_memberOfGroup", EntityRelationship.RelationshipType.MANYTOMANY, "Group", "principal", "Group", "uniquemember", true)); EntitiesConfig entityCfg = new EntitiesConfig(attrDefs, entityDefs, entityRelations); // Create physical Identity Store configuration IdentityStoreConfig idStoreCfg = new IdentityStoreConfig( "ldap://host1:389,ldap://host2:389", "cn=orcladmin", "password".toCharArray(), IdentityStoreConfig.IdentityStoreType.OID); idStoreCfg.setHighAvailabilityOption(IdentityStoreConfig.HAOption.FAILOVER); idStoreCfg.setProperty(IdentityStoreConfig.HEARTBEAT_INTERVAL, "60"); idStoreCfg.setProperty(IdentityStoreConfig.CONN_TIMEOUT, "30000"); // milli sec idStoreCfg.setProperty(IdentityStoreConfig.MIN_POOLSIZE, "5"); idStoreCfg.setProperty(IdentityStoreConfig.MAX_POOLSIZE, "10"); idStoreCfg.setProperty(IdentityStoreConfig.MAX_POOLWAIT, "1000"); // milli sec idStoreCfg.setProperty(IdentityStoreConfig.MAX_POOLCHECKS, "10"); idStoreCfg.setProperty(IdentityStoreConfig.FOLLOW_REFERRAL, "false"); idStoreCfg.setAttrMapping("firstname", "givenname"); // Set operational config OperationalConfig opConfig = new OperationalConfig(); opConfig.setEntityProperty(opConfig.USER_ENTITY, opConfig.SEARCH_BASE, "cn=users,dc=us,dc=example,dc=com"); opConfig.setEntityProperty(opConfig.USER_ENTITY, opConfig.CREATE_BASE, "cn=users,dc=us,dc=example,dc=com"); opConfig.setEntityProperty(opConfig.USER_ENTITY, opConfig.NAME_ATTR, "cn"); opConfig.setEntityProperty(opConfig.USER_ENTITY, opConfig.FILTER _OBJCLASSES, "inetorgperson"); opConfig.setEntityProperty(opConfig.USER_ENTITY, opConfig.CREATE _OBJCLASSES, "inetorgperson"); opConfig.setEntityProperty(opConfig.GROUP_ENTITY, opConfig.SEARCH_BASE, "cn=groups,dc=us,dc=example,dc=com"); opConfig.setEntityProperty(opConfig.GROUP_ENTITY, opConfig.CREATE_BASE, "cn=groups,dc=us,dc=example,dc=com"); opConfig.setEntityProperty(opConfig.GROUP_ENTITY, opConfig.NAME_ATTR, "cn"); opConfig.setEntityProperty(opConfig.GROUP_ENTITY, opConfig.FILTER _OBJCLASSES, "groupofuniquenames"); opConfig.setEntityProperty(opConfig.GROUP_ENTITY, opConfig.CREATE _OBJCLASSES, "groupofuniquenames"); // Initialize Identity Store Service IdentityDirectoryFactory factory = new IdentityDirectoryFactory(); ids = factory.getIdentityDirectory("ids1", entityCfg, idStoreCfg, opConfig); // Get UserManager and GroupManager handles uMgr = ids.getUserManager(); gMgr = ids.getGroupManager(); } }
アイデンティティ・ストアにユーザーを追加できます。
次のコード・サンプルでは、アイデンティティ・ストアにユーザーを追加します。
Principal principal = null; List<Attribute> attrs = new ArrayList<Attribute>(); attrs.add(new Attribute("commonname", "test1_user1")); attrs.add(new Attribute("password", "mypassword".toCharArray())); attrs.add(new Attribute("firstname", "test1")); attrs.add(new Attribute("lastname", "user1")); attrs.add(new Attribute("mail", "test1.user1@example.com")); attrs.add(new Attribute("telephone", "1 650 123 0001")); attrs.add(new Attribute("title", "Senior Director")); attrs.add(new Attribute("uid", "tuser1")); try { CreateOptions createOpts = new CreateOptions(); principal = uMgr.createUser(attrs, createOpts); System.out.println("Created user " + principal.getName()); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
指定されたプリンシパルのユーザーを取得するには、次のサンプル・コードを使用します。
User user = null; try { ReadOptions readOpts = new ReadOptions(); user = uMgr.getUser(principal, readOpts); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
アイデンティティ・ディレクトリのユーザーを変更するには、次のコード・サンプルを使用します。
try { ModifyOptions modifyOpts = new ModifyOptions(); List<ModAttribute> attrs = new ArrayList<ModAttribute>(); attrs.add(new ModAttribute("description", "modified test user 1")); user.modify(attrs, modifyOpts); System.out.println("Modified user " + user.getName()); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
指定されたアイデンティティ値と一致するユーザーを取得するには、次のサンプル・コードを使用します。
try { ReadOptions readOpts = new ReadOptions(); User user = uMgr.searchUser("tuser1", readOpts); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
複雑な検索フィルタを使用してユーザーを検索するには、次のコード・サンプルを使用します。
try { // Complex search filter with nested AND and OR conditiions SearchFilter filter = new SearchFilter( SearchFilter.LogicalOp.OR, new SearchFilter(SearchFilter.LogicalOp.AND, new SearchFilter("firstname", SearchFilter.Operator.BEGINS_WITH, "test"), new SearchFilter("telephone", SearchFilter.Operator.CONTAINS, "650")), new SearchFilter(SearchFilter.LogicalOp.AND, new SearchFilter("firstname", SearchFilter.Operator.BEGINS_WITH, "demo"), new SearchFilter(SearchFilter.LogicalOp.OR, new SearchFilter("orgunit", SearchFilter.Operator.BEGINS_WITH, "hr"), new SearchFilter("orgunit", SearchFilter.Operator.BEGINS_WITH, "it"), new SearchFilter("telephone", SearchFilter.Operator.CONTAINS, "650"))); // Requesting attributes List<String> reqAttrs = new ArrayList<String>(); reqAttrs.add("jpegphoto"); SearchOptions searchOpts = new SearchOptions(); searchOpts.setPageSize(100); searchOpts.setRequestedAttrs(reqAttrs); searchOpts.setSortAttrs(new String[] {"firstname"}); ResultSet<User> sr = uMgr.searchUsers(filter, searchOpts); while (sr.hasMore()) { User user = sr.getNext(); System.out.println(user.getSubjectName()); } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
次のコード・サンプルは、ユーザー・パスワードの変更方法を示しています。
ModifyOptions modOpts = new ModifyOptions(); try { user.changePassword("welcome123".toCharArray(), "welcome1".toCharArray(), modOpts); System.out.println("Changed user password"); } catch (Exception e) { System.out.println("Failed to change user password"); e.printStackTrace(); }
ユーザー・パスワードをリセットするには、次のサンプル・コードを使用します。
ModifyOptions modOpts = new ModifyOptions(); try { user.resetPassword("welcome123".toCharArray(), modOpts); System.out.println("Reset user password"); } catch (Exception e) { System.out.println("Failed to reset user password"); e.printStackTrace(); }
APIを使用してユーザーを認証できます。
次のコード・サンプルは、ユーザーの認証方法を示しています。
ReadOptions readOpts = new ReadOptions(); try { User user = uMgr.authenticateUser("tuser1", "mypassword".toCharArray(), readOpts); System.out.println("authentication success"); } catch (Exception e) { System.out.println("Authentication failed. " + e.getMessage()); e.printStackTrace(); }
ユーザーを削除するには、次のコード・サンプルを使用します。
try { DeleteOptions deleteOpts = new DeleteOptions(); uMgr.deleteUser(principal, deleteOpts); System.out.println("Deleted user " + principal.getName()); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
グループを作成するには、次のサンプル・コードを使用します。
Principal principal = null; List<Attribute> attrs = new ArrayList<Attribute>(); attrs.add(new Attribute("name", "test1_group1")); attrs.add(new Attribute("description", "created test group 1")); attrs.add(new Attribute("displayname", "test1 group1")); try { CreateOptions createOpts = new CreateOptions(); principal = gMgr.createGroup(attrs, createOpts); System.out.println("Created group " + principal.getName()); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
グループを検索するには、次のコード・サンプルを使用します。
public void searchGroups() { try { SearchFilter filter = new SearchFilter("name", SearchFilter.Operator.BEGINS_WITH, "test"); SearchOptions searchOpts = new SearchOptions(); searchOpts.setPageSize(10); ResultSet<Group> sr = gMgr.searchGroups(filter, searchOpts); while (sr.hasMore()) { Group group = sr.getNext(); System.out.println(group.getSubjectName()); } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
次のコード・サンプルを使用して、管理チェーンの取得方法を示します。
try { ReadOptions readOpts = new ReadOptions(); User user = uMgr.searchUser("tuser1", readOpts); SearchOptions searchOpts = new SearchOptions(); searchOpts.setPageSize(10); int nLevels = 0; ResultSet<User> sr = user.getManagementChain(nLevels, searchOpts); while (sr.hasMore()) { User u = sr.getNext(); System.out.println(u.getSubjectName()); } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
次のコード・サンプルを使用して、ユーザーのReporteeの取得方法を示します。
// Get Reportees with target search filter public void getReportees() { try { ReadOptions readOpts = new ReadOptions(); User user = uMgr.searchUser("tuser1", readOpts); SearchOptions searchOpts = new SearchOptions(); searchOpts.setPageSize(20); int nLevels = 0; // get all the direct/indirect reporting of tuser1 who are "developers" SearchFilter filter = new SearchFilter("title", SearchFilter.Operator.CONTAINS, "developer"); ResultSet<User> sr = user.getReportees(nLevels, filter, searchOpts); while (sr.hasMore()) { User u = sr.getNext(); System.out.println(u.getSubjectName()); } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
グループにメンバーを追加できます。
次のコード・サンプルでは、グループにメンバーを追加します。
try { ReadOptions readOpts = new ReadOptions(); User user = uMgr.searchUser("tuser1", readOpts); Group group = gMgr.searchGroup("test1_group1", readOpts); ModifyOptions modOpts = new ModifyOptions(); user.addMemberOf(group, modOpts); System.out.println("added tuser1 as a member of test1_group1"); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
グループからメンバーを削除するには、次のコード・サンプルを使用します。
try { ReadOptions readOpts = new ReadOptions(); User user = uMgr.searchUser("tuser1", readOpts); Group group = gMgr.searchGroup("test1_group1", readOpts); ModifyOptions modOpts = new ModifyOptions(); group.deleteMember(user, modOpts); System.out.println("deleted tuser1 from the group test1_group1"); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
注意:
Identity Governance Framework/Identity Directory Serviceのグループ・メンバーシップ検索では、静的グループと動的グループの両方を評価します。ただし、メンバーシップの更新(追加/削除)は、動的グループではサポートされません。たとえば、グループからメンバーを削除する際に、そのメンバーがそのグループの動的メンバーである場合、動的グループでは削除操作がサポートされません。
ユーザーがメンバーとなっているグループをすべて取得するには、次のコード・サンプルを使用します。
try { ReadOptions readOpts = new ReadOptions(); User user = uMgr.searchUser("tuser1", readOpts); SearchOptions searchOpts = new SearchOptions(); searchOpts.setPageSize(10); int nLevels = 0; ResultSet<Group> sr = user.getMemberOfGroups(nLevels, null, searchOpts); while (sr.hasMore()) { Group group = sr.getNext(); System.out.println(group.getSubjectName()); } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
次のコード・サンプルを使用して、検索フィルタでのNOT演算子の使用方法を示します。
try { SearchFilter f1 = new SearchFilter("firstname", SearchFilter.Operator.BEGINS_WITH, "demo"); SearchFilter f2 = new SearchFilter("orgunit", SearchFilter.Operator.CONTAINS, "myorg"); f2.negate(); SearchFilter filter = new SearchFilter(SearchFilter.LogicalOp.AND, f1, f2); ResultSet<User> sr = uMgr.searchUsers(filter, searchOpts); }