public static void setEnabled(User user, boolean enabled, AccountLock lock, SessionInfo session) throws Exception {
CoreServlet servlet = CoreServlet.getServlet();
try {
servlet.fireCoreEvent(new CoreEvent(servlet, CoreEventConstants.ACCOUNT_LOCKED, lock, session));
Property.setProperty(new UserAttributeKey(user, User.USER_ATTR_ENABLED), enabled, session);
servlet.fireCoreEvent(new CoreEvent(CoreServlet.getServlet(), enabled ? CoreEventConstants.GRANT_ACCESS
: CoreEventConstants.REVOKE_ACCESS, null, session, CoreEvent.STATE_SUCCESSFUL).addAttribute(
CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, user.getPrincipalName()));
} catch (Exception e) {
servlet.fireCoreEvent(new CoreEvent(servlet, enabled ? CoreEventConstants.GRANT_ACCESS
: CoreEventConstants.REVOKE_ACCESS, null, session, CoreEvent.STATE_UNSUCCESSFUL).addAttribute(