Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Finding names of local user accounts

Finding names of local user accounts

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EnkelIk
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • E EnkelIk

      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

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      See my article about it: Getting local groups member names in C#[^] Mazy No sig. available now.

      E 1 Reply Last reply
      0
      • M Mazdak

        See my article about it: Getting local groups member names in C#[^] Mazy No sig. available now.

        E Offline
        E Offline
        EnkelIk
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • E 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

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          Yes,but only works when you working wiht Active Directory. :) Mazy No sig. available now.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups