Mapping and Remapping Network Drives with Different Users on Win7

15,851

The issue has been resolved. Although I do not know exactly what did it, the following resource provided a number if possible fixes, many of which I tried and found unsuccessful, but perhaps some combination of them ended up working. I hope if other users come across this issue, this thread will be useful to them.

http://social.technet.microsoft.com/Forums/windows/en-US/ced8eab6-87e2-4d20-9d18-7aaf5e9713a3/windows-7-clear-cached-credentials?forum=w7itpronetworking

Share:
15,851
user3846506
Author by

user3846506

Mathematician on sabbatical from data science and programming.

Updated on June 09, 2022

Comments

  • user3846506
    user3846506 almost 2 years

    I am currently trying to develop an automated client-side test of a server that contains a network share. However, I need to verify its security by connecting with more than one user, although I only need to connect one user at a time.

    Currently, I am connecting using the command:

    net use z: \\server_ip\share password /user:doman\username
    

    and I am disconnecting using the command:

    net use z: /delete /y
    

    Furthermore, I verify the resource is no longer connected by simply examining that it is not listed on the net use command.

    However, if I disconnect and then try to reconnect as a different user, I am hit with a

    System Error 1219 has occurred.
    
    Multiple connections to a server or shared resource by the same user, using more
     than one user name, are not allowed. Disconnect all previous connections to the
     server or shared resource and try again.
    

    I did some research and solutions like mapping two different drives, one using the ip and another using the server name are not acceptable since the test client will not necessarily know the server name. Restarting the computer is also not acceptable given that would interrupt the automated tests. Finally, I cannot modify any server settings using the test client, so no Samba aliases.

    I think that perhaps the issue is cached credentials, but when I examine the credential manager in Control Panel, there is nothing listed.

    Is there any way to make Windows completely disconnect from the server share and/or make it forget the cached credentials? Or am I doing something wrong?

    Thank you for any suggestions/help!

    EDIT: I should clarify, any solutions have to be done programatically since this is an automated test that should be able to resolve this issue should it arise. I am writing in Python, but I am willing to utilize a solution in any language that can run on Windows.

  • mech
    mech about 8 years
    Welcome to Stack Overflow, @Akshat59 ! While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value.
  • Wyrmwood
    Wyrmwood over 7 years
    The - Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon - Change the value of CachedLogonsCount to 0 - Reboot Worked for me. Even though it was showing all connections disconnected before attempting a new connection, the new connection would always fail. After changing this registry entry and rebooting, it works now.
  • Wyrmwood
    Wyrmwood over 7 years
    This does not work, unless, however, you do net use * /d /y but that's not ideal, especially if you don't want to alter any other connections.