Results 1 to 3 of 3

Thread: Retrieve Network UserName?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733

    Retrieve Network UserName?

    How do you retrieve a username from a network?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    anyone got any ideas on this one???

  3. #3
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    VB Code:
    1. 'GET USER NAME
    2. 'MODULE:
    3. Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    4.  
    5. 'FORM:
    6. Private Sub Form_Load()
    7. Dim cn As String
    8. Dim ls As Long
    9. Dim res As Long
    10. cn = String(1024, 0)
    11. ls = 1024
    12. res = GetUserName(cn, ls)
    13. If res <> 0 Then
    14. MsgBox "You are logged in as " & " " & Mid(cn, 1, InStr(cn, Chr(0)) - 1)
    15. Else
    16. MsgBox "You are not logged in"
    17. End If
    18. End
    19. End Sub
    20.  
    21.  
    22.  
    23. 'GET NET USER NAME
    24. 'MODULE:
    25. Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long
    26.  
    27. 'FORM:
    28. Private Sub Form_Load()
    29. Dim b As String * 128
    30. WNetGetUser "", b, 128
    31. MsgBox "Username = " & b
    32. End
    33. End Sub

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