Basically it can’t be regularly enforced, but if someone with a residence permit comes to the attention of the police and they suspect a violation, they can investigate, and possibly use that violation to deport the person. In that regard the enforcement is similar to European Union or EEA citizens who stay longer than three months in a country other than their own without qualifying under one of the points in the freedom of movement directive.
It’s also similar to certain motor vehicle laws. It’s rare to be cited for failure to yield right of way unless you cause an accident.
People with a national D visa are trusted. They have permanent status in one EU country, possibly the first step to citizenship, so why would they throw that away to “go illegal” in another one?
If a violation is noticed by the authorities (e.g. illegal working in another member country) they will react. But any border controls would damage the main purpose of the Schengen rules, which is to make travel easier for citizens and permanent residents.
They aren’t controlled in a direct manner since there aren’t any regular border checks in the Schengen area. However it is still enforced indirectly:
Hundreds of thousands of people travel around Europe without a valid visa in the first place, so a small violation by legal residents is not a big deal for the Schengen members.
Credit:stackoverflow.com‘