Impersonation
C#
1
Posts
1
Posters
0
Views
1
Watching
-
Hi, I have used below code to log in to my network drive, before using this code every time when i manually access the network folder it asks me credential to login. But after executing this code the network drive is not asking for any credential when i manually locate to the network drive. Any idea what is happening
[DllImport("advapi32.dll")]
public static extern int LogonUserA(String lpszUserName,
String lpszDomain,
String lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken);
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int DuplicateToken(IntPtr hToken,
int impersonationLevel,
ref IntPtr hNewToken);\[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)\] public static extern bool RevertToSelf(); \[DllImport("kernel32.dll", CharSet = CharSet.Auto)\] public static extern bool CloseHandle(IntPtr handle);