When the action is brought and the claim is made that another person is rightfully entitled to the office, judgment may be given upon the right of the defendant and also upon the right of the person so claimed to be entitled, or only upon the right of the defendant as justice may require.
AS 09.50.330