impersonation - C# Copying a file from one server to another with permissions -
impersonation - C# Copying a file from one server to another with permissions -
i have written c# console app re-create backup 1 server on schedule every day. works if have logged share folder , credentials chached, if credentials have not been input on share of source server, error in code. need have app impersonate login shared folder of source, can grab file , move destination.
public static void copynewestbackup() { string sourcepath = @"\\source"; string targetpath = @"\\destination"; fileinfo newestfile = getnewestfile(); string sourcefile = path.combine(sourcepath, newestfile.name); string destfile = path.combine(targetpath, newestfile.name); console.write("copying " + newestfile.name + " " + sourcepath + " " + destfile); filesystem.copyfile(sourcefile, destfile, uioption.alldialogs); //file.copy(sourcefile, destfile, true); }
how can impersonate login server grab file?
this msdn article gives view on impersonation: http://msdn.microsoft.com/en-us/library/chf6fbt4.aspx
c# impersonation fileinfo
Comments
Post a Comment