Re: impersonation in vb.net
- From: "Joe Kaplan \(MVP - ADSI\)" <joseph.e.kaplan@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Feb 2006 10:53:54 -0600
As the documentation for LogonUser states, it requires the TCB privilege
(act as part of the operating system) under Windows 2000. Only the SYSTEM
account has this by default. XP and 2003 do not have this restriction.
Note that it is a good idea to use Microsoft's sample implementation from
the MSDN docs for WindowsImpersonationContext instead of roling your own
wrapper here.
Joe K.
"Nadeem Ahmed" <Nadeem Ahmed@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:52C3119F-BB03-4DC2-8EA1-1058E0F16081@xxxxxxxxxxxxxxxx
Hi,
I am trying to impersonate a local user on windows 2000 server in
vb.net
application using following piece of code
Public Class ADVAPI32
' LogonUser call
Public Declare Auto Function LogonUser Lib "advapi32.dll" _
(ByVal lpszUserName As String, ByVal lpszDomain As String, _
ByVal lpszPassword As String, ByVal dwLogonType As Integer, _
ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Integer
Public Enum Logon
Batch = 1
Interactive = 2
NetworkCleartext = 8
End Enum
Public Enum Provider
[Default] = 0
WindowsNT35 = 1
WindowsNT40 = 2
Windows2000 = 3
End Enum
Public Declare Auto Function CloseHandle Lib "kernel32.dll" _
(ByVal hObject As IntPtr) As Integer
End Class
when I call following method, providing only user name and password, it
always returns 0.
ADVAPI32.LogonUser(username, domain, password, ADVAPI32.Logon.Interactive,
ADVAPI32.Provider.Default, hUser)
Can you please explain why its returing zero?
Thanks.
.
- Prev by Date: Re: CAPICOM within .NET
- Next by Date: Remoting System.Security exception
- Previous by thread: CryptoAPI
- Next by thread: Remoting System.Security exception
- Index(es):
Relevant Pages
|