@Reference
ResourceResolverFactory resolverFactory;
ResourceResolver adminResolver = null;
Session adminSession=null;
try {
adminResolver = resolverFactory.getAdministrativeResourceResolver(null);
adminSession = adminResolver.adaptTo(Session.class);
final UserManager userManager= adminResolver.adaptTo(UserManager.class);
Authorizable authorizable = userManager.getAuthorizable("userName");
if (authorizable instanceof User) {
User user = (User)authorizable;
user.remove(); //Remove the user
user.disable() // Disable the user.
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (adminResolver != null) adminResolver.close();
}
No comments:
Post a Comment
If you have any doubts or questions, please let us know.