how to Delete/Disable the users through Java API in Adobe Experience Manager(AEM)
This post will explain how to Delete/Disable the users through Java API in Adobe Experience Manager(AEM).@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();
}
hi,
ReplyDeletei've tried this code, remove()method not removing the user. could you please help..
thanks,
hi,.
ReplyDeleteu missed adminSession.save();
rest all working fine.
Thanks,