Can you use .NET Active Directory for authentication from a MAUI Windows Desktop app and is there a code sample?

Owsen, Craig 21 Reputation points

There is sample code available for using .NET Active Directory from a Blazor server side app and I have been able to get that to work. But that code does not work for a MAUI Desktop app.

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,176 questions
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,182 questions
0 comments No comments
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 28,876 Reputation points Microsoft Vendor

    Hello @Owsen, Craig ,

    I am working with internal line of business apps with no need for mobile apps.

    .NET MAUI apps can be written for iOS/Android/Windows/Mac and so on. Since you are aiming for Windows-only and .NET MAUI uses Windows UI Library (WinUI) 3 on Windows platform, you can use the same methods to connect to AD as in any other WinUI app, and you should be able to call the same System.DirectoryServices API you called in WPF.

    I am hoping to migrate WPF desktop apps to MAUI Blazor Windows desktop to take advantage of Blazor component libraries for the frontend

    You have access to the same .Net 7 (or 6) that you use in WPF, and you don't need to switch to MAUI for Blazor Hybrid. Blazor Hybrid is available for WPF. See Build a Windows Presentation Foundation (WPF) Blazor app.

    Restricting MAUI desktop to mobile security requirements will stymie any serious migration from WPF apps. Who can we raise these requirements to?

    MAUI desktop isn't restricted to mobile security requirements. Such restrictions come from the underlying platform (Android, iOS, MacCatalyst, or Windows), not from MAUI and directly affect only apps running on those platforms.

    MAUI apps can call Windows specific code through the methods documented at .Net MAUI/Platform Integration/Invoke Platform Code

    Best Regards,
    Wenyan Zhang

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 44,091 Reputation points

    Hello there,

    I found the below Blog. We are pleased to announce official .NET MAUI support in Microsoft.Identity.Client 4.47.0 to easily add authentication into your apps.

    These sample apps can run as they are on iOS, Android, and Windows platforms. When you create your own App, you need to configure it in the Azure portal and replace the values.

    More info here


    --If the reply is helpful, please Upvote and Accept it as an answer--