Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Exception in IIS when using windows authentication #650

Closed
LiveLikeLastDay opened this issue Jan 3, 2017 · 14 comments
Closed

Exception in IIS when using windows authentication #650

LiveLikeLastDay opened this issue Jan 3, 2017 · 14 comments
Assignees
Labels
Milestone

Comments

@LiveLikeLastDay
Copy link

LiveLikeLastDay commented Jan 3, 2017

Hi,

IdentityServer4 released verion 1.0.

Can someone reopen #38 support for windows authnetication?

Thanks.

@rposener
Copy link

rposener commented Jan 3, 2017

+1 for that

It works great running behind IIS Express, but as soon as I try to publish to IIS, everything breaks. Just ends up with a 500 error on /Account/ExternalLogin?provider=Negotiate URL.

@rposener
Copy link

rposener commented Jan 4, 2017

Looks like you need to configure WebListener. This means not using Kestrel and not using IIS. WebListener is it's own web server. Here are some critical details that seem to be working for me: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/weblistener .

@leastprivilege
Copy link
Member

both WebListener and Kestrel + IIS Integration works.

@rposener
Copy link

rposener commented Jan 6, 2017

Any chance some direction on getting this working with Kestrel + IIS Integration would be helpful. As noted, it seems to work fine under IIS Express, but will not work when deployed to IIS. Even just a pointer to some MS article or source that might be useful would be helpful.

When run under Kestrel + IIS Express and it does work it still presents a 500 Error Page momentarily then seems to refresh and the credential is set. Quite odd behavior - I've never seen a 500 error refresh itself.

@brockallen
Copy link
Member

Any chance some direction on getting this working with Kestrel + IIS Integration would be helpful.

IIRC our samples/quickstarts were even updated to show how to do this. Do those not work for you?

@rposener
Copy link

rposener commented Jan 6, 2017

For what it's worth, here is what I have done that works:

public static void Main(string[] args)
        {
            IWebHost host;
            if (args.Length == 0)
            {
                host = new WebHostBuilder()
                    .UseKestrel()
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseIISIntegration()
                    .UseStartup<Startup>()
                    .Build();
            }
            else
            {
                host = new WebHostBuilder()
                    .UseWebListener(options =>
                    {
                        options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM;
                        options.ListenerSettings.Authentication.AllowAnonymous = true;
                    })
                    .UseUrls(args)
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseIISIntegration()
                    .UseStartup<Startup>()
                    .Build();
            }
            host.Run();
        }

Then you can either run with Kestrel behind IIS (as normal), or you can just "dotnet run http://localhost:8080" and it will run and start listening there directly using the WebListener server.

Your IIRC samples all work prefect on IISExpress, but do not work on production IIS. As for what I've been following is the Host project in the IdentityServer4 source. It seems to be the only one with everything. When I publish it to my local IIS, I get this error.
image

@brockallen
Copy link
Member

huh, ok. we'll double check it tomorrow.

@rposener
Copy link

rposener commented Jan 6, 2017

Didn't mention it in my last post, just for clarity the unmodified Hosts project running this in VS under IIS Express works perfectly when I click the Windows button. Here is my IIS setup:
image
image

and I'm just doing a dotnet publish from command line to get it to the directory. Thanks for the help.

@brockallen
Copy link
Member

I was able to repro. It's a app identity permissions issue as far as I can tell. I opened an issue here: aspnet/KestrelHttpServer#1288. If I can find a workaround here in IdentityServer, but fundamentally that call should work in ASP.NET Core.

@brockallen
Copy link
Member

Looks like this was already reported: aspnet/IISIntegration#231

@brockallen
Copy link
Member

As for a workaround, we could use "Windows" as the provider name -- this is really just used to lookup the user's IdP in the identity management system, and it prolly doesn't care if NTLM or Negotiate is used. Really it just cares that the user is a windows user.

@brockallen
Copy link
Member

done on dev

@brockallen brockallen added bug and removed bug report labels Jan 6, 2017
@rposener
Copy link

rposener commented Jan 6, 2017

Excellent! Thanks for getting to the bottom of it quickly.

@brockallen brockallen changed the title Reopen #38 Support for windows authnetication Exception in IIS when using windows authnetication Jan 6, 2017
@brockallen brockallen changed the title Exception in IIS when using windows authnetication Exception in IIS when using windows authentication Jan 6, 2017
@lock
Copy link

lock bot commented Jan 15, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants