|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
impersonation in vb.netI 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. 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. Show quoteHide quote "Nadeem Ahmed" <Nadeem Ah***@discussions.microsoft.com> wrote in message news:52C3119F-BB03-4DC2-8EA1-1058E0F16081@microsoft.com... > 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.
Problem with RSA.ImportParameters() under ASP .NET
AuthenticateAsServer/AuthenticateAsClient ProtectionLevel and iden Running application in local intranet .NET 2.0, X509Certificates and CRL Check Issues With User Control Embedded Into Web Page Since Installing .NET 2.0 CryptoAPI Encyption Translate BUILTIN to domain name NEED Solution for .NET 2.0 mscorcfg.msc w/o SDK Searching on Encrypted Fields |
|||||||||||||||||||||||