Quite possibly one of the least implemented security features (I'd wager that even Body Cavity Searches outdo it), a duress code is a simple extension to an access control system. Many advanced access systems require that a user enter in a PIN code in addition to presenting a badge or biometric. In such a system, a duress code is an alternate code for that user, which signals to the system that the user is under coercion. What the system does now depends on the configuration, which is typically based on the sensitivity of the facility.

High security facilities (like SCIFs), may immediately disable all access into the building, raise a visible alarm to inhibit egress, and notify the security forces, who will arrive with M-16s in a few minutes.
Probably the poorest choice, this option would simply disable the access of the user under duress. Without forcing a facility-wide shutdown, another user could easily fall into the hands of the adversary, who may have nothing to lose by terminating their original victim.
Silent alarm
In a low security facility, this would raise an alarm with the security team, who would then investigate. All other access would be as if the user had entered their normal PIN.