I have a WindowsForms vb.net Framework 4.6 Application which must copy some files from c:\sample
to a network drive (\\servername\sample
).
I must use other credentials to access the share. But I can't use impersonate, because i have to use a local user on the Server. The Login on the server is something like <.\Username> <password>
.
Is there a way to copy my files to the network drive using the server's local user credentials?
EDIT 18.06:
I also tried this way, but it did not work for me.
Dim domain, username, passwordStr, remoteServerName As String
Dim password As New System.Security.SecureString
Dim command As New Process
domain = "servername"
username = "username"
passwordStr = "password"
remoteServerName = "\\servername\path\"
Dim impersonator As New AliasAccount(username, passwordStr)
For Each c As Char In passwordStr.ToCharArray
password.AppendChar(c)
Next
command.StartInfo.FileName = "test.pdf"
command.StartInfo.Arguments = remoteServerName
command.StartInfo.UserName = username
command.StartInfo.Password = password
command.StartInfo.Domain = domain
command.StartInfo.Verb = "open"
command.StartInfo.UseShellExecute = False
impersonator.BeginImpersonation()
command.Start()
impersonator.EndImpersonation()
My user on the server does not a have a specific domain, because the user only exists on the server. So i'm using the servername as the domain. I also tried using ".\".
I'm always getting the same error "wrong username or password" (translated from german to englisch). I've checked the username and password more than 30 times... It is definitely correct. I'm also able to connect a network drive with the credentials... So they are correct.
Do you have any other suggestions?