Results 1 to 8 of 8

Thread: Netwrok Information: Users logged in and PC names

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Question Netwrok Information: Users logged in and PC names

    I have code, using API, which will allow me to view all users who have an NT account on our network. What I need to know is what PC they are logged into...

    Does anyone know how to find a users PC name?

    Has anyone got a spare fish?

  2. #2
    Si_the_geek
    Guest

    Will an orange halibut do?

    These work on the current machine:
    VB Code:
    1. Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal _
    2.     lpszLocalName As String, ByVal lpszUserName As String, _
    3.     lpcchBuffer As Long) As Long
    4.  
    5. ' return the current default user name or
    6. ' the user name used to establish a connection
    7.  
    8. Function NetworkUserName() As String
    9.     Dim buffer As String
    10.     buffer = Space$(256)
    11.     ' if the WNetGetUser API returns 0, then
    12.     ' the user name is in buffer
    13.     If WNetGetUser(vbNullString, buffer, Len(buffer)) = 0 Then
    14.         NetworkUserName = Left$(buffer, InStr(buffer, vbNullChar) - 1)
    15.     End If
    16. End Function

    VB Code:
    1. Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    2. Private Sub Form_Load()
    3.     'KPD-Team 1998
    4.     'URL: [url]http://www.allapi.net/[/url]
    5.     'E-Mail: [email][email protected][/email]
    6.     Dim strString As String
    7.     'Create a buffer
    8.     strString = String(255, Chr$(0))
    9.     'Get the computer name
    10.     GetComputerName strString, 255
    11.     'remove the unnecessary chr$(0)'s
    12.     strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1)
    13.     'Show the computer name
    14.     MsgBox strString
    15. End Sub

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking Orange halibuts are a protected species...got any blue haddock?

    I know how to get the info for my PC, but what I am trying to do it look at all users logged into the network and find out the computer name which they are logged into

    I know it's possible. have found code to list all users, and code to list all computer names, but what I can't do is link a computer name to the user logged in, which is what is required.

    Booooooooooooooooooooooooooooooooooooo.

  4. #4
    Si_the_geek
    Guest

    I've only got a blue goldfish I'm afraid...

    sorry, no idea.. be nice to know tho

  5. #5

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking Come on! Blue goldish saves the world!

    I have this, which lists on users on a domain, and whether they are logged in or not. Oh, it's not my code...
    Attached Files Attached Files

  6. #6
    Si_the_geek
    Guest

    Unhappy sorry, felt peckish.. had it for lunch

    very nice code, I'm sure I'll find a use for it sometime...

    having a quick peek at the API-Guide the NetUserGetInfo function is definitely the way to get it... seems that you can pass USER_INFO_x to get various forms of information back, but lack of definitions for the variations of X and how to get the data out unfortunately.

    Try searching the web for "NetUserGetInfo and USER_INFO_". I'm sure you'll find it then

  7. #7

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking Unhappy, required that for interaction with my programmable frag!

    Oooo...Just been to pub and had 3 pints
    Gotta work feeling very wobbley. Drinking in afternoon doesn't go down to well...

    Tried searching on those things but it only produced to result, neithe rof which were any good

    *SIGH*

    back to the drawing board....

  8. #8
    Si_the_geek
    Guest

    pants on my head, feeling cosy

    oops... just searched myself, seems that you can only set that bit anyway; I'm out of ideas

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