Forbidden configurations for distributive and modular ordered sets