Finding names of local user accounts
-
Hi all. Is there an easy way to retrieve the names of all the local user accounts on a computer? If it is possible to get additional information about the accounts that would be great, but it is not absolutely necessary... Thanks /EnkelIk
-
See my article about it: Getting local groups member names in C#[^] Mazy No sig. available now.
Thanks for your answer. This also works (putting the names of the accounts into a datatable): string strHost=Environment.MachineName; DirectoryEntry vscDirEnt=new DirectoryEntry("WinNT://" + strHost + ",computer"); DataTable vscDT=new DataTable(); DataRow vscDR; vscDT.Columns.Add("names",System.Type.GetType("System.String")); foreach(DirectoryEntry vscAccount in vscDirEnt.Children) { if(string.Compare(vscAccount.SchemaClassName,"User",true)==0) { vscDR=vscDT.NewRow(); vscDR["names"]=vscAccount.Name; vscDT.Rows.Add(vscDR); } } Thanks /EnkelIk
-
Thanks for your answer. This also works (putting the names of the accounts into a datatable): string strHost=Environment.MachineName; DirectoryEntry vscDirEnt=new DirectoryEntry("WinNT://" + strHost + ",computer"); DataTable vscDT=new DataTable(); DataRow vscDR; vscDT.Columns.Add("names",System.Type.GetType("System.String")); foreach(DirectoryEntry vscAccount in vscDirEnt.Children) { if(string.Compare(vscAccount.SchemaClassName,"User",true)==0) { vscDR=vscDT.NewRow(); vscDR["names"]=vscAccount.Name; vscDT.Rows.Add(vscDR); } } Thanks /EnkelIk