Re: Impersonate Issues to note
- From: "Anthony Jones" <Ant@xxxxxxxxxxxxxxxx>
- Date: Fri, 19 Jan 2007 09:35:33 -0000
"Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%2335SAP0OHHA.140@xxxxxxxxxxxxxxxxxxxxxxx
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.noticed
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
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
It's for this reason I always use the header files to find definitions and
signatures. Then build the ones I want to use into a type library.
.
- References:
- Impersonate Issues to note
- From: Tony Proctor
- Impersonate Issues to note
- Prev by Date: Re: Learn API or VB.Net instead
- Next by Date: Re: Learn API or VB.Net instead
- Previous by thread: Re: Impersonate Issues to note
- Next by thread: Re: Impersonate Issues to note
- Index(es):