Search code examples
c#model-view-controllersingle-sign-oniis-7.5

SSO Works on Local Computer IIS but not on IIS


I have been working on a webapp on a locally domain joined computer and when I run the app everthing works fine. It redirects to the Microsoft site, asks for my credentials, and then signs in to the web app without any problems.

When I create folders on our Sharepoint site through the web app it has the create by as being the person that is signed into it via SSO.

I publish the web app to an IIS server that is on the same domain, and instead of authenticate against Microsoft, it authenticates against the domain which still works, but when I create a folder through the web app, it now has the person who created it as Sharepoint App.

Not really sure where to look as everything I have read I have setup as per instructions.

enter image description here

This is what I have in the program.cs

builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
    .EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
        .AddMicrosoftGraph(builder.Configuration.GetSection("MicrosoftGraph"))
        .AddInMemoryTokenCaches();

Just wondering how I force IIS to use SSO instead of authenticating locally?

Regards, Darren


Solution

  • After more investigation I discovered that if I enable anonymous authentication and turn off Windows authentication in IIS for that web site then it forces Azure AD authentication (SSO) instead of authenticating against Active Directory. Seems this is opposite to everything that I have read, but it may be due to the scenarious in the articles I read were not publishing web sites on a domain joined IIS server.

    Anyway, everything is working ok now.