Search code examples
windowsnetwork-programminglocalhostshareunc

Authentication issues using simulated host via UNC


After modifying my "hosts" file I have appended the location for "testunc" to "127.0.0.1". When I type in the path "\testunc\share" into "Run" (I have a shared folder on my C:\ drive called "share") I receive an authentication prompt. I am asked for the credentials to the "Guest" account on my local machine. Though the "Guest" account does not have a password, it always fails.

I am coding an application locally for use on a standalone network. I need to simulate the UNC path locally so that I can see if the application will work on the actual network.

\127.0.0.1\share works great, \localhost\share yields the following alert: "You were not connected because a duplicate name exists on the network."

Edit & Answer

Since I only have 9 rep at the moment I can't self answer for 6 more hours. I will self answer later on. Answer is as follows:

Ok, figured it out. I don't advise doing this if there are security concerns on the local PC that you will be using. I.E. undo this once you've done what you need.

Do all this after modifying your C:\windows\system32\drivers\etc\hosts file with the new hostname and IP.

Required Steps Overiew

  1. Install Loopback adapter from Microsoft (might not matter)
  2. Modify registry to disable loopback authentication
  3. Modify registry to disable strict name checking.

Step Breakdown

First install the loopback adapter following these instructions (this is on Windows XP mind you). Go into the properties for this adapter and change its static IP address and gateway if you like. It will work the same way as Localhost but use a different IP.

Follow the instructions in the technet post referenced in my comments above (enumerated below):

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  3. Right-click Lsa, point to New, and then click DWORD Value. Next open your registry (windows + r, 'regedit' in the run prompt).
  4. Type DisableLoopbackCheck, and then press ENTER.
  5. Right-click DisableLoopbackCheck, and then click Modify.
  6. In the Value data box, type 1, and then click OK.
  7. Exit Registry Editor.
  8. Restart the computer.

After reboot you must now disable strict name checking following the instructions from this article (enumerated below):

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and click the following key in the registry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameters
  3. On the Edit menu, click Add Value, and then add the following registry DWORD value: DisableStrictNameChecking
  4. Right-click DisableStrictNameChecking, and then click Modify.
  5. In the Value data box, type 1, and then click OK.
  6. Exit Registry Editor.
  7. Restart the computer.

After the last restart you will be able to path to a "simulated" unc location on your localhost computer. This should help in testing network deployed applications / scripts on a standalone system.


Solution

  • Self answering this one. Answer is also included in original question text.

    I don't advise doing this if there are security concerns on the local PC that you will be using. I.E. undo this once you've done what you need.

    Do all this after modifying your C:\windows\system32\drivers\etc\hosts file with the new hostname and IP.

    Required Steps Overiew

    1. Install Loopback adapter from Microsoft (might not matter)
    2. Modify registry to disable loopback authentication
    3. Modify registry to disable strict name checking.

    Step Breakdown

    First install the loopback adapter following these instructions (this is on Windows XP mind you). Go into the properties for this adapter and change its static IP address and gateway if you like. It will work the same way as Localhost but use a different IP.

    Follow the instructions in the technet post referenced in my comments above (enumerated below):

    1. Click Start, click Run, type regedit, and then click OK.
    2. Locate and then click the following registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
    3. Right-click Lsa, point to New, and then click DWORD Value. Next open your registry (windows + r, 'regedit' in the run prompt).
    4. Type DisableLoopbackCheck, and then press ENTER.
    5. Right-click DisableLoopbackCheck, and then click Modify.
    6. In the Value data box, type 1, and then click OK.
    7. Exit Registry Editor.
    8. Restart the computer.

    After reboot you must now disable strict name checking following the instructions from this article (enumerated below):

    1. Click Start, click Run, type regedit, and then click OK.
    2. Locate and click the following key in the registry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameters
    3. On the Edit menu, click Add Value, and then add the following registry DWORD value: DisableStrictNameChecking
    4. Right-click DisableStrictNameChecking, and then click Modify.
    5. In the Value data box, type 1, and then click OK.
    6. Exit Registry Editor.
    7. Restart the computer.

    After the last restart you will be able to path to a "simulated" unc location on your localhost computer. This should help in testing network deployed applications / scripts on a standalone system.