Using the Win32_UserAccount WMI class we can iterate through the user account information on a local computer.
From MSDN:
The Win32_UserAccount WMI class contains information about a user account on a computer system running Windows.
Sample usage
The following function will query the Win32_UserAccount class and iterate through it to list all available properties.
Function GetUserAccountInfo()
Dim objWMI As Object
Dim accounts As Object
Dim account As Object
Set objWMI = GetWMIService
Set accounts = objWMI.ExecQuery("Select * from Win32_UserAccount")
For Each account In accounts
Debug.Print account.AccountType
Debug.Print account.Caption
Debug.Print account.Description
Debug.Print account.Disabled
Debug.Print account.Domain
Debug.Print account.FullName
Debug.Print account.InstallDate
Debug.Print account.LocalAccount
Debug.Print account.Lockout
Debug.Print account.Name
Debug.Print account.PasswordChangeable
Debug.Print account.PasswordExpires
Debug.Print account.PasswordRequired
Debug.Print account.SID
Debug.Print account.SIDType
Debug.Print account.Status
Next account
End Function
Function GetWMIService() As Object
' http://msdn.microsoft.com/en-us/library/aa394586(VS.85).aspx
Dim strComputer As String
strComputer = "."
Set GetWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
End Function