1

If I want to close a user session on a Samba server, the smbcontrol close-share and smbcontrol kill-client-ip commands are available to achieve this. However when dealing with a shared client (a Windows Terminal Server for example) these commands close the session of all users on that client.

Is it possible to close the session of only one user if that session comes from a shared host? I've looked at the smbcontrol, samba-tool and net utilities, and although net rap session looked promising, it doesn't seem to work. I also tried net rpc file CLOSE, but that too doesn't seem to work.

roelvanmeer
  • 1,764
  • 3
  • 13
  • 27

2 Answers2

1

This post might help you. there are several answers so have a look and let us know if anything was helpful. [1]: https://social.technet.microsoft.com/Forums/en-US/72e66e9c-f55f-47ee-af92-20db0a2daacc/closing-smb-session-on-windows-client

blond_viper
  • 23
  • 1
  • 1
  • 4
  • Thanks, but I am trying to close the session server-side, not client-side, so I'm looking for a linux/samba command to do this. – roelvanmeer May 17 '22 at 12:09
  • I believe you can kill the login of that user I reckon well or reach out to that user to close the connection on their end. – blond_viper May 17 '22 at 12:14
0

Answer: yes, it can.

It is possible to list the open files with the command: net rpc file -U $user. The resulting list includes a FileId as first field. A specific file can be closed by using its FileId in this command: net rpc file close $fileid -U $user

Note that the $user used to connect needs to have the SeDiskOperatorPrivilege for the close command to work!

roelvanmeer
  • 1,764
  • 3
  • 13
  • 27