1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| [Test]
public static void EcritureFichier_Tester()
{
IntPtr token;
bool b = LogonUser("DOMAIN\login", "DOMAIN", "password", LogonTypes.NewCredentials, LogonProviders.Default, out token);
WindowsIdentity.Impersonate(token);
Console.WriteLine(b);
EMail eMail = new EMail();
eMail.Body = "C'est le body et puis tanpis !";
ActeWebMailer.ActeWebMailer.EcritureFichier(eMail, @"\\affgt\fr\");
}
[DllImport("advapi32.dll", SetLastError = true)]
static extern bool LogonUser(
string principal,
string authority,
string password,
LogonTypes logonType,
LogonProviders logonProvider,
out IntPtr token);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool CloseHandle(IntPtr handle);
enum LogonTypes : uint
{
Interactive = 2,
Network,
Batch,
Service,
NetworkCleartext = 8,
NewCredentials
}
enum LogonProviders : uint
{
Default = 0, // default for platform (use this!)
WinNT35, // sends smoke signals to authority
WinNT40, // uses NTLM
WinNT50 // negotiates Kerb or NTLM
} |
Partager