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?
Printable View
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?
These work on the current machine:
VB Code:
Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal _ lpszLocalName As String, ByVal lpszUserName As String, _ lpcchBuffer As Long) As Long ' return the current default user name or ' the user name used to establish a connection Function NetworkUserName() As String Dim buffer As String buffer = Space$(256) ' if the WNetGetUser API returns 0, then ' the user name is in buffer If WNetGetUser(vbNullString, buffer, Len(buffer)) = 0 Then NetworkUserName = Left$(buffer, InStr(buffer, vbNullChar) - 1) End If End Function
VB Code:
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Sub Form_Load() 'KPD-Team 1998 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] Dim strString As String 'Create a buffer strString = String(255, Chr$(0)) 'Get the computer name GetComputerName strString, 255 'remove the unnecessary chr$(0)'s strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1) 'Show the computer name MsgBox strString End Sub
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.
sorry, no idea.. be nice to know tho :rolleyes:
I have this, which lists on users on a domain, and whether they are logged in or not. Oh, it's not my code...
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 :)
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....
oops... just searched myself, seems that you can only set that bit anyway; I'm out of ideas :eek: