0

I recently started playing with windows authentication. Due to some requirement to collect user details under our domain without asking credentials, I started with windows authentication.

Im working in VS2015 and the application is running in IIS Express. For windows authentication I enabled windows authentication is Web.config as below

<authentication mode="Windows">

</authentication>

Then altered the iis express config script to this

<windowsAuthentication enabled="true">
    <providers>
        <add value="Negotiate" />
        <add value="NTLM" />
    </providers>
</windowsAuthentication>

and also this one

<add name="WindowsAuthenticationModule" lockItem="false" />

under modules

Then this one

under section group name authentication

<section name="windowsAuthentication" overrideModeDefault="Allow" />

then I specified it in my source of a web page.

<h3><%= User.Identity.Name %></h3>

But it doesnt returns anything when running from VS. But if I deploy this to Real IIS with windows authentication only enabled it shows the current user name inside the H3

Really havent got an idea what I missed or what I did wrong...

Marcus Höglund
  • 13,944
  • 9
  • 42
  • 63
Sandeep Thomas
  • 2,962
  • 6
  • 41
  • 80
  • 1
    Have you also disabled the anonymous authentication? – Alexander Powolozki Jul 01 '19 at 13:54
  • I disabled Anonymousauthentication under where I enabled windows authentication – Sandeep Thomas Jul 01 '19 at 13:58
  • 1
    Can you check the properties for your project to make sure they're set up for Windows Auth? In solution explorer single click on the asp.net project and then open the properties pane (F4 if not pinned) > check `Anonymous Authentication` = `Disabled`, `Windows Authentication` = `Enabled` – dvo Jul 01 '19 at 14:09
  • Thats perfect.. I was setup Windows Authentication in common config file under documents. Here for projects it still shows as disabled... I changed it and its working fine – Sandeep Thomas Jul 01 '19 at 14:12
  • "Then altered the iis express config script to this", which file exactly did you alter? You can easily change the wrong file. – Lex Li Jul 01 '19 at 18:00
  • @LexLi there is a common iis config file under documents/iisexpress which I modified. Not the solution config – Sandeep Thomas Jul 02 '19 at 05:12
  • https://docs.jexusmanager.com/getting-started/features.html#add-iis-express-from-visual-studio-2015-2017-solution-file If you never knew which file used by VS2015, you ignored something important. – Lex Li Jul 02 '19 at 05:30

0 Answers0