Listing All Users and User Details of your Local pc or of Intranet

Introduction

This article provide detail about how to list user and their details of local system or intranet by using System.Management.SelectQuery class. using Select Query class i have quered data from Win21_UserAccount class and listed all the data such as User Name, domain etc. 
 
The code example details are given bellow.
 

       SelectQuery SQ = new SelectQuery("Win32_UserAccount");

 ManagementObjectSearcher MOS = new ManagementObjectSearcher(SQ);

         foreach (ManagementObject MO in MOS.Get())

            {


                Console.WriteLine("Username : {0}", MO["FullName"]);

                Console.WriteLine("======-===========-==========-=========-=========-========-=========");


                Console.WriteLine("AccountType          : {0}", MO["AccountType"]);

                Console.WriteLine("Caption              : {0}", MO["Caption"]);

                Console.WriteLine("Description          : {0}", MO["Description"]);

                Console.WriteLine("Disabled             : {0}", MO["Disabled"]);

                Console.WriteLine("Domain               : {0}", MO["Domain"]);

                Console.WriteLine("FullName             : {0}", MO["FullName"]);

                Console.WriteLine("InstallDate          : {0}", MO["InstallDate"]);

                Console.WriteLine("LocalAccount         : {0}", MO["LocalAccount"]);

                Console.WriteLine("Lockout              : {0}", MO["Lockout"]);

                Console.WriteLine("PasswordChangeable   : {0}", MO["PasswordChangeable"]);

                Console.WriteLine("PasswordExpires      : {0}", MO["PasswordExpires"]);

                Console.WriteLine("PasswordRequired     : {0}", MO["PasswordRequired"]);

                Console.WriteLine("SID                  : {0}", MO["SID"]);

                Console.WriteLine("SIDType              : {0}", MO["SIDType"]);

                Console.WriteLine("Status               : {0}", MO["Status"]);                

                Console.WriteLine(Environment.NewLine);

        }

 

Summery 

The above example explains how to list the users and their information.

Ebook Download
View all
Learn
View all