CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: LogonUser

  1. #1
    Join Date
    Jul 1999
    Posts
    8

    LogonUser

    How do I use LogonUser (win32 api) together with vb.
    The following is the problem, they are constants and how do I get those constants to work with VB?

    DWORD dwLogonType, //
    DWORD dwLogonProvider, //


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: LogonUser

    use the API Viewer add-in to get those constants in VB syntax.
    I did it for you:
    Public Const LOGON32_LOGON_INTERACTIVE = 2
    Public Const LOGON32_PROVIDER_WINNT35 = 1



  3. #3
    Join Date
    Jul 1999
    Posts
    8

    Re: LogonUser

    Thanks! But why doesn't it work (login failed)??
    the code is under a command_button in a form with nothing else...
    the domain, pwd and user is correct (string type).

    Dim TokenHandle as Long
    Dim lstatus as Long

    lstatus = LogonUser("user", "domain", "pwd", LOGON32_LOGON_INTERACTIVE,
    LOGON32_PROVIDER_DEFAULT, TokenHandle)

    If lstatus then
    lstatus = CloseHandle(TokenHandle)
    MsgBox "Login Successful"
    else
    MsgBox "Login Failed"
    End If





  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: LogonUser

    always call FormatMessage and pass the err.lastDLLerror to get a readable description of the reason of your error


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured