Pages

Thursday, December 20, 2012

UserManager : Misc (Lock/Unlock/Disable/Enable)

Now lets look at the other important functionalities provided by the UserManager class.

1) Code

public void misc(OIMClient oimclient){
UserManager usrMgr = oimclient.getService(UserManager.class);
try {
usrMgr.lock("65", true, true);
usrMgr.unlock("65", false);
usrMgr.disable("65", false);
usrMgr.enable("65", false);
} catch (ValidationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserLockException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchUserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserUnlockException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserDisableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserEnableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

2) Result

User is locked/unlocked/disabled/enabled as expected

3) JavaDoc

You can find more information about the UserManager class and its methods in the javadoc link.

2 comments:

  1. what is value 65 mean here. any quick help. I believe it is user key. please confirm

    ReplyDelete
    Replies
    1. Yes you are right. 65 is the user key.
      Alternately you can use the user login and provide the value 'true' for the flag.

      Delete