In this work, we propose a method to prescribe essential boundary conditions in the finite element approximation of elliptic problems when the boundary of the computational domain does not match with the element boundaries. The problems considered are the Poisson problem, the Stokes problem, and the Darcy problem, the latter both in the primal and in the dual formulation. The formulation proposed is of variational type. The key idea is to start with the variational form that defines the problem and treat the boundary condition as a constraint. The particular feature is that the Lagrange multiplier is not defined on the boundary where the essential condition needs to be prescribed but is taken as a certain trace of a field defined in the computational domain, either in all of it or just in a region surrounding the boundary. When approximated numerically, this may allow one to condense the DOFs of the new field and end up with a problem posed only in terms of the original unknowns. The nature of the field used to weakly impose boundary conditions depends on the problem being treated. For the Poisson problem, it is a flux; for the Stokes problem, a stress; for the Darcy problem in primal form, a velocity field; and for the Darcy problem in dual form, it is a potential.