Total Pageviews

Tuesday, October 23, 2018

Code to fetch UserKey from UserLogin OIM

public String getUserkey(String userLogin) {
          logger.info("getUserkey method started");
          UserManager usrMgr = Platform.getService(UserManager.class);
          User user = new User(userLogin);
          Set restSet = new HashSet();
          restSet.add("usr_key");
          String userKey = null;

          try {
              user =
    usrMgr.getDetails("User Login", userLogin, null); // getting the user key based on userlogin
          } catch (NoSuchUserException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (UserLookupException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (SearchKeyNotUniqueException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (NullPointerException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (Exception e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          }

          userKey = user.getEntityId();

          return userKey;
      }

No comments:

Post a Comment