Correlation functions in the Wess-Zumino-Novikov-Witten (WZNW) theory satisfy a system of Knizhnik-Zamolodchikov (KZ) equations, which involve constants of motion of an exactly solvable model, known as Gaudin magnet. We show that modified KZ equations, where the Gaudin operators are replaced by constants of motion of the closely related pairing Hamiltonian, give rise to a deformed WZNW model that contains terms breaking translational symmetry. This boundary WZNW model is identified and solved. The solution establishes a connection between the WZNW model and the pairing Hamiltonian in the theory of superconductivity. We also argue and demonstrate on an explicit example that our general approach can be used to derive exact solutions to a variety of dynamical systems.