I'm writing a program which needs to be able to upload a single file to a SMB share folder. While the program will run with user specified credentials, the program may need to access the SMB folder with different credentials, which are built into the program. I can use WNetAddConnection2
, but this allows the user access to the share while the folder is uploading. I can't just access the share with standard I/O, because I need it to be accessed with the specified credentials, not through the privileges of the user who is logged in.
Is there a simple way that can I upload a single file to an SMB share with specified credentials, without creating a semi-permanent connection through WNetAddConnection2
or net use
.