If it appears to the court by the certificate of the register of deeds or clerk of courts, or by the verified statement of any person who may have examined or searched the records, that there are outstanding liens or encumbrances of record upon such real property, or any part or portion thereof, which existed and were of record at the time of the commencement of the action, and the persons holding such liens are not made parties to the action, the court must either order such persons to be made parties to the action, by an amendment or supplemental complaint, or appoint a referee to ascertain whether or not such liens or encumbrances have been paid or, if not paid, what amount remains due thereon, and their order among the liens or encumbrances severally held by such persons and the parties to the action, and whether the amount remaining due thereon has been secured in any manner, and if secured, the nature and extent of the security.
SDCL 21-45-8