Results 1 to 3 of 3

Thread: How do I get current user name and domain?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    8

    How do I get current user name and domain?

    In ASP we can get the user by this:

    sUser=Request.ServerVariables("AUTH_USER")

    But how do I get the user in VB?

    I have used the API Function,

    Private Declare Function w32_WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long

    but this only gets the user name.

    I want the domain and username (<domain>\<username>)

    Any suggestions?

    Vone

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    8

    Found solution

    VB Code:
    1. Dim WinNTSysInfo As WinNTSysInfo
    2. set WinNTSysInfo = New WinNTSysInfo
    3.  
    4. Debug.Print WinNTSysInfo.DomainName
    5. Debug.Print WinNTSysInfo.UserName

  3. #3
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    or use the the "Environ" Function.
    VB Code:
    1. MsgBox Environ("USERDOMAIN")
    2. MsgBox Environ("USERNAME")

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