Impersonate Issues to note
- From: "Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 18 Jan 2007 21:00:55 -0000
I've been trying to use ImpersonateSelf here, and ran into a few problems. I
just want to jot them down in case anyone else finds them useful.
To start with, the API TextViewer declaration is wrong. It declares it as:
Private Declare Function ImpersonateSelf Lib "advapi32.dll"
(ImpersonationLevel As Integer) As Long
but this gives parameter validation errors. After looking at the C header
file, I changed it to the following and it was a lot better:
Private Declare Function ImpersonateSelf Lib "advapi32.dll" (ByVal
ImpersonationLevel As Long) As Long
The next problem is the definition of the SECURITY_IMPERSONATION_LEVEL
values. The API TextViewer gives just:
Private Const SecurityAnonymous = 1
Private Const SecurityIdentification = 2
even though these blatantly disagree with the MSDN documentation. I noticed
that a lot of old posts also seem to use these bad values. Again, after
looking at the C header files, I used the following definition instead:
Private Enum SECURITY_IMPERSONATION_LEVEL
SecurityAnonymous = 0
SecurityIdentification
SecurityImpersonation
SecurityDelegation
End Enum
Tony Proctor
.
- Follow-Ups:
- Re: Impersonate Issues to note
- From: Ken Halter
- Re: Impersonate Issues to note
- From: Anthony Jones
- Re: Impersonate Issues to note
- From: Tony Proctor
- Re: Impersonate Issues to note
- Prev by Date: Re: Detect mouse pointer over scrollbar
- Next by Date: Re: Impersonate Issues to note
- Previous by thread: DeviceIoControl and reparse points.
- Next by thread: Re: Impersonate Issues to note
- Index(es):
Relevant Pages
|