code: public User setEnabled(String userName, boolean enabled, boolean broadcast) throws Exception,
        UnsupportedOperationException
     {
        User foundUser = findUserByName(userName, UserStatus.ANY);
  
        if (foundUser == null || foundUser.isEnabled() == enabled)
        {
           return foundUser;
        }
        synchronized (foundUser.getUserName())
        {
           Session session = service.getStorageSession();
           try
           {
              ((UserImpl)foundUser).setEnabled(enabled);
              if (broadcast)
                 preSetEnabled(foundUser);
              Node node = getUserNode(session, (UserImpl)foundUser);
              if (enabled)
              {
                 if (!node.canAddMixin(JCROrganizationServiceImpl.JOS_DISABLED))
                 {
                    node.removeMixin(JCROrganizationServiceImpl.JOS_DISABLED);
                    PropertyIterator pi = node.getReferences();
                    while (pi.hasNext())
                    {
                       Node n = pi.nextProperty().getParent();
                       if (!n.canAddMixin(JCROrganizationServiceImpl.JOS_DISABLED))
                       {
                          n.removeMixin(JCROrganizationServiceImpl.JOS_DISABLED);
                       }
                    }
                 }
              }
              else
              {
                 if (node.canAddMixin(JCROrganizationServiceImpl.JOS_DISABLED))
                 {
                    node.addMixin(JCROrganizationServiceImpl.JOS_DISABLED);
                    PropertyIterator pi = node.getReferences();
                    while (pi.hasNext())
                    {
                       Node n = pi.nextProperty().getParent();
                       if (n.canAddMixin(JCROrganizationServiceImpl.JOS_DISABLED))
                       {
                          n.addMixin(JCROrganizationServiceImpl.JOS_DISABLED);
                       }
                    }
                 }
              }
              session.save();
              if (broadcast)
                 postSetEnabled(foundUser);
              putInCache(foundUser);
           }
           finally
           {
              session.logout();
           }
           return foundUser;
        }
     }
docs: {@inheritDoc}