"Adding sign-in with Microsoft" example does not work on my working VDI

Aleksandr Romanov 0 Reputation points
2023-02-21T08:33:06.04+00:00

Good day everyone!

Background: I have old legacy ASP.NET MVC on premise application running on local windows IIS. I'm investigating ways to integrate this application with Azure AD authentication. As far as I can understand (Windows IIS integration with Azure AD) it's not possible to do it directly because of the Azure AD authentication can be added at the application level only. So I'm thinking integrating one of the MSAL library for adding Azure AD authentication.

Using this windows manual (Quickstart: Add sign-in with Microsoft to a web app), I've downloaded sample windows application (ASP.NET code sample) from this learn page and tried to run it within the Visual Studio 2022 in debug mode on my azure virtual work machine (based on VDI platform).

And Azure AD authentication does not work. When I click "Sign in with windows" button on the start application page, I get the error:

MicrosoftTeams-image (4)

This sample works fine on my local laptop in exactly the same state. I suggest that any security utilities might be the reason, but I don't know how to check it. I can't disable security apps on my working machine, and maybe there are any restrictions on the network level I don't even know nothing about.

Could somebody suggest any ways to solve this problem? Or maybe still ways to find the reason of this problem?

Thank you in advanced!

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Developer technologies | ASP.NET | Other
Developer technologies | C#
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Alan Farias 755 Reputation points
    2023-02-28T17:15:37.12+00:00

    It's possible that the issue is related to the configuration of your IIS server on the virtual machine. Here are a few things you can check:

    1. Make sure that the virtual machine has access to the internet and can connect to Azure Active Directory. You can try accessing the Azure AD sign-in page directly from the virtual machine's browser to confirm this.
    2. Check that the virtual directory for the sample application is configured correctly in IIS. Make sure that the application is configured to use the correct version of the .NET Framework, and that the virtual directory is mapped to the correct physical directory where the sample application is stored.
    3. Verify that the web.config file for the sample application is correctly configured with the necessary Azure AD settings. Double-check that the values for the client ID, tenant ID, and redirect URI are correct.
    4. Check the IIS logs for any errors or warnings related to the sample application. This could provide clues as to what might be causing the issue.
    5. Make sure that any firewalls or security settings on the virtual machine or on the network allow traffic to and from the Azure AD endpoints. You may need to work with your IT department to check and configure these settings.

    I hope these suggestions help you troubleshoot the issue with the Azure AD authentication not working on your virtual machine.


    Please, if this answer is helpful, click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please let me know.


  2. Aleksandr Romanov 0 Reputation points
    2023-03-02T07:53:25.07+00:00

    The issue was solved by adding

    <authentication mode="None" />
    

    to <system.web> section in web.config file.

    The solution was found here

    0 comments No comments

  3. Shweta Mathur 30,296 Reputation points Microsoft Employee Moderator
    2023-03-02T08:04:34.84+00:00

    Hi @Aleksandr Romanov ,

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution in case you'd like to "Accept" the answer.

    User's image

    Thanks,

    Shweta

    0 comments No comments

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.