Re: impersonation in vb.net



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.


.



Relevant Pages

  • Using LogonUser API in ASP.net with an account other than ASPNet account
    ... I am trying to use the LogonUser API function from ASP.Net. ... on windows 2000 server. ... part of operating system" is permission is needed for using LogonUser ... When I give this permission to the asp.net account ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: c#, indexing service and authorization
    ... operating system) to execute LogonUser under Windows 2000. ... >> I would like to ask, is there anybody successfully calling LogonUser() ...
    (microsoft.public.dotnet.security)
  • Re: LogonUser failed with error code : 1314 [After explicitly giving T
    ... You need to call LogonUser to create a token that you can use to create the ... WindowsIdentity.GetCurrentreturns the name of the anonymous user. ... Doing ACLs on the file system so that you can write to specific locations is ... I cannot recommend enough to read Keith Brown's Windows ...
    (microsoft.public.dotnet.security)
  • Re: Using LoginUser for Authentication
    ... This is sort of a problem on windows 2000, because LogonUser only ... What you might consider is using SSPI to authenticate the user's ... >using Administrator user accounts. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: WindowsPrinciple.IsInRole not working with cached info
    ... LogonUser talks to the local LSA and it will ... Windows API function that generally results in an RPC call to the DC to do ... I can't really think of a good way to get around this with IsInRole though. ... >> I'm not doing anything that I know about to cache role credentials. ...
    (microsoft.public.dotnet.security)