Log on to the Windows Network Share (SMB) for this process only

It is easy to log into the Windows Network Share (SMB) for an entire user session (e.g. net use , WNetAddConnection2() , etc.).

Is there a similar way that only affects my current process?

Maybe some kind of token system?

The entire auth session is fine if there is no alternative, but I would prefer to avoid a "global solution to the local problem."

0
source share
2 answers

Network sessions (and assigned drive letters) are processed for each user, and not for each process. Thus, no, you cannot create an SMB session only for your process, unless it works with a special user account. Otherwise, you just need to add the global connection (for example, the CONNECT_TEMPORARY flag, for example), and then remove the connection ( WNetCancelConnection2() ) when you finish using it.

+1
source

Network sessions are processed by the Windows kernel as part of the smb client driver, so they are managed on every Windows workstation (and not actually), which means that you cannot access the same resource with two different credentials and you don’t You can create a new network connection for each process according to the restriction imposed by the Windows smb client . The reason for the limitation is that Microsoft has implemented access to shared resources as a filter driver, each UNC path (\ share \ test) for sharing is stored as a shared resource to make your life as a developer and user easier. (makes sharing accessible seamless)

A quick example of how it launches network usage on the elevated command line (runs as an administrator) and tries to access it in an unselected context.

you can go anyway:

  • use samba / another userland sms user implementation (there are some python based ones) in your software.
  • create a new winstation for each of your processes (this has a lot of overhead)
0
source

All Articles