thanks for ur quick response. but im stucked with login only. im using following code to try to login:
bool success = LogonUser(\"username\", \"000.000.000.
you need impersonation :
[DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken);
IntPtr userToken = IntPtr.Zero;
bool success = External.LogonUser(
"john.doe",
"domain.com",
"MyPassword",
(int) AdvApi32Utility.LogonType.LOGON32_LOGON_INTERACTIVE, //2
(int) AdvApi32Utility.LogonProvider.LOGON32_PROVIDER_DEFAULT, //0
out userToken);
if (!success)
{
throw new SecurityException("Logon user failed");
}
using (WindowsIdentity.Impersonate(userToken))
{
// do the stuff with john.doe's credentials
}
We have a similar scenario in our project. We have created a user on the domain which has required permission on local and remote server (both servers in same domain). We have a windows service as well as web application both configured to run under this user context. Hence we don't get permission issues when coping the file to and from remote server.
However if the remote server is not on the same domain, then you either user Impersonation(if possible) or configure a ftp server on remote machine. You can then upload and download files using ftp protocol.