The effective anchoring energy resulting from the ionic adsorption phenomenon in a nematic liquid-crystal sample in the shape of a slab of thickness d is investigated. The electric field distribution is determined in the framework of a general nonlinear Poisson-Boltzmann approach. The analysis is particularized for the case in which d>>lambdaD, where lambdaD is the Debye screening length. In this limit, the spatially dependent electric field distribution across the sample as well as the contribution, of dielectric and flexoelectric origins, to the effective anchoring energy is obtained in an exact manner.