When several persons claim to be entitled to the same office or franchise, they may be all made defendants, so as to determine their respective rights.