Sec. 9. Sanctuary Jurisdictions. It is the policy of the executive branch to ensure, to the fullest extent of the law, that a State, or a political subdivision of a State, shall comply with 8 U.S.C. 1373.This section has been challenged in court as illegal and unconstitutional.
(a) In furtherance of this policy, the Attorney General and the Secretary [of Homeland Security], in their discretion and to the extent consistent with law, shall ensure that jurisdictions that willfully refuse to comply with 8 U.S.C. 1373 (sanctuary jurisdictions) are not eligible to receive Federal grants, except as deemed necessary for law enforcement purposes by the Attorney General or the Secretary. The Secretary has the authority to designate, in his discretion and to the extent consistent with law, a jurisdiction as a sanctuary jurisdiction. The Attorney General shall take appropriate enforcement action against any entity that violates 8 U.S.C. 1373, or which has in effect a statute, policy, or practice that prevents or hinders the enforcement of Federal law.
If it occurs to you that a direction from the chief executive to his subordinates that is expressly limited by its terms to actions "consistent with law" cannot possibly be illegal, congratulations, you understand law better than a federal district judge.