32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="NativeMethods.cs" company="Microsoft Corporation">
|
|
// Copyright (C) 2011 Microsoft Corporation
|
|
// </copyright>
|
|
//-----------------------------------------------------------------------
|
|
|
|
namespace Microsoft.Samples.Management.OData.RoleBasedPlugins
|
|
{
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
/// <summary>
|
|
/// Keeps declaration of native methods
|
|
/// </summary>
|
|
internal static class NativeMethods
|
|
{
|
|
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
public static extern bool LogonUser(
|
|
string lpszUsername,
|
|
string lpszDomain,
|
|
string lpszPassword,
|
|
int logonType,
|
|
int logonProvider,
|
|
ref IntPtr token);
|
|
|
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
|
public static extern bool CloseHandle(IntPtr handle);
|
|
|
|
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
public static extern bool DuplicateToken(IntPtr existingTokenHandle, int securityImpersonationLevel, ref IntPtr duplicateTokenHandle);
|
|
}
|
|
} |