2

I have a standard web form app which is authenticated using IIS's Windows Authentication setting.

As I now need to expose some the data via Web API, I have added an APIController which I can successfully retrieve the required data, however, I need to restrict what is returned based on the identity of the requestor.

The problem is that the this.User.Identity is coming back empty..

[System.Security.Principal.WindowsIdentity]: {System.Security.Principal.WindowsIdentity}
AuthenticationType: ""
IsAuthenticated: false
Name: ""

I am new to Web API so not sure what I have done wrong / forgotten to do...

FYI - The authentication on the web form app is working perfectly...

Chris Hammond
  • 2,064
  • 5
  • 27
  • 53

1 Answers1

2

Having "anonymous authentication" enabled..along side of "windows authentication" will create this "empty windowsIdentity" problem.

Longer discussion (and my problem and answer) here:

HttpClient calling a Windows-Authenication ApiController Method...but no WindowsIdentity coming along for the ride

Also see:

How to get Windows user name when identity impersonate="true" in asp.net?

Community
  • 1
  • 1
granadaCoder
  • 26,328
  • 10
  • 113
  • 146