MB3 45a: Bameh Madlikin (270:1-2)

The reasons why we say bameh madlikin on Friday Night; saying it before or after maariv, and saying it on Chol HaMoed or when Yom Tov is Friday or Shabbos.

Correction: The Aruch Hashulchan states that the Zohar advises one to say Kegavna (and does not mention Bameh Madlikin).