Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
87 views
in Technique[技术] by (71.8m points)

c# - Windows authentication in asp.net 5

I am building an intranet application in ASP .NET 5, MVC 6. I want to know how to enable Windows Authentication.? The default project template supports only Individual User Accounts.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Mark's answer is still valid in ASP.Net RC1. There are some additional steps to tie it all together (I don't have enough reputation to comment on his solution):

  1. Install WebListener from NuGet
  2. Add the following usings to Startcup.cs:

    using Microsoft.AspNet.Http.Features;
    using Microsoft.Net.Http.Server;
    
  3. Add Mark's code snippet in the Configure method before app.UseMvc:

    // If we're self-hosting, enable integrated authentication (if we're using
    // IIS, this will be done at the IIS configuration level).
    var listener = app.ServerFeatures.Get<WebListener>();
    if (listener != null)
    {
        listener.AuthenticationManager.AuthenticationSchemes = 
        AuthenticationSchemes.NTLM;
    }
    
  4. To debug this, you need to add the WebListener run target in project.json, as Mark noted in a different answer:

    "commands": {
      "weblistener": "Microsoft.AspNet.Server.WebListener --config hosting.ini",
      "web": "Microsoft.AspNet.Server.Kestrel"
    },
    
  5. Pick weblistener instead of IIS Express of web (Kestrel) to debug your application.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...