Home > How-To Library > Network

How to Enumerate user accounts on network

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
Option Explicit Sub Main() Dim thisComputer As String Dim oWMIService As Object, oItem As Object, 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 End Sub

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.