§ 1. The following incur a latae sententiae interdict or, if a cleric, also a latae sententiae suspension: 1° a person who, not being an ordained priest, attempts the liturgical celebration of the Eucharistic Sacrifice; 2° a person who, apart from the case mentioned in can. 1384, though unable to give valid sacramental absolution, attempts to do so, or hears a sacramental confession. § 2. In the cases mentioned in § 1, other penalties, not excluding excommunication, can be added, according to the gravity of the offence. § 3. Both a person who attempts to confer a sacred order on a woman, and the woman who attempts to receive the sacred order, incur a latae sententiae excommunication reserved to the Apostolic See; a cleric, moreover, may be punished by dismissal from the clerical state. § 4. A person who deliberately administers a sacrament to those who are prohibited from receiving it is to be punished with suspension, to which other penalties mentioned in can. 1336 §§ 2-4 may be added. § 5. A person who, apart from the cases mentioned in §§ 1-4 and in can. 1384, pretends to administer a sacrament is to be punished with a just penalty.
Source: Code of Canon Law (Vatican.va)