u.setClearPassword(password);
// And the user to the "users" group, create if needed
List<Group> groups = groupManager.getGroups();
if (groups == null || groups.isEmpty() || groups.size() == 0) {
Group userGroup = new Group();
userGroup.setName("users");
userManager.create(u, userGroup);
} else {
for (Group g : groups) {
if (g.getName().equals("users")) {
userManager.createWithExistingGroup(u, g);