If you are like me you might have multiple user accounts on the target windows box and you might want to switch the network credentials used to login by the Windows. One thing which I have found extremely annoying is the tendency of Windows Explorer to remember your last credential even when you have kept the “remember credentials” checkbox unchecked. I am not talking about credentials which you ask Windows to “remember” but about credentials which you don’t want Windows to remember so that if I closed explorer and re-opened the explorer and tried to access a remote computer’s file share I should be asked for the credentials again. I don’t know if this is a Windows 7 specific behavior or not but I am facing this issue on Windows 7. This logon is basically cached for your convenience. But what if you don’t want your credentials to be cached, what if you want to switch your credentials rapidly. This might sound stupid to some but it is helpful once in a while.
Well I found a workaround which is clunky but works great. Open a command prompt in administrator mode and execute the following command.
net use \\your_remote_computer\share /delete
This command basically terminates the connection to your remote computer if it’s not already terminated. If you want to terminate all your connections then execute the following command instead of the above command.
net use * /delete
The above command ensures that all connections to any remote computers are terminated. This command might ask you for confirmation in the command prompt. Answer “yes” for all connections. Now follow up with the following command:
klist purge
This command basically terminates the Kerberos Ticket for the credential you had for your remote computer if it has not already been done. Please note you need to ensure that the connection to the remote computer has been terminated and then purge the outdated kerberos tickets for closed connections so you need to execute the 2 commands in sequence. This will ideally solve this little problem.