I\'m trying to connect to a remote password protected shared folder from a Windows service, which runs as LocalSystem account. It seems that the LocalSystem account is unabl
To tell the trust I worked all time only in a domain environment and without password-protected network shares, but I know that there are two main ways to make a connection: WNetAddConnection2
API and NetUseAdd
API. I recommend you to try NetUseAdd
function with Level equal to 1 (USE_INFO_1
). I used only USE_INFO_2
which has ui2_username
, ui2_domainname
and ui2_password
, but USE_INFO_1
has only ui1_password
, so it looks like a function made for connection to a password-protected share.
By the way, LogonUser() has really no sense, because it makes local login on the local computer and you need to establish a session to the remote computer. This do WNetAddConnection2
and NetUseAdd
functions.