Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get user name from Computer Name

Status
Not open for further replies.

hwkranger

MIS
Nov 6, 2002
717
US
I'm trying to find the User name of someone that has a file opened on the network drive programatically, I've been able to fetch their Computer name, but not their user name. If I have the username I can fetch their full name from

Code:
Private Declare Function apiNetUserGetInfo _
    Lib "netapi32.dll" Alias "NetUserGetInfo" _
    (servername As Any, _
    username As Any, _
    ByVal Level As Long, _
    bufptr As Long) As Long



I don't have access to query the WMI services on another machine, How would I achieve getting their USER NAME if I know a user's Machine Name?

This code won't work.. since I dont' have the permissions...

Code:
Dim strComputer As String
Dim objWMIService As Object
Dim colcomputer As Object
Dim objcomputer As Object
'WXP8NW2T81
strComputer = "WXP8NW2T81"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colcomputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
 
For Each objcomputer In colcomputer
   'out put...
Next

Any help is beneficial.

Randall Vollen
Merrill Lynch
 
Check out Application.UserName



[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
I need to know about a remote machine.

Example: Lets say you want to see who has an Access 2003 File open. You can read from the ADO recordset that reads the ldb file. This file only gives you the COMPUTER NAME of the machine that has it open. If I wanted to see who's logged onto that machine, how would I achieve this?



Randall Vollen
Merrill Lynch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top