Specifying Search Parameters Searching the Repository

Developing with the User and Role API 25-23 while resp.hasNext { Identity idy = resp.next; System.out.printlnUnique name: +idy.getUniqueName; } }catch IMException e { e.printStackTrace; } } } Searching for Users and Searching for Groups When searching for users, you invoke UserProfile, as in the above example with SimpleSearchFilter. When searching for groups, however, you use RoleProfile instead.

25.7.2 Example 2: User Management in an Oracle Internet Directory Store

In this example several user management tasks such as creating, modifying, and dropping an identity are performed in an Oracle Internet Directory store: ■ creating a user ■ modifying the user’s display name ■ dropping the user public class CreateModifyDeleteUser { public static void mainString args[] { IdentityStoreFactoryBuilder builder = new IdentityStoreFactoryBuilder; IdentityStoreFactory oidFactory = null; IdentityStore oidStore = null; try { Hashtable factEnv = new Hashtable; Hashtable storeEnv = new Hashtable; creating the factory instance factEnv.putOIDIdentityStoreFactory.ST_SECURITY_PRINCIPAL, User DN; factEnv.putOIDIdentityStoreFactory.ST_SECURITY_CREDENTIALS, User password; factEnv.putOIDIdentityStoreFactory.ST_LDAP_URL, ldap:ldaphost:port; oidFactory = builder.getIdentityStoreFactory oracle.security.idm.providers.oid. OIDIdentityStoreFactory, factEnv; creating the store instance storeEnv.putOIDIdentityStoreFactory.RT_SUBSCRIBER_NAME, dc=us,dc=oracle,dc=com; oidStore = oidFactory.getIdentityStoreInstancestoreEnv; get UserManager 25-24 Oracle Fusion Middleware Application Security Guide UserManager usrmanager = oidStore.getUserManager; create user String usrname = testuser; delete user if already exists try { User usr = oidStore.searchUserusrname; usrmanager.dropUserusr; }catchIMException ime{} System.out.printlncreating user +usrname; User usr = usrmanager.createUserusrname,passwd1.toCharArray; System.out.printlnuser +usr.getUniqueName + created; modifying user properties System.out.printlnmodifying property UserProfile.DISPLAY_NAME; UserProfile usrprofile = usr.getUserProfile; ModProperty mprop = new ModProperty UserProfile.DISPLAY_NAME, modified display name, ModProperty.REPLACE; usrprofile.setPropertymprop; System.out.printlnget property values UserProfile.DISPLAY_NAME; Property prop = usrprofile.getPropertyUserProfile.DISPLAY_NAME; List values = prop.getValues; Iterator itr = values.iterator; whileitr.hasNext { System.out.printlnUserProfile.DISPLAY_NAME+: + itr.next; } System.out.println; drop user System.out.printlnNow dropping user +usrname; usrmanager.dropUserusr; System.out.printlnuser dropped; }catch IMException e { e.printStackTrace; } } }

25.7.3 Example 3: User Management in a Microsoft Active Directory Store

In this example several user management tasks such as creating, modifying, and dropping an identity are performed in a Microsoft Active Directory store: ■ creating a user ■ modifying the user’s display name ■ dropping the user