Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6939295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:36:16+00:00 2026-05-27T12:36:16+00:00

I am working on an ASP.Net MVC 3 application and I am having a

  • 0

I am working on an ASP.Net MVC 3 application and I am having a User table that stores usernames and their passwords. I have created an additional ADUsername (stores Active Directory’s Domain/Username).

I am trying to do the following:

  1. Users running the application from Intranet should not see login page. Their Domain/Username should be received automatically and compared against ADUsername field.

  2. Users running the application from internet (out of the local network) or users with no ADUsername value: should see the login screen and they should use my custom Username and Password fields to login.

This was very easy using Visual Studio Development Server and very difficult using IIS 🙂

As I set my Web.Config to use forms, I am using WindowsIdentity.GetCurrent().Name to get the current ADUsername and then, I lookup my User table to find the user and FormsAuthentication.SetAuthCookie him.

Using IIS is always returning APPPOOL\ASP.NET v4.0 user which is not reflecting the domain/user I needed.

Any Help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:36:16+00:00Added an answer on May 27, 2026 at 12:36 pm

    This is not an easy task to accomplish. The Windows identity of your intranet user will only be available to you when Windows Authentication in IIS is enabled, an anonymous authentication disabled. When the user’s browser hits the server, IIS will perform the NTLM challenge/response process to validate the user. Note that this challenge/response actually occurs on every individual HTTP request, not just once.

    The problem with this mechanism is that your Forms authentication will no longer be used, as it kicks in after Windows authentication runs, and failing to authenticate just triggers an IIS access-denied – not fallback to Forms authentication.

    To build a hybrid, you will need to:

    1. Set up your main web application to authenticate users with Forms authentication. Set web.config like this. Generate your own machine key – this is key to ensure cookie sharing works

      <authentication mode="Forms"><forms loginUrl="~/Account/LogOn" timeout="2880" path="/" enableCrossAppRedirects="true" name=".ASPXFORMSAUTH" protection="All"  />
      </authentication>
      <machineKey validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F" validation="SHA1" /> <system.webServer>
      <security>
        <authentication>
          <anonymousAuthentication enabled="true"/>
          <windowsAuthentication enabled="false"/>
        </authentication>
      </security></system.webServer>
      
    2. Create a new, separate web app to use purely for the NTLM authentication. It will authorize then redirect to the main application. Sorry, the two apps can’t be combined.

    3. In NTLM web app, change web.config Authentication mode like below:

        <authentication mode="Windows">       
        </authentication>   
        <machineKey validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
                    decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F" validation="SHA1" />
    <system.webServer>
        ....
        <security>
          <authentication>
            <windowsAuthentication enabled="true"/>
            <anonymousAuthentication enabled="false"/>
          </authentication>
          <ipSecurity>
            <!-- put whatever here to restrict to your LAN
            <add ..../>
            -->
          </ipSecurity>
        </security>
      </system.webServer>
    
    1. In NTLM webapp, the controller does one thing – extract username from (WindowsPrincipal)Thread.CurrentPrincipal(); and calls FormsAuthentication.SetAuthCookie(..). Then redirect to the main web app. Do not use WindowsIdentity.GetCurrent() as it will not be accurate without impersonation enabled [see msdn.microsoft.com/en-us/library/ff647076.aspx] which you don’t want to be using

    2. You cannot test any of this under Cassini or IIS Express; you must use IIS 7.5.

    3. Goto IIS 7.5 and turn on Feature Delegation for “Authentication – Anonymous” and “Authentication – Windows”.

    4. Create IIS application for your Forms based app

    5. Right click on your newly created Forms app and ‘Add Application’. Set path to your NTLM authentication application, and the name to something like “IntranetAuthentication”

    6. In browser access http://localhost/YourSite for forms authentication, and http://localhost/YourSite/IntranetAuthentication to see NTLM auth then passthru auth working back to main site

    At your company, direct intranet users to use the intranet logon. Externally everyone uses regular forms authentication page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with an ASP.NET MVC application. I have one master page having
I am working on asp.net MVC 3 application. I have created a Razor view
I'm working on an asp.net MVC application. I have a class that wraps a
I am working on an ASP.NET MVC application that contains a header and menu
I am working on an asp.net MVC 3 application. I have a C# function
I have an ASP.NET MVC 2 form that is working perfectly, doing client side
I'm working on an ASP.NET MVC 3 application and having some issues. I've got
I'm working on an ASP.NET MVC application. I'm having a problem where my Application_Error()
I am working on a ASP.NET MVC application where we have to write our
I am working with an ASP.NET MVC application. There is a requirement that a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.