In this paper we consider the optimal management of an aggregated dynamic pension fund. There are n classes of workers whose salaries are stochastic. A portion of the salary is contributed to the funding process and the manager invests in a portfolio with m risky assets and a risk-free security. The main objective is to minimize the cost of contributions in a bounded horizon T and to maximize the utility of final surplus, measured as the relative fund level respect to the mean salary. The aim of the paper is to describe the properties of fund allocation and optimal contribution when salaries differ across contributors to the fund.Both authors gratefully acknowledge financial support from Consejería de Educación y Cultura de la Junta de Cast...