§ 95. Duties of public officers. It shall be the duty of all officers of the state of New York or of any civil division or city thereof to conform to and comply with and to aid in all proper ways in carrying into effect the provisions of this chapter, and the rules and regulations prescribed thereunder. No officer or officers having the power of appointment or employment shall appoint or select any person for appointment, employment, promotion or reinstatement except in accordance with the provisions of this chapter and the rules and regulations established thereunder. Any person employed or appointed contrary to the provisions of this chapter or of the rules and regulations established thereunder shall be paid by the officer or officers so employing or appointing, or attempting to employ or appoint him, the compensation agreed upon for any services performed under such appointment or employment or, in case no compensation is agreed upon, the actual value of such services and any necessary expenses incurred in connection therewith, and shall have a cause of action against such officer or officers for such sum and for the costs of the action. No public officer shall be reimbursed by the state or any of its civil divisions for any sums so paid or recovered in any such action.