Deputies are authorized to discharge all the duties that belong to the office of sheriff that may be placed under their charge by their principals, with the same effect as though they were executed by the respective sheriffs. If there is a vacancy in the office of sheriff, the highest-ranking deputy sheriff or under-sheriff, who is qualified to hold the office of sheriff, shall exercise the powers of sheriff until a sheriff is appointed and qualified.