This is sort of a spin-off of the sedevacantist question. How should this situation be handled, in the case of a latae sententiae excommunication?
Can. 1331 §1. An excommunicated person is forbidden:
1/ to have any ministerial participation in celebrating the sacrifice of the Eucharist or any other ceremonies of worship whatsoever;
2/ to celebrate the sacraments or sacramentals and to receive the sacraments;
3/ to exercise any ecclesiastical offices, ministries, or functions whatsoever or to place acts of governance.