Did you receive any errors? It works fine for me. Below is a working example.
By the way, the Graph API doesn't support on-premises AD, it's only available in Azure AD.
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.