dh.setQuery(query.toString());
List<UsersToDelete> usersToDelete = dh.list();
if (usersToDelete != null) {
Iterator<UsersToDelete> iterUsersToDelete = usersToDelete.iterator();
UsersToDelete userToDelete;
User user;
Company comp = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany();
UserAPI uAPI = APILocator.getUserAPI();
User sysUser = uAPI.getSystemUser();
for (; iterUsersToDelete.hasNext();) {
try {
userToDelete = iterUsersToDelete.next();
if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
user = uAPI.loadByUserByEmail(userToDelete.getUserId(), sysUser, false);
} else {
user = uAPI.loadUserById(userToDelete.getUserId(), sysUser, false);
}
user.setActive(false);
uAPI.save(user, sysUser, false);