Would it be simpler to just use KRB5_PRINCIPAL_PARSE_NO_REALM when parsing the name?