Validity and liceity of administration of the sacraments
As stated above, the effect of the sacraments comes ex opere operato (by the very fact of being administered). Since it is Christ who operates through them, their effectiveness does not depend on the worthiness of the minister.
However, an apparent administration of a sacrament is invalid, if the person acting as minister does not have the necessary power (as if a deacon were to celebrate Mass). They are also invalid if the required "matter" or "form" is lacking. The matter is the perceptible material object, such as water in baptism or wheaten bread and grape wine for the Eucharist, or the visible action. The form is the verbal statement that specifies the signification of the matter, such as, (in the Western Church), "N., I baptize you in the name of the Father, and of the Son, and of the Holy Spirit". Furthermore, if the minister positively excludes some essential aspect of the sacrament, the sacrament is invalid. This last condition lies behind the 1896 judgement of the Holy See denying the validity of Anglican Orders.
A sacrament may be administered validly, but illicitly, if a condition imposed by canon law is not observed. Obvious cases are administration of a sacrament by a priest under a penalty of excommunication or suspension, and an episcopal ordination without a mandate from the Pope.
Canon law specifies impediments to reception of the sacraments of orders and marriage. Those concerning the first of these two sacraments only concern liceity, but "a diriment impediment renders a person incapable of validly contracting a marriage" (canon 1073).
In the Latin Church, only the Holy See can authentically declare when divine law prohibits or invalidates a marriage, and only the Holy See has the right to establish for those who are baptised other impediments to marriage (canon 1075). But individual Eastern Catholic Churches, after having fulfilled certain requirements that include consulting (but not necessarily obtaining approval from) the Holy See, may establish impediments (Code of Canons of the Eastern Churches, canon 792).
If an impediment is imposed by merely ecclesiastical law, rather than being a matter of divine law, the Church may grant a dispensation from the impediment.
Conditions for validity of marriage such as sufficient use of reason (canon 1095) and freedom from coercion (canon 1103), and the requirement that, normally, a marriage be contracted in the presence of the local Ordinary or parish priest or of the priest or deacon delegated by either of them, and in the presence of two witnesses (canon 1108), are not classified in the Code of Canon Law as impediments, but have much the same effect.
Three of the sacraments may not be repeated: Baptism, Confirmation and Holy Orders: their effect is permanent. This teaching has been expressed by the images of, in the West, an indelible character or mark and of, in the East, a seal (CCC 698). However, if there is doubt about the validity of the administration of one or more of these sacraments, a conditional form of conferral may be used, such as: "If you are not already baptized, I baptize you …"