If just one occupant consents, the police may search a home that someone else also lives in. (United States v. Matlock, 415 U. S. 164 (1974).) But if two occupants are present, one consents, and the other objects, the police usually can't search the residence. (Georgia v. Randolph, 547 U. S. 103 (2006).)
(For information on the nuances of such rules, see Agreeing to a Search and If my roommate tells the cops they can come in, but I tell them they can’t, can they?)
The U.S. Supreme Court recently decided that, when one occupant tells the police it's okay to enter, another occupant must be present in order to prevent the search. Even if the police officers are the ones to take the objecting occupant away, they can later come back and ask for the consent of the remaining occupant(s). (The police must, however, have a valid basis for hauling the objector away.)
In the case under consideration, a beaten woman answered the door after the police knocked. The officers asked her to step aside so that they could conduct a "protective sweep," but the defendant appeared and told them they couldn't come in. They arrested him for assaulting the woman and took him away, then returned approximately an hour later. They asked for and received consent to search from the same woman. They found incriminating evidence.
The Court held that the evidence was properly admitted at trial because the defendant wasn't present to object to the search. (Fernandez v. California, 571 U.S. __ (2014).)
For more on the case, see Supreme Court: Presence is Required to Prevent Certain Home Searches.