Proceeding pursuant to CPLR article 78 (initiated in this Court pursuant to CPLR 506 [b] [1]) to compel respondent to accept petitioner’s plea of guilty to the crime of attempted criminal possession of marihuana in the second degree.
After the People obtained an indictment charging petitioner with criminal possession of marihuana in the first degree and unlicensed growing of cannabis, they made an offer for petitioner to plead guilty to attempted criminal possession of marihuana in the second degree in exchange for her cooperation against a codefendant, a sentence of two years imprisonment and one year of postrelease supervision, plus forfeiture of cash *991found at the time of arrest. The sentence attached to this offer was illegal; attempted criminal possession of marihuana in the second degree is a class E felony subject to a determinate prison sentence of 1 to IV2 years (see Penal Law § 110.05 [6]; §§ 221.25, 70.70 [2] [a] [iv]). Petitioner appeared in County Court, where respondent was the presiding judge, and indicated that she was inclined to accept the plea offer, but the proposed sentence exceeded the legal maximum. The matter was adjourned at defense counsel’s request. Upon returning to court, defense counsel stated that petitioner was prepared to enter the plea, but asked respondent to adjust the sentence to comport with the legal maximum for the crime contained in the plea offer. The People never offered a plea with a lower sentence. Respondent refused to accept such a plea.
Petitioner commenced this CPLR article 78 proceeding seeking to compel respondent, in his capacity as County Judge, to accept her plea of guilty to attempted criminal possession of marihuana in the second degree in accordance with the plea offer, but with a reduced, legal sentence. Initially, the petition should be dismissed based upon petitioner’s failure to designate the District Attorney as a party to this proceeding (see CPLR 7804 [i]; Matter of Thomas v Justices of Supreme Ct. of State of N.Y., Queens County, 304 AD2d 585, 585-586 [2003]).
The petition should also be dismissed on the merits. Mandamus is an extraordinary remedy which lies only to compel performance of acts which are mandatory, not those that are discretionary (see Klostermann v Cuomo, 61 NY2d 525, 539 [1984]; Matter of Schroedel v LaBuda, 264 AD2d 136, 138 [2000], lv denied 95 NY2d 754 [2000], cert denied 531 US 860 [2000]). Courts are mandated to entertain pleas, but each court retains discretion regarding the acceptance of any particular plea offer (see Matter of Schroedel v LaBuda, 264 AD2d at 138). While a defendant may plead guilty to an entire indictment as a matter of right (see CPL 220.10 [2]), a defendant may only enter a plea of guilty to a lesser included offense with both the People’s consent and the court’s permission (see CPL 220.10 [3], [4]).
Even if petitioner agreed to plead to the lesser crime consistent with the terms of the plea offer, respondent retained the discretion to accept or reject that plea, or attach reasonable conditions to the plea before accepting it (see People v Shervington, 25 AD3d 628, 629 [2006], lv denied 6 NY3d 818 [2006]; see also People v Smith, 272 AD2d 679, 682 [2000], lv denied 95 NY2d 938 [2000]). Petitioner did not plead in accordance with the plea offer, but attempted to add conditions of her own as *992part of her plea. Despite respondent’s prior indication of his approval of the plea offer, he certainly was not mandated to accept a guilty plea containing an illegal sentence—once he became aware of that circumstance—nor accept a plea on terms other than those offered (compare People v Sherwood, 28 AD3d 259, 260 [2006], lv denied 7 NY3d 763 [2006]). As respondent had discretion to reject petitioner’s plea, the remedy of mandamus is not available to petitioner.
Mercure, J.P., Spain, Carpinello and Mugglin, JJ., concur. Adjudged that the petition is dismissed, without costs.