Desktop Functions: Smart Device Functions:
|
LOGON_TYPE (advapi32)
C# Signature:
enum LOGON_TYPE VB Signature:
Enum LOGON_TYPE User-Defined Types:None. Notes:One important thing to note is that in order to use WindowsIdentity.Impersonate(), we need a primary token, so if we go with LOGON32, we'll need to use DuplicateHandle in order to get at the primary token. Since I like to avoid extra work like that, it looks like LOGON32 or LOGON32 would both be more appropriate choices. Selecting between them will depend on the rights that the account we're trying to logon has.
One important thing to note is that in order to use WindowsIdentity.Impersonate(), we need a primary token, so if we go with LOGON32_LOGON_NETWORK, we'll need to use DuplicateHandle in order to get at the primary token. Since I like to avoid extra work like that, it looks like LOGON32_LOGON_BATCH or LOGON32_LOGON_INTERACTIVE would both be more appropriate choices. Selecting between them will depend on the rights that the account we're trying to logon has. Once your call to LogonUser has gotten you a user token for the user you'd like to impersonate, you can then call WindowsIdentity.Impersonate() and have your thread take over the identity of the Windows user you just logged on.
Once your call to LogonUser has gotten you a user token for the user you'd like to impersonate, you can then call WindowsIdentity.Impersonate() and have your thread take over the identity of the Windows user you just logged on. https://blogs.msdn.microsoft.com/shawnfa/2005/03/21/how-to-impersonate/
https://blogs.msdn.microsoft.com/shawnfa/2005/03/21/how-to-impersonate/ Tips & Tricks:Please add some! Sample Code:
// Call LogonUser to get a token for the user Alternative Managed API:Do you know one? Please contribute it! Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|