3
我想从远程计算机复制同一个域中的文件。所以我使用模拟来做到这一点。跨网络进行文件复制的模拟
我正在使用adlpipi32.dll的DLLImport并正确模拟用户。
现在当下面的代码行执行我得到以下错误。
\\line
File.Copy(@"\\sins00048178\D$\BNCustody\Swift\Received_from_SWIFT\Error_files\E03248681_error.out", @"C:\E03248681_error.out", true);
\\Error
"Logon failure: user not allowed to log on to this computer."
完整代码的要求提前
[DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken
);
IntPtr userHandle = IntPtr.Zero;
bool loggedOn = LogonUser(userid, domain, pass, 9, 0, out userHandle);
if (loggedOn)
{
WindowsImpersonationContext context = WindowsIdentity.Impersonate(userHandle);
File.Copy(@"\\sins00048178\D$\BNCustody\Swift\Received_from_SWIFT\Error_files\E03248681_error.out", @"C:\E03248681_error.out", true);
context.Undo();
}
感谢....
请向我们展示您的dll导入和实际调用。 – Dennis
您是否使用runas命令测试了凭据? –
在描述中添加的代码 – Denish