  Future particle accelerators such as the the SLAC ``Linac Coherent Light
Source-II'' (LCLS-II) and the proposed Cornell Energy Recovery Linac (ERL)
require hundreds of superconducting radio-frequency (SRF) cavities operating in
continuous wave (CW) mode. In order to achieve economic feasibility of projects
such as these, the cavities must achieve a very high intrinsic quality factor
($Q_0$) to keep cryogenic losses within feasible limits. To reach these high
$Q_0$'s in the case of LCLS-II, nitrogen-doping has been proposed as a cavity
preparation technique. When dealing with $Q_0$'s greater than 1\e{10}, the
effects of ambient magnetic field on $Q_0$ become significant. Here we show
that the sensitivity to RF losses from trapped magnetic field in a cavity's
walls is strongly dependent on the cavity preparation. Specifically, standard
electropolished and 120$^\circ$C baked cavities show a residual resistance
sensitivity to trapped magnetic flux of $\sim0.6$ and $\sim0.8$ n$\Omega$/mG
trapped, respectively, while nitrogen-doped cavities show a sensitivity of
$\sim$ 1 to 5 n$\Omega$/mG trapped. We show that this difference in
sensitivities is directly related to the mean free path of the RF surface layer
of the niobium: shorter mean free paths lead to less residual resistance
sensitivity to trapped magnetic flux in the dirty limit ($\ell<<\xi_0$) while
longer mean free paths lead to lower sensitivity in the clean limit
($\ell>>\xi_0$). These experimental results are also shown to have good
agreement with recent theoretical predictions for pinned vortex lines
oscillating in RF fields.
