2 Replies Latest reply on Dec 10, 2012 2:04 PM by Ashish Easow

    Working with User and Role API

      I am having usecase to access information of my users. eg. getting email etc.
      I am using SQLAuthenticator and able to access users using dbprovider.jar which is sample application, My USER table has columns U_NAME, U_PASSWORD, U_DESCRIPTION AND EMPLOYEE_ID, where EMPLOYEE_ID pointing to my EMPLOYEE table which holds further information of USER like EMAIL, CONTACT_INFO etc.

      *1. How can I access other fields present in database, for example how can I access U_DESCRIPTION ?*
      *2. I am stuck how to access EMPLOYEE table's fields (email, contact_no, etc) using User and Role API or any other way ? so that It can be called in SOA/BPM related functions like ids:getUserProperty(ora:getCreator(),'mail')?*

      My code is as following to have idea what I have achieved so far.

      IdentityStoreFactoryBuilder builder = new IdentityStoreFactoryBuilder();
      IdentityStoreFactory factory = null;
      IdentityStore store = null;
      try {
      Hashtable factEnv = new Hashtable();
      Hashtable storeEnv = new Hashtable();


      factory =
      System.out.println("Factory: " + factory);

      store = factory.getIdentityStoreInstance(storeEnv);
      System.out.println("Store: " + store);

      SimpleSearchFilter sf =
      SimpleSearchFilter.TYPE_EQUAL, null);
      sf.setValue("j" + sf.getWildCardChar());

      SearchParameters params = new SearchParameters();

      Class cls = Class.forName("oracle.security.idm.UserProfile");
      Field[] flds = cls.getFields();
      int len = flds.length;

      // Searching for users
      SearchResponse resp = store.searchUsers(params);
      UserManager umanager = store.getUserManager();
      System.out.println("Searched users are:");
      while (resp.hasNext()) {
      Identity idy = resp.next();
      UserProfile userProfile = (UserProfile)idy;
      System.out.println("Unique name: " + idy.getUniqueName());
      System.out.println("GUID: " + idy.getGUID());

      for (int i = 0; i < len; i++) {
      String fname = flds.getName();
      System.out.println(fname + ": " + userProfile.getPropertyVal(fname)); //it is returning only user name for all sout print

      Will appreciate for quick reply, thanks in advance.