I have a local computer that connect to a Windows Server and accesses some files on a shared folder on that server. The server has several users defined, with rights to access some folder and to block some other, depending on the user connected.
What I need is a C# code to FULLY disconnect from the server, so that I have to enter the credentials again if I want to reconnect.
The code has to detect, NOT ONLY the open files or folders opened, but ANY connection, From my point of view, as far as I have introduced some credentials (user + pwd) I AM connected, and that connection can be detected and canceled.
I want a C# code that will allow me, while I sit in front of my local computer, to connect to server with credentials for User1, then disconnect, then reconnect as User2, etc, with any user defined on the server, WITHOUT THE NEED to close my local session.
NOTE: The code ONLY HAS to detect existing connections and cancel them. Nothing more.
NOTE2: I'm connecting to the server ONLY to access files and folders:
- I open Windows Explorer
- I type the server's name or IP
- I'm asked for the credentials: I enter username and password
- I then see the server's shared folders and printers
- I'M THEN CONNECTED, and have not yet opened any file
The C# piece of code has to disconnect me, so that I cannot keep browsing the server's folders without first entering again some access credentials. It should be a SIMPLE piece of code, no nuke matter...