Asp.net Core Web API - Current user & Windows Authentication

后端 未结 3 1169
终归单人心
终归单人心 2020-12-16 02:40

We have following technical stack in our application AngularJS2 Asp.Net Core API SQL Server

Now we need to store User Name for the Logged in User in table during Cre

3条回答
  •  轮回少年
    2020-12-16 03:39

    I looked around and it was suggested to create Asp.Net Core WebApi application using Windows Authentication.

    So when i created Asp.Net Core WebApi using Windows Authentication it worked and i got values in User.Identity objects.

    So i created 2 applications i.e. one with Windows Authentication and one without, and then compared all files and found changes in following files

    • forwardWindowsAuthToken - true, this was tried before but issue was not solved and same was suggested by Daboul
    • launchSettings.json, Set windowsAuthentication: true & anonymousAuthentication: false

    After doing this, I was able to values in User.Identity object.


    The launchSettings.json file:

    {
      "iisSettings": {
        "windowsAuthentication": true,
        "anonymousAuthentication": false
        }
    }
    

    The Web.Config:

    
    
      
        
          
        
        
            
                
                    
                    
                
            
      
    
    

提交回复
热议问题