3
동일한 도메인의 원격 시스템에서 파일을 복사하려고합니다. 그래서 나는 그것을하기 위해 가장을 사용하고 있습니다.네트워크를 통한 파일 복사의 가장.
나는 advapi32.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 명령으로 자격 증명을 테스트 해 보셨습니까? –
코드가 description에 추가되었습니다. – Denish