
545 N.W.2d 296 (1996)
LINN COUNTY SHERIFF, Plaintiff,
v.
IOWA DISTRICT COURT FOR LINN COUNTY, Defendant.
No. 95-933.
Supreme Court of Iowa.
March 20, 1996.
*297 Todd Tripp and Scott C. Peterson, Assistant County Attorneys, for plaintiff.
Duane Rohovit, Public Defender's Office, Cedar Rapids, for defendant.
Considered by McGIVERIN, C.J., and LAVORATO, NEUMAN, SNELL, and TERNUS, JJ.
LAVORATO, Justice.
The Linn County sheriff has petitioned this court for a writ of certiorari challenging the authority of the district court regarding a work release order. At sentencing, the district court in the criminal case ordered the defendant to make arrangements with the Linn County jail to enter the work release program. The sheriff refused the defendant's request because the defendant's employment was outside the county.
The defendant then filed an application in the criminal case for work release privileges. The court heard the application and entered an order. The order authorized and directed the sheriff to (1) enroll the defendant in the work release program, and (2) allow the defendant to travel to, and work at, his place of employment outside the county.
The sheriff challenges this order on three grounds. First, the court had no authority to issue the order in a criminal case to which the sheriff was not a party. Second, the court issued the order without providing the sheriff with notice and an opportunity to be heard. Last, the court lacked the statutory authority to order the sheriffcontrary to his own rulesto provide work release to an inmate employed outside the county. Because we conclude none of these grounds have merit, we annul the writ.

I. Background Facts.

On March 3, 1995, the Linn County District Court entered a judgment of conviction and sentence against Larry Eugene Renfer, Jr., for child endangerment. See Iowa Code § 726.6(3) (1995). The court sentenced Renfer to one year in the county jail, suspending all but ninety days of the sentence. The court then placed Renfer on probation to the Iowa Department of Correctional Services for one year. See Iowa Code § 356.47. The sentencing order also had the following provision: "Mittimus is withheld until the defendant can make arrangements with the Linn County jail to enter into the work release program."
Renfer's attempt to make these arrangements was denied. A sheriff's representative told him he was ineligible for the work release program under the rules governing the administration of the program. The sheriff promulgates these rules, which are embodied in the work release agreement participants sign when they enter the program. The work release agreement restricts inmates participating in the program to employment within "the territorial limits of Linn County." At the time of his conviction, Renfer was employed outside of the county in North Liberty. North Liberty is in Johnson County, about eighteen miles south of the Linn County jail.
*298 Renfer's counsel initially intended to file a motion for a rule to show cause why the court's sentencing order was not being obeyed. See Iowa Code § 665.7 ("Before punishing for contempt, unless the offender is already in the presence of the court, the offender must be served personally with a rule to show cause."). Instead, after talking withand at the request ofthe Linn County attorney, Renfer's counsel filed a motion on March 23 in Renfer's criminal case. The proof of service shows that Renfer served the county attorney with a copy of this motion. The motion seeks an order directing the sheriff to enroll Renfer in the work release program after a hearing on the matter.
On April 12 the court heard and thereafter granted Renfer's motion. The court authorized and directed the sheriff to enroll Renfer in the work release program as it had ordered on March 3. The order also authorized and directed the sheriff to allow Renfer to travel to, and work at, his place of employment in North Liberty.
Although no record of the proceeding was made, the court's order indicates that Renfer, his attorney, and an assistant county attorney appeared, and both counsel presented arguments. Additionally, the sheriff's brief concedes that a sheriff's "employee appeared at the request of the State to provide information regarding the work release rules."
On April 19 an assistant county attorney filed two motions on behalf of the sheriff. The first was a motion to intervene, in which the sheriff claimed that (1) he was a "party interested in the subject matter of this litigation," and (2) his claim was "adverse[] to [that of] the defendant." (Iowa Rule of Civil Procedure 25 allows intervention in civil proceedings when an indispensable party has not been joined. The motion to intervene was apparently premised on the sheriff's contention here that Renfer had to file a separate action to test the sheriff's rules before the district court would have authority to decide the issue.)
The second motion was to annul or rehear. In this motion the sheriff asked the court to annul the April 12 order or have a second hearing on Renfer's application for work release. On April 28, the courtwithout a hearingissued a second order. This order denied the sheriff's motion to annul or rehear in its entirety. The order also (1) ratified the court's March 3 judgment of conviction and sentencing order, (2) ratified its April 12 order granting Renfer work release privileges, and (3) authorized the sheriff to act under Iowa Code section 356.32 to contract with the sheriff of another county for Renfer's employment.
The county attorney filed a petition for a writ of certiorari on behalf of the sheriff. See Iowa R.App.P. 301. We granted the petition and denied the sheriff's motion for a stay.

II. Scope of Review.

A certiorari proceeding is proper when the district court allegedly has exceeded its jurisdiction or has acted illegally. Iowa R.Civ.P. 306; Halverson v. Iowa Dist. Ct., 532 N.W.2d 794, 797 (Iowa 1995). Generally, we review certiorari actions at law. Dressler v. Iowa Dept. of Transp., 542 N.W.2d 563, 564 (Iowa 1996).

III. Jurisdiction of the Case.

A. Applicable law. There are four pertinent statutes regarding work release privileges: Iowa Code sections 903.3, 356.26, 356.27, and 356.32.
Iowa Code section 903.3 states:
The court may direct that a prisoner sentenced to confinement in a county jail... be released from custody during specified hours, as provided by sections 356.26 to 356.35.
Iowa Code section 356.26 provides in pertinent part that

[t]he district court may grant by appropriate order to any person sentenced to a county jail the privilege of a sentence to accommodate the work schedule of the person or the privilege of leaving the jail at necessary and reasonable hours for any of the following purposes:
....

*299 2. Working at the person's employment.

(Emphasis added.)
Under Iowa Code section 356.27,

[u]nless such privilege is expressly granted by the court, the prisoner is sentenced to ordinary confinement. Any prisoner may petition the court for such privilege at the time of sentencing or thereafter, and the court in its discretion may review the petition and make appropriate orders. The court may withdraw the privilege at any time by order entered with or without notice or hearing.
(Emphasis added.)
Finally, Iowa Code section 356.32 provides that

[t]he court may by order authorize the sheriff to whom the prisoner is committed, to contract with a sheriff of another county, for the employment of the prisoner in the other's county, and while so employed to be in the other's custody, but in other respects to be and continue subject to commitment.
(Emphasis added.)
B. The issue. The sheriff first contends the district court lacked subject matter jurisdiction regarding the April 12 work release order. We understand the sheriff's lack of subject matter jurisdiction argument to be this. He concedes that in a civil action the court would have the power under Iowa Code section 356.26 (authorizing district court to grant work release privileges) to review the reasonableness of the sheriff's rules governing work release privileges. He argues, however, that there is no statutory authority for the court to make such a determination in a criminal proceeding. The district court therefore lacked subject matter jurisdiction over the April 12 work release order. So the court did not have authority to order that Renfer be placed on work release in employment outside of Linn County.
C. The merits. Subject matter jurisdiction is "the authority of a court to hear and determine cases of the general class to which the proceedings in question belong." Christie v. Rolscreen Co., 448 N.W.2d 447, 450 (Iowa 1989) (citation omitted). A court acting without legal authority to do so lacks jurisdiction of the subject matter. Wederath v. Brant, 287 N.W.2d 591, 595 (Iowa 1980). Lack of subject matter jurisdiction may be raised at any stage of a proceeding and cannot be conferred by waiver, estoppel, or consent. Milks v. Iowa Oto-Head & Neck Specialists, P.C., 519 N.W.2d 801, 803 (Iowa 1994). Any action taken by a court not having jurisdiction of the subject matter is void. Hutcheson v. Iowa Dist. Ct., 480 N.W.2d 260, 262 (Iowa 1992).
The issue the sheriff raises is technically not one of subject matter jurisdiction. We pointed out in Christie that "[a] court may have subject matter jurisdiction but for one reason or another may not be able to entertain the particular case." Christie, 448 N.W.2d at 450. We have referred to this lack of authority to hear the particular case as lack of jurisdiction of the case. Id.
Christie is a good example of this lack of jurisdiction of the case. There, the statute created a cause of action and established the procedures for enforcing that action. So the district court had subject matter jurisdiction. Because the plaintiff did not follow the statutory procedures to enforce the action, we held the plaintiff did not properly invoke the authority of the court to hear the case. The court therefore had no authority to hear the case orput another waylacked jurisdiction of the case. Id. at 450-51.
Another good example of lack of jurisdiction of the case is found in City of Des Moines v. Des Moines Police Bargaining Unit Association, 360 N.W.2d 729 (Iowa 1985). In that case, the City of Des Moines brought a declaratory judgment action seeking a ruling that a provision in a collective bargaining agreement with the police bargaining association constituted a retirement system and was therefore invalid. We held there was an adequate administrative remedy available that by statute was intended to be exclusive. Because the city did not pursue that remedy before seeking relief in the district court, we concluded the court had no authority to hear the declaratory judgment action. Id. at 731-33.
*300 A final example is Rerat Law Firm v. Iowa District Court, 375 N.W.2d 226 (Iowa 1985). In Rerat, a law firm challenged a district court order requiring the firm to pay fees and a percentage of litigation costs arising out of a lawsuit to which the firm was not a party. The law firm in whose favor the order ran was also not a party to the lawsuit but sought the order in the suit via an application for fees and costs. We noted the district court certainly had subject matter jurisdiction to hear any contractual dispute between the two firms regarding the fees and costs. But we reasoned that the issue was technically not one of subject matter jurisdiction but one of jurisdiction of the case. We concluded the firm seeking the fees and costs had not properly invoked the court's authority to hear the application because both firms were not parties to the underlying lawsuit. We pointed out that the only way to invoke that authority was for the firm seeking the fees and costs to bring a separate action against, and serve an original notice upon, the other firm. Id. at 230-31.
Here, clearly, the district court had subject matter jurisdiction regarding work release privileges because the statutes authorize the district court to grant them. See Iowa Code §§ 903.3, 356.26, 356.27. The statutes also prescribe the procedures regarding granting those privileges. The court has the discretion to grant them as part of the sentence, or later upon the defendant's application. See Iowa Code §§ 356.26, 356.27.
The district court granted Renfer work release privileges as part of his sentence. Later, when the sheriff refused Renfer's request to work outside the county, Renfer filed an application requesting such work release privileges. He did this pursuant to section 356.27 ("[a]ny prisoner may petition the court for [work release privileges] at the time of sentencing or thereafter"). We see nothing in section 356.27 that requires the prisoner to file an application for work release privileges in a separate action. Absent such language, we conclude the prisoner may file the application in the criminal case. Renfer followed the proper statutory procedures by filing his application in his criminal case.
Absent any other alleged fatal jurisdictional defect, the district court had jurisdiction of the case when it entered the original work release order and the subsequent order granting work release privileges outside the county. That brings us to the next issue in the case.

IV. Notice.

The sheriff alleges another jurisdictional defect. He claims the district court lacked jurisdiction of the case because he had no notice of Renfer's application and was not given an opportunity to be heard.
The statutes granting the district court authority to grant work release privileges make no provision for such notice. Nor do we think such notice is required. Once the sheriff has knowledge of a work release order, the sheriff can either carry it out or intervene in the criminal case and argue that the work release privilege is not appropriate.
Although Renfer, rather than the sheriff, brought the sheriff's refusal to carry out the work release order to the court's attention, we think the sheriff had his day in court. The county attorney asked Renfer's counsel to serve him with Renfer's March 23 application that led to the April 12 order. That is precisely what Renfer's counsel did. The county attorney and the sheriff certainly knew that the county attorney is the sheriff's official counsel in any proceeding in which the sheriff is an interested party. See Iowa Code § 331.756(6) (county attorney shall prosecute and defend all actions and proceedings in which a county officer, in the officer's official capacity, is interested or a party). We can reasonably assume that is why the county attorney asked that the motion be served on him rather than on the sheriff. We can also reasonably assume the sheriff acquiesced in such a notice because the parties agree that the sheriff's representative appeared at the hearing on Renfer's motion and gave information about the sheriff's rules.
These facts lead us to conclude that the sheriff had ample opportunity to make his *301 case about why the district court could not, and should not, grant work release privileges outside the county. These facts also reasonably explain why the district court summarily ruled against the sheriff's April 19 motions. The court must have felt that the motions were attempts by the sheriff to rehash matters considered and ruled on at the hearing on Renfer's motion.
V. Statutory Authority to Grant Work Release Privileges Outside County of Confinement.
The sheriff last contends the district court lacked statutory authority to grant work release privileges beyond Linn County in violation of the sheriff's own rules. In support of this contention, the sheriff presents several arguments.
First, he maintains that allowing a defendant to complete the work release program through employment outside the county will dramatically increase the sheriff's administrative burdens regarding (1) supervision of inmates on the job, (2) collection of inmate wages or salaries, (3) furnishing or paying for transportation of inmates to their employment, and (4) investigating alleged inmate violations of work release agreements at the place of employment.
Second, he warns that to allow Renfer out-of-county employment in this case will open the door to absurd results. He cautions that in the wake of an adverse decision, a district court could grant an inmate employed in Council Bluffs work release privileges in Dubuque. The conditions of this work release privilege would be impossible for the sheriffs involved to administer.
Third, he argues the language of section 356.32 clearly implies the legislature intended that courts should generally restrict work release privileges to the county in which an inmate is sentenced and confined. The sheriff further argues that the court's discretion under section 356.32 to grant out-of-county work release privileges is limited to "certain and conditioned circumstances." He fails to state what these circumstances are, but indicates the instant case is not one of them. He also believes that, before a court can grant out-of-county work release privileges, the statute necessarily implies there must first be an "unequivocal agreement" between the respective sheriffs.
Finally, the sheriff analogizes the power of the district court in the instant circumstances to the "limited power" the court possesses in the state correctional scheme. He maintains that
once the individual is sentenced and placed in the custody of corrections officials, ... the authority and jurisdiction of the court terminates except for very limited and special circumstances as provided for by statute. The fact that the court has sentenced an individual does not confer upon the court the authority to review any program into which the individual enters, any facility to which the individual is committed, or any claim or complaint the individual makes known to the sentencing court.
There is nothing in the statutes governing work release privileges that restricts the district court's authority to allow work release privileges outside the county of confinement. The district court's authority in this respect is broad.
Section 356.32 envisions that the district court will grant such privileges. This section allows the district court by order to
authorize the sheriff to whom the prisoner is committed, to contract with a sheriff of another county, for the employment of the prisoner in the other's county, and while so employed to be in the other's custody, but in other respects to be and continue subject to the commitment.
Iowa Code § 356.32.
We, however, do not view this section as the exclusive procedure for allowing out-of-county work release privileges. Rather, we view it as an accommodation to the sheriff if the sheriff deems such an arrangement desirable. For example, here, the sentencing order was broad enough to permit out-of-county work release privileges. Under the order, the sheriff was authorized to allow Renfer to work outside the county without any contractual arrangement with the sheriff of the county in which Renfer was employed. If the sheriff preferred such a contractual arrangement, *302 he could have asked the district court to authorize it.
The district court implicitly recognized this option when it used the following language in its April 28 order:
IT IS FURTHER ORDERED that if the Linn County sheriff deems it necessary, he is authorized to contract with the sheriff of another county for the employment of the defendant in the other's county, all as authorized by section 356.32 of the Iowa Code.
(Emphasis added.)
Our interpretation of section 356.32 does not adversely affect the sheriff's control of, and supervision over, any inmate with out-of-county work release privileges. Iowa Code section 356.26 provides that
[a]ll released prisoners shall remain, while absent from the jail, in the legal custody of the sheriff, and shall be subject, at any time, to being taken into custody and returned to the jail.
We have interpreted this provision to mean that an inmate while on work release remains in the constructive custody of the sheriff. See State v. Eads, 234 N.W.2d 108, 111-12 (Iowa 1975) (when prisoner, while on work release from county jail, left for Colorado without permission there was departure from legal or constructive custody of sheriff constituting crime of escape).
Finally, we think the hazards that the sheriff warns will occur as a result of our decision are slight at best. We doubt that district court judges, in their discretion, will routinely arrange work release for local defendants in remote counties. And, if for some reason a judge may deem such an arrangement is appropriate, section 356.32 provides a mechanism to carry out such an arrangement without affecting the inmate's incarceration during nonworking hours. Section 356.32 evinces legislative recognition of judges' need for flexibility in providing work release privileges in situations in which the county line has no practical meaning.

VI. Disposition.

We conclude the district court did not exceed its jurisdiction nor act contrary to statute when it ordered the Linn County sheriff to allow Renfer work release privileges and to allow him to continue working at his out-of-county employment. In addition, the sheriff had notice and an opportunity to be heard on Renfer's application for out-of-county work release privileges. We therefore annul the writ.
WRIT ANNULLED.
