"And King David came and sat before the LORD, and said: Who am I, O LORD God, and what is my house, that You have brought me thus far?" (II Samuel 7:18). Rabbi Chiyya taught: There is no sitting in the courtyard except for the kings of the House of David alone. Rabbi Shimon ben Lakish said: Even for the kings of the House of David there is no sitting in the courtyard. They challenged him: "And King David came and sat before the LORD." Rabbi Aivi bar Negri said: He settled himself with words. There we learned: The first group went out and sat down on the Temple Mount — from which it follows that it sat there [outside]. From here it is said that within they were standing.
May Kings of David's House Sit in the Temple Courtyard
Midrash Shmuel 27:1
ויבא המלך דוד וישב לפני ה' ויאמר מי אנכי ה' אלהים ומי ביתי כי הביאותני עד הלום (שמואל ב' ז' י"ח), תאני רבי חייא אין ישיבה בעזרה אלא למלכי בית דוד בלבד, אמר רבי שמעון בן לקיש אף למלכי בית דוד אין ישיבה בעזרה, מתיבין ליה ויבא המלך דוד וישב לפני ה' (רבי בן נגרי) [רבי אייבי בר נגרי] אמר ישב עצמו בדברים, תמן תנינן יצתה כת הראשונה וישבה לה בהר הבית, מכלל שישבה לה, (מיכאן) נאמר שבפנים היו עומדים.