private void loadUserDns(Group group) throws SecurityException {
    if (CollectionUtils.isNotEmpty(group.getMembers())) {
      ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();
      List<String> userDns = new ArrayList<String>();

      for (String member : group.getMembers()) {
        User user = reviewMgr.readUser(new User(member));
        userDns.add(user.getDn());
      }

      group.setMembers(userDns);
    }
  }
  private void loadRoleDns(Group group) throws SecurityException {
    if (CollectionUtils.isNotEmpty(group.getMembers())) {
      ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(this.contextId);
      List<String> roleDns = new ArrayList<String>();

      for (String member : group.getMembers()) {
        Role role = reviewMgr.readRole(new Role(member));
        roleDns.add(role.getDn());
      }

      group.setMembers(roleDns);
    }
  }
  /**
   * @param group
   * @throws org.apache.directory.fortress.core.CreateException
   */
  Group create(Group group) throws CreateException {
    LdapConnection ld = null;
    String nodeDn = getDn(group.getName(), group.getContextId());

    try {
      LOG.debug("create group dn [{}]", nodeDn);
      Entry myEntry = new DefaultEntry(nodeDn);
      myEntry.add(SchemaConstants.OBJECT_CLASS_AT, GROUP_OBJ_CLASS);
      myEntry.add(SchemaConstants.CN_AT, group.getName());
      // protocol is required:
      myEntry.add(GROUP_PROTOCOL_ATTR_IMPL, group.getProtocol());
      // type is required:
      myEntry.add(GlobalIds.TYPE, group.getType().toString());

      loadAttrs(group.getMembers(), myEntry, SchemaConstants.MEMBER_AT);
      loadProperties(group.getProperties(), myEntry, GROUP_PROPERTY_ATTR_IMPL, '=');

      if (StringUtils.isNotEmpty(group.getDescription())) {
        myEntry.add(SchemaConstants.DESCRIPTION_AT, group.getDescription());
      }

      ld = getAdminConnection();
      add(ld, myEntry);
    } catch (LdapException e) {
      String error = "create group node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage();
      throw new CreateException(GlobalErrIds.GROUP_ADD_FAILED, error, e);
    } finally {
      closeAdminConnection(ld);
    }

    return group;
  }
  /**
   * @param group
   * @return
   * @throws org.apache.directory.fortress.core.CreateException
   */
  Group update(Group group) throws FinderException, UpdateException {
    LdapConnection ld = null;
    String nodeDn = getDn(group.getName(), group.getContextId());

    try {
      LOG.debug("update group dn [{}]", nodeDn);
      List<Modification> mods = new ArrayList<Modification>();

      if (StringUtils.isNotEmpty(group.getDescription())) {
        mods.add(
            new DefaultModification(
                ModificationOperation.REPLACE_ATTRIBUTE,
                SchemaConstants.DESCRIPTION_AT,
                group.getDescription()));
      }

      if (StringUtils.isNotEmpty(group.getProtocol())) {
        mods.add(
            new DefaultModification(
                ModificationOperation.REPLACE_ATTRIBUTE,
                GROUP_PROTOCOL_ATTR_IMPL,
                group.getProtocol()));
      }

      loadAttrs(group.getMembers(), mods, SchemaConstants.MEMBER_AT);
      loadProperties(group.getProperties(), mods, GROUP_PROPERTY_ATTR_IMPL, true, '=');

      if (mods.size() > 0) {
        ld = getAdminConnection();
        modify(ld, nodeDn, mods, group);
      }
    } catch (LdapException e) {
      String error = "update group node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage();
      throw new UpdateException(GlobalErrIds.GROUP_UPDATE_FAILED, error, e);
    } finally {
      closeAdminConnection(ld);
    }
    return get(group);
  }