WinSCP .NET Assembly impersonation issue: The stub received bad data

Viewed 132

I have an .NET console app using WinSCP assembly version 5.19.5. The app is under impersonation in order to access files on NAS so that I set ExecutableProcessUserName and ExecutableProcessPassword for the Session object.

Dim sessionOptions As New SessionOptions
With sessionOptions
    .Protocol = Protocol.Sftp
    .HostName = _SFTPServer
    .UserName = _SFTPLoginID
    .Password = _SFTPLoginPwd
    .PortNumber = _SFTPPort
End With

sessionOptions.SshHostKeyFingerprint =
    session.ScanFingerprint(sessionOptions, "SHA-256")

Using session As New Session
    session.ExecutableProcessUserName = _ServiceAccountUsername
    session.ExecutableProcessPassword =
        ConvertToSecureString(_ServiceAccountPassword)
    session.Open(sessionOptions)

It fails at session.Open with error:

The stub received bad data Any ideas? Thanks

1 Answers

It seems that you need to specify the domain:
Stub received bad data?

session.ExecutableProcessUserName = "user@domain";

Side note: Setting SessionOptions.SshHostKeyFingerprint to the value returned by session.ScanFingerprint is just an ineffective equivalent of SshHostKeyPolicy.GiveUpSecurityAndAcceptAny.

Related