[RESOLVED] Enumerating user accounts on network
Hi,
I need to enumerate the user accounts on the network. I'm writing a program that should only be accessed by management and they're already complaining that they have to remember too many (2) passwords. What I want to do is check which account is loged in on the current PC and if they aren't suppose to have access, close the program. But I'd need to ba able to add users to my lis, and for that I want to have a list of all the user accounts so that I can just choose one from there.
Any help would be greatly appreciated
Re: Enumerating user accounts on network
How about using WMI?
VB Code:
Dim thisComputer As String
Dim oWMIService As Object
Dim oItems As Object
Dim cItems As Object
thisComputer = "."
Set oWMIService = GetObject("winmgmts:\\" & thisComputer & "\root\CIMV2")
Set cItems = oWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", , 48)
For Each oItem In cItems
Debug.Print "FullName: " & oItem.FullName
Debug.Print "Name: " & oItem.Name
Debug.Print "Domain: " & oItem.Domain
Debug.Print "LocalAccount: " & oItem.LocalAccount
Next
Re: Enumerating user accounts on network
Shuja_Ali: That might just be exactly what I need!! I ran the code and it seems to return al the accounts. Didn't verify, but it'll do for now. Thank you.
PS. rated!