The Talmud (Moed Katan 17a) infers from a verse in Malachi (2:7) that a rabbi only has authority inasmuch as his active choices reflect the values and teachings of the Torah:
ההוא צורבא מרבנן דהוו סנו שומעניה. א"ר יהודה: היכי ליעביד - לשמתיה צריכי ליה רבנן, לא לשמתיה קא מיתחיל שמא דשמיא? א"ל לרבב"ח: מידי שמיע לך בהא? א"ל: הכי א"ר יוחנן: מאי דכתיב (מלאכי ב, ז) "כי שפתי כהן ישמרו דעת ותורה יבקשו מפיהו כי מלאך ה' צבאות הוא" - אם דומה הרב למלאך ה' יבקשו תורה מפיו ואם לאו אל יבקשו תורה מפיו
There was one young scholar concerning whom evil rumors were current.
Said R' Yehuda: "What shall be done in this case? Shall we put him
under the ban? The rabbis need him. Shall we not? The name of Heaven
will be profaned." And he asked Rabba bar bar Hana: "Do you know
anything about such a case?" He answered him: So said R' Yohanan: "It
is written (Malachi 2:7): 'The priest's lips are ever to keep
knowledge, and the law are they to seek from his mouth, for he is the
malach (angel) of the Lord of hosts.' That means: If the Master is equal
to an malach, law may be sought from his mouth, but not otherwise."
The Sadducees were a heretical sect and therefore had no standing as halachic authorities and it would be forbidden to treat them as such. See also: https://www.ou.org/jewish_action/06/2015/halachah-and-the-fallen-rabbi-q-a-with-rabbi-hershel-schachter/