The Emirates' desire to promote itself as a cosmopolitan and tolerant corner of the Middle East has at times run up against local laws, which are based in part on Islamic legal codes and forbid sex outside of marriage.