Opinion by
President Judge Crumlish, Jr.,The petitioner, Delancey Davis, and the Pennsylvania Public School Employees’ Retirement System (System), the Pennsylvania Public School Employees’ Retirement Board (Board), and Pittsburgh National Bank (PNB) (collectively, respondents), have filed cross motions for summary judgment in this Court’s original jurisdiction.
Davis seeks a declaration that his legal 'services contract with PNB, the Board and System was improperly terminated. Respondents, in their cross motion for summary judgment, ask this Court to declare that that contract violated the Commonwealth Attorneys Act (Act)1 and the Code of Professional Responsibility.2 Respon*455dents also seek restitution in the amount that Davis was compensated under his contract.
In 1982, Davis was appointed Deputy Attorney General. His duties included, inter alia, the review and approval of the Systems real estate contracts and investments. In this capacity, Davis approved an agreement establishing PNB as trustee for those investments.
In 1986, Davis chose to leave the Attorney Generals office and notified the Executive Director of the System, James A. Perry, that he intended to work for a Philadelphia bank. At that time, Perry advised Davis that if he could “figure out a way to do it,”3 he could join the System as counsel in order to conduct the trusts real estate transactions. Following negotiations with the Board and PNB, Davis executed an agreement which PNB signed at Perrys direction.4 Davis performed his duties under the contract and was provided with an office, telephone, and secretarial support by the System.5
In March of 1987, the Governors Office of General Counsel advised the Board that Davis’ agreement was illegal and void. The Board then voted to direct PNB to terminate the agreement. Davis filed the instant petition for review; this Court denied the respondents’ preliminary objections by Order dated June 3, 1987.
In support of his summary judgment motion, Davis contends that under the contract, PNB could have terminated him only for just cause.6 The gravamen of his *456complaint is that the contract was legal and enforceable; therefore, it was improperly terminated because just cause was not established.
Respondents contend that the contract was illegal, because Davis “devised a scheme” to serve as counsel for the System without appointment by the Office of General Counsel. They argue that this arrangement violated the Act. Additionally, respondents allege that Davis violated the Code of Professional Responsibility by accepting employment in the private sector in a matter over which he had considerable responsibility as a public employee.
Summary judgment is appropriate when no genuine issue of material fact remains, and the movant is entitled to judgment as a matter of law. Allen v. Colautti, 53 Pa. Commonwealth Ct. 392, 417 A.2d 1303 (1980); Pa. R.C.P. No. 1035.
Initially, we must determine whether Davis’ agreement violated the Act. That act established the Office of Attorney General and Office of General Counsel and authorized the allocation of legal resources for Commonwealth agencies.
Pursuant to Section 301 of the Act, the Office of General Counsel has the authority to appoint legal staffing as it deems necessary for the operation of each executive agency.7 Independent agencies, on the other hand, may appoint their own counsel or request legal services from the Office of General Counsel.8
*457Davis argues that as an independent agency, the System had the right to retain him as counsel for its trust agreement with PNB. Respondents counter that the System is an executive agency, which must obtain legal counsel only from the Office of General Counsel.
The Retirement Code established the System as the Boards functional arm responsible for allocating and distributing participants’ retirement benefits.9 The Attorney General was initially designated as the legal ad-visor to the Board;10 however, Section 502 of the Act,11 transferred those powers and duties under the Retirement Code to the Office of General Counsel.
The legislature, in enacting those sections, statutorily transferred exclusive legal advisory powers to the Office of General Counsel. Section 502 of the Act and Section 8501(e) of the Retirement Code, when read in pari materia, demonstrate the legislature’s intent to vest exclusive legal advisory powers to the Office of General Counsel.
Davis, however, argues that he was employed exclusively by PNB, therefore, he contends that the Act does not apply to his private contract with PNB.
The pleadings, depositions, and interrogatory answers disclose, however, that PNB was unaware of substantial portions of the contract, including compensation and job responsibilities.12 When PNB reviewed the contract, its trust officer, Frank Morris thought that “it was rather rare and unique that a trust fund would engage the services of counsel on an ongoing basis.”13
*458Morris also objected to the contractual language that PNB had determined the need to hire Davis and changed the contract to read “the trustee, in its own right, has not made a determination as to the need of counsels services.”14 Moreover, Morris testified as to his conception of the arrangement between the Board, PNB and Davis: “The way I viewed the whole thing is Mr. Davis is working for the Board. Hes not working for me.”15
Additionally, Perry testified that Davis’ function under the legal services agreement “was to coordinate and monitor the implementation of real estate investment decisions initially, and then to either personally handle or monitor the handling of subsequent legal issues that come up with real estate we owned.”16 This testimony indicates that he also considered that Davis was working for the System. Finally, Davis averred in his petition that PNB terminated his contract at the direction of the Board.17
Thus, the undisputed facts portray Davis as primarily responsible to the Board and System under the legal services agreement. Because the Office of General Counsel had the exclusive power to engage the services of attorneys for the Board, Davis was working under a contract that violated the Act. A contract that' violates public policy as declared by the legislature is unenforceable and void ab initio. F.F. Bollinger Co. v. Widmann Brewing Corp., 339 Pa. 289, 14 A.2d 81 (1940); Watrel v. Department of Education, 88 Pa. Commonwealth Ct. 1, 488 A.2d 378 (1985), aff'd, 513 Pa. 61, 518 A.2d 1158 (1986). Because the contract is *459unenforceable, Davis’ motion for summary judgment is denied; respondents’ cross motion for summary judgment in declaratory relief is granted.
Next, we must consider respondents’ motion for summary judgment on their counterclaim for restitution of Davis’ fee, which was paid out of the trust. Respondents claim that they are entitled to restitution because Davis’ fee arrangement violated both the Act and his ethical obligations under the Code of Professional Responsibility.18
Initially, we note that violations of the Code are not the proper subject for consideration of either the common pleas or intermediate appellate courts of the Commonwealth. Reilly v. SEPTA, 507 Pa. 204, 219-20, 489 A.2d 1291, 1299 (1985).19
However, the recipient of a benefit may be required to make restitution if the circumstances of its receipt are such that, as between the two parties, it would be unjust for the recipient to retain the benefit. Allesandro v. Borough of Braddock, 37 Pa. Commonwealth Ct. 513, 391 A.2d 38 (1978). Moreover, an attorney is not entitled to keep a fee obtained in violation of his professional obligation. Feld and Sons, Inc. v. Pechner, Dorf*460man, Wolfee, Rounick, and Cabot, 312 Pa. Superior Ct. 125, 458 A.2d 545 (1983).20
Generally, fees or other compensation paid illegally or. by mistake to those entrusted with public funds may be recovered. Loushay Appeal, 169 Pa. Superior Ct. 543, 83 A.2d 408 (1951), aff'd, 370 Pa. 453, 88 A.2d 793 (1952). This rule has been in practice as early as 1897 when, in County of Allegheny v. Grier, 179 Pa. 639, 36 A. 353 (1897), our Supreme Court upheld an order of restitution imposed upon a county official.
In Grier, a statutory change limiting certain officials’ salaries rendered the Allegheny County Controller’s compensation illegal. He was ordered to return the sum over and above the statutory limit. In upholding the recoupment, Chief Justice Sterrett noted that, “[p]ublic office is a public trust; the sanctity of public property is essential to its due administration; and necessarily implies a remedy for every diversion from legitimate use.” 179 Pa. at 642, 36 A. at 354. The Court further noted that the change in law “should have put him on. his guard. As the fiscal officer of the county he was bound to take notice that the construction of the act . . . was open to question, and that without the aid of the courts he must act at his peril.” Id.
In this instance, Davis, a former deputy attorney general, knew or should have known that the Act restricted the Board’s ability to hire outside attorneys. Davis, nonetheless, established contacts within the Board that netted him a legal advisory position with the Board and System.
*461Because we have concluded that such a contract was in contravention of the Act and void, Davis was in essence a volunteer.
This Court cannot legitimize the practice of a former public employee attempting to work under a contract that he should have known was illegal. An order of restitution is consistent with the policy of restoring funds illegally or mistakenly paid out of a public fund. Grier; Loushay. Moreover, such an order returns the parties to the status quo prior to the execution of the illegal contract. Feld and Sons.
Accordingly, we grant respondents’ motion for summary judgment on their counterclaim for restitution.
Order
Petitioner’s motion for summary judgment is denied. The cross motions for summary judgment of the Pennsylvania Public School Employees’ Retirement Board and System, and Pittsburgh National Bank on petitioner’s petition for declaratory judgment are granted. The cross motions of the Pennsylvania Public School Employees’ Retirement Board and System and Pittsburgh National Bank for summary judgment on the counterclaim for restitution are granted.
Judge MacPhail did not participate in the decision in this case.Act of October 15, 1980, P.L. 950, as amended, 71 P.S. §§732-101 — 732-506.
By Order, the Supreme Court of Pennsylvania adopted the Code of Professional Responsibility February 27, 1974, effective *455February 27, 1974. The Code of Professional Responsibility was superseded by the Rules of Professional Conduct, adopted .October 16, 1987, effective April 1, 1988, 204 Pa. Code Chapter 81.
Deposition of James A. Perry, 7/21/87, p. 26.
Deposition of Frank Morris, Trust Officer at PNB, 7/21/87, pp. 48, 51.
Deposition of Perry, pp. 43-44; deposition of Morris, p. 133.
Just cause is defined in Davis’ employment contract as “including, but not limited to Davis’ willful breach of duty or habitual neglect of the duty undertaken by him” under the agreement.
71 P.S. §732-301. Section 102 of the Act defines an “executive agency” as “[t]he Governor and the departments, boards, commissions, authorities and other officers and agencies of the Commonwealth government, but the term does not include . . . any independent agency.” 71 P.S. §732-102.
71 P.S. §732-401. Section 102 specifically enumerates eighteen “independent agencies.” Although the Public School Employees’ Retirement Code (Retirement Code), 24 Pa. C. S. §§8101— *4578534, established the Systems Board as an “independent administrative board,” 24 Pa. C. S. §8501(a), the Board and System are not identified in the section as independent agencies.
24 Pa. C. S. §8102.
24 Pa. C. S. §8501(e).
71 P.S. §732-502.
Deposition of Morris, pp. 34-35.
Deposition of Morris, pp. 34-35.
Id. at pp. 42-43.
Id. at p. 61.
Deposition of Perry, p. 40.
Complaint of Davis, p. 4.
Respondents contend that Davis’ performance under the legal services agreement violated Disciplinary Rule 9-101(B), Code of Professional Responsibility DR 9-101(B) (1974). In addition, respondents allege that Davis maintained communications with members of the Board and System after the present litigation commenced, in violation of DR 7-104(A)(l).
Under the Rules of Disciplinary Enforcement, Rule 201 provides: “Jurisdiction, (a) The exclusive disciplinary jurisdiction of the Supreme Court and the Board under these rules extends to: (a) Any attorney admitted to practice law in this Commonwealth.” 204 Pa. Code, Chapter 83. Rule 208 of those Rules provides: “Procedure. (a) Informal proceedings. (1) All investigations, whether upon complaint or otherwise, shall be initiated and conducted by Disciplinary Counsel.” (Emphasis in original.)
In Feld and Sons, the Superior Court reversed a lower courts dismissal of a contract claim by several clients to recover legal fees they paid to their attorneys. The court held that, if clients can prove that a lawyer has by immoral or illegal conduct, retained a fee, that fee may be recovered. Id. at 142-143, 458 A.2d at 554.