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
2022-11-28T17:05:20.28+00:00

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.

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

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 34,556 Reputation points Microsoft Vendor
    2022-11-29T09:29:05.717+00:00

    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,566 Reputation points
    2022-11-30T12:45:14.437+00:00

    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 https://devblogs.microsoft.com/dotnet/authentication-in-dotnet-maui-apps-msal/

    ---------------------------------------------------------------------------------------------------------------------------------------------

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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.