In the execution of a writ, mandate, order, or judgment of a court, the sheriff may enter on the lands, and into the residence or other building, owned or occupied by the judgment debtor or defendant. If necessary to effect entry, he may break open any door or window. If resistance is offered or threatened, he may require the assistance of the police, of neighbors, and of persons present or passing by.