Hi Ninad,
I’ve a piece of code for it but no information why we use it. I got it from some where and it might help you.
IContext context context = ContextFactory.acquireContext(true);
IDirUser user = (IDirUser) dirSystemPolicy.lookupPrincipalByID(context, userID, IDirSystem.TYPE_USER);
IThingID userThingID = user.getDirectoryPrincipalID();
boolean currentUser = context.isAdminSession();
context.impersonate(userThingID, currentIsAdmin );
#MWS-CAF-Task-Engine#webMethods#webMethods-BPMS