2. Given the function $f(x)=x^{2}-2 a x+2 a+4$ with the domain $R$ and the range $[1,+\infty]$. Then the value of $a$ is ).
(A) interval $[-1,3$ ]
(B) interval $(1-\sqrt{5}, 1+\sqrt{5})$
(C) interval $(-\infty,-1) \cup(3,+\infty)$
(D) set $\{-1,3\}$