A district may commence, maintain, intervene in, and compromise, in the name of the district, and assume the costs of, any action or proceeding involving or affecting the ownership or use of water or water rights within the district, used or useful for any purposes of the district, or of common benefit to the lands situated therein.