4

I'm connected to a Linux smb share via Samba from Windows and have logged in using account "jim". Now I want to logout of Jim's account and login as "fred", because account Jim has no access to Fred's home share.

I can see an active smb connection via PowerShell:

PS> Get-SmbConnection

ServerName ShareName UserName                          Credential                        Dialect NumOpens
---------- --------- --------                          ----------                        ------- --------
10.0.1.21  jim   DESKTOP-UTS9E27\Jim Bob DESKTOP-UTS9E27\jim                             3.1.1   0

There is a PowerShell command Close-SmbSession, but I have no sessions; only connections:

PS> Get-SmbSession
PS>

I accessed the share from an Explorer window by navigating to \\10.0.1.21\jim and logging in with the correct credentials. I did not map the directory to a drive letter. Therefore my connection is not visible from NET USE:

C:\>net use
New connections will be remembered.

There are no entries in the list.

I can't revoke the credential because it's not listed in the Credential Manager:

enter image description here

If I try to access Fred's home directory explicitly with \\10.0.1.21\fred, Windows will provide a login dialog:

enter image description here

However, using Fred's credentials gives an error that tells me that I'm already logged in as another user on this account and multiple connections as other users is not allowed:

enter image description here

So it's pretty clear that I need to explicitly log out of one user before I can log in as another. But I don't know how to do that. At this point, I have to reboot my computer, because I can't find any way to logout of one user once I've logged in. Closing the Explorer window with the previous connection retains that login. How do I log out of Jim's credentials so I can login as Fred to access a share with a different permission?

4
  • What happens if you perform a net use /d * which disconnects everything related to network shares?
    – LPChip
    Aug 16, 2022 at 9:57
  • @LPChip: This will work for mappings.
    – harrymc
    Aug 16, 2022 at 9:59
  • @harrymc I've had it also work for non mappings.
    – LPChip
    Aug 16, 2022 at 10:53
  • There is no sessions visible to NET USE, as stated in the question. When using this command when there are no mappings, the response is There are no entries in the list.
    – Zhro
    Aug 16, 2022 at 20:17

2 Answers 2

2

Once all open files on the share are closed, the idle connection should be closed automatically by the server within 15 minutes (if the server is Windows).

Otherwise, to close all SMB connections, one strong-arm method is to enter the Services applet and restart the Workstation service. This clears the cached credentials from the SMB connections.

Services applet :

enter image description here

Task Manager :

enter image description here

5
  • I'm very interested in the resolution of restarting the Workstation service. I appear to not have this service though. Do you know the exact name? EDIT: got it. Lanman Workstation: batcmd.com/windows/10/services/lanmanworkstation
    – LPChip
    Aug 16, 2022 at 10:55
  • Mine is called just "Workstation". What is your version of Windows?
    – harrymc
    Aug 16, 2022 at 11:01
  • Windows 10 21H2. Its called Workstation in the description, but the service name itself is Lanman Workstation Same as described in the link I posted earlier. EDIT: oh this is interesting. Task Manager's Services tab says lanman workstation, but services.msc uses the description as the Name field. Opening the service there tells me Lanman Workstation again.
    – LPChip
    Aug 16, 2022 at 11:26
  • This is not very useful in the event that I don't have access to this service. It's bizarre that there doesn't seem to be a more useful method of logging out of a SMB connection. I can't find a way to query this information outside of PowerShell as well. How did older versions of Windows without it obtain the same information?
    – Zhro
    Aug 16, 2022 at 20:53
  • Although I was able to obtain some success using the method of restarting the Workstation service (permission aside), this solution appears to be problematic. After a few tests, the service locked up and was stuck in a perpetual state of "Stopping". The service could not be restarted and was unrecoverable. The only solution was the restart the computer. If the system enters this state, it is no different from requiring a full system restart in order to login as a different user, and can't be relied upon for this use case without compromising the state of all running applications.
    – Zhro
    Aug 17, 2022 at 0:18
-1

Remove the file share

net use <driveletter>: /delete

Then close the IPC session

net use \\10.0.1.21 /delete

1
  • There is no IPC session visible to NET USE, as stated in the question.
    – Zhro
    Aug 16, 2022 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .