code: public List<CmsOrganizationalUnit> getOrgUnitsForRole(CmsDbContext dbc, CmsRole role, boolean includeSubOus)
      throws CmsException {
  
          String ouFqn = role.getOuFqn();
          if (ouFqn == null) {
              ouFqn = "";
              role = role.forOrgUnit("");
          }
          CmsOrganizationalUnit ou = readOrganizationalUnit(dbc, ouFqn);
          List<CmsOrganizationalUnit> orgUnits = new ArrayList<CmsOrganizationalUnit>();
          if (m_securityManager.hasRole(dbc, dbc.currentUser(), role)) {
              orgUnits.add(ou);
          }
          if (includeSubOus) {
              Iterator<CmsOrganizationalUnit> it = getOrganizationalUnits(dbc, ou, true).iterator();
              while (it.hasNext()) {
                  CmsOrganizationalUnit orgUnit = it.next();
                  if (m_securityManager.hasRole(dbc, dbc.currentUser(), role.forOrgUnit(orgUnit.getName()))) {
                      orgUnits.add(orgUnit);
                  }
              }
          }
          return orgUnits;
      }
docs: Returns all the organizational units for which the current user has the given role.<p>
  
  @param dbc the current database context
  @param role the role to check
  @param includeSubOus if sub organizational units should be included in the search
  
  @return a list of {@link org.opencms.security.CmsOrganizationalUnit} objects
  
  @throws CmsException if something goes wrong