7 Replies Latest reply: Nov 20, 2012 1:23 AM by 879020 RSS

    Make Search by user defined attribute -11G Release2

    879020
      Hi all,

      I have a user defined attribute in the name UserReconKey, an I use the below query for OIM search, but when try to get value from result I get the Thor.API.Exceptions.tcColumnNotFoundException exception, how I can get my user defined attribute value ? Any help is strongly appreciated...

           tcUserOperationsIntf userOp =
                Platform.getService(tcUserOperationsIntf.class);

           Map searchAttr = new HashMap();
           searchAttr.put("Users.Email", email);
           String[] returnColumns =
                new String[] { "Users.Email", "UserReconKey" };
           tcResultSet usersFound = null;

           try {
           usersFound = userOp.findUsersFiltered(searchAttr, returnColumns);

           for (int i = 0; i < usersFound.getTotalRowCount(); i++) {
                usersFound.goToRow(i);
                String _userReconKey =
                          usersFound.getStringValue("UserReconKey");

           }

      BR
      Aliye
        • 1. Re: Make Search by user defined attribute -11G Release2
          Nishith Nayan
          use label name of udf instead of database attribute. lablel which has been given during UDF creation

          you can share your UDF label name so that we can help you. go to Sysadmin->Form->User-> verify the UDF label given by you( exclude what is added bydefault)
          • 2. Re: Make Search by user defined attribute -11G Release2
            Nishith Nayan
            You can try 11g API as well for searching user like below:


            import oracle.iam.identity.usermgmt.api.UserManager;
            import oracle.iam.identity.usermgmt.api.UserManagerConstants;
            import oracle.iam.identity.usermgmt.vo.User;
            import oracle.iam.platform.entitymgr.vo.SearchCriteria;


            HashMap<String, Object> parameters = null;
            Set<String> attrNames = null;
            SearchCriteria criteria = null;

            criteria = new SearchCriteria(new SearchCriteria("User Login","TESTUSER",SearchCriteria.Operator.EQUAL), new SearchCriteria("Status","Active",SearchCriteria.Operator.EQUAL), SearchCriteria.Operator.AND);


            parameters = new HashMap<String, Object>();
            parameters.put("STARTROW", 0);
            parameters.put("ENDROW", -1);
            UserManager um=Platform.getService(UserManager.class);
            List<User> users = um.search(criteria,null, parameters);
            for(int i=0;ll<users.size();i++){
            User uu=users.get(i);

            System.out.println(uu.getAttribute(UserManagerConstants.AttributeName.USER_LOGIN.getId()));
            }

            print UU(user object) directly and you will be knowing the attribute name
            • 3. Re: Make Search by user defined attribute -11G Release2
              879020
              Thank you Nayan for your fast response..

              The label is "User Recon Key", I tried with it but the same result, again getting the Thor.API.Exceptions.tcColumnNotFoundException error...

              I also trying the search with the below code, this time I get the error Caused by: oracle.iam.identity.exception.SearchAttributeAccessDeniedException: You do not have permission to search the following user attributes: User Recon Key.
              I can not understand what is wrong ... Thank you for your help...


                   UserManager userManager = Platform.getService(UserManager.class);
                   //define the crieteria
                   oracle.iam.platform.entitymgr.vo.SearchCriteria criteria =
                        new oracle.iam.platform.entitymgr.vo.SearchCriteria("User Recon Key", userReconKey,
                                                      oracle.iam.platform.entitymgr.vo.SearchCriteria.Operator.EQUAL);

                   // Attributes that should be returned as part of the search.
                   // Retrieve "User Login" attribute of the User.
                   // Note: Additional attributes can be specified in a
                   // similar fashion.
                   Set<String> retAttrs = new HashSet<String>();
                   retAttrs.add("Users.User ID");

                   // Use 'search' method of UserManager API to retrieve
                   // records that match the search criteria. The return
                   // object is of type User.
                   List<oracle.iam.identity.usermgmt.vo.User> users;

                   try {
                   users = userManager.search(criteria, retAttrs, null);
                   } catch (UserSearchException e) {
                   e.printStackTrace();
                   }
              • 4. Re: Make Search by user defined attribute -11G Release2
                Nishith Nayan
                Mark attribute as searchable using Sysadmin. Have you exported your sandbox. have you drag this attribute on User Detail page. I mean are you able to see the attribute on user detail page.

                For verifying Same do one thing search user using User Login, print the entire Resultset as suggested above. and see if that attribute exist in the resultset. what is the attribute name. if not here means some problem with the attribute.

                You have to include this attribute on all three pages(Create, Edit and Detial ) page separately . same time look at the attribute properties. make sure you publish the sandbox properly.
                • 5. Re: Make Search by user defined attribute -11G Release2
                  879020
                  Hmm I mark it as searchable but did not add it to the pages, I will add it to the pages and see what happens then...
                  • 6. Re: Make Search by user defined attribute -11G Release2
                    Nishith Nayan
                    for detail page choose data component as 'Manage User' then UserVo1
                    • 7. Re: Make Search by user defined attribute -11G Release2
                      879020
                      Hi Nayan,

                      Finally it worked. I did not had to add my attribute to the pages, I used the 11g search query you offered, the only difference was the start and end row parameters and return attributes. I did it as you suggested in the way below and all was fine, thank you for your help...

                           String userLogin=null;
                           UserManager userManager = Platform.getService(UserManager.class);
                           //define the crieteria
                           oracle.iam.platform.entitymgr.vo.SearchCriteria criteria =
                                new oracle.iam.platform.entitymgr.vo.SearchCriteria("UserReconKey", userReconKey,
                                                              oracle.iam.platform.entitymgr.vo.SearchCriteria.Operator.EQUAL);

                           HashMap<String, Object> parameters = new HashMap<String, Object>();
                           parameters.put("STARTROW", 0);
                           parameters.put("ENDROW", -1);

                           List<oracle.iam.identity.usermgmt.vo.User> users;

                           try {
                           users = userManager.search(criteria, null, parameters);
                           System.out.println("User Count Found For Recon Key : "+userReconKey+" -> "+users.size());
                           
                           
                           if(users!=null && users.size()>0){
                           displayAttributes(users.get(0).getAttributes());
                           userLogin = (String)users.get(0).getAttribute(UserManagerConstants.AttributeName.USER_LOGIN.getId());
                           }

                      System.out.println("User Login Returned : "+userLogin);
                           } catch (UserSearchException e) {
                           e.printStackTrace();
                           }