UAN numbers are generated by the EPFO and assigned to employees automatically when they join a new employer and enroll in the employee provident fund.