list all User accounts

Does any one know how to return a list of all the users accounts.

 

 



Answer this question

list all User accounts

  • Yoky

    That worked after I modified little bit he query To

    ("Select * FROM Win32_useraccount")

    Now can I get the current user logged in to the session

    I am thinking to add to the query more details like "where user…."

    Well, I am not sure.


  • Bryan W

    are you talking about the object picker I don't think there is any such concept as built in user accounts. there are built in user groups. but all user accounts are created by the administrator, either directly or indirectly via a program executed by a user with administrative privileges.

  • MasterOD

    List users in an active directory

    http://www.vb-tips.com/default.aspx ID=2b7d8d24-665f-43d4-9553-9c76953e41cf

    List users on local computer using wmi. Add a reference to system.management for this sample

    Dim moReturn As Management.ManagementObjectCollection
    Dim moSearch As Management.ManagementObjectSearcher
    Dim mo As Management.ManagementObject

    moSearch = New Management.ManagementObjectSearcher("Select * from
    Win32_Account")

    moReturn = moSearch.Get

    For Each mo In moReturn
    Dim strOut As String
    strOut = String.Format("Name {0} ", mo("Name"))
    Trace.WriteLine(strOut)
    Next



  • SamirL

    here is a link to a C# component wrapper for the windows DsObjectPicker

    there is a sample app written in VB that is using it. as configured in the app, it is set for picking computers.

    IMPORTANT!!! build the solution before you open the test form or it will error loading in the designer. if you forget and open the form before compiling, jiust close the form and build the solution then open again.

    set the filters to user (both downlevel and uplevel) and set the computer name to the computer you want to browse(or leave it blank for the domain users).

    you can use two instances of the component, one set for computers to browse for a computer, and another for the uses on that computer.

    give a shout if you need help.



  • Karl Hilsmann MSFT

    This was good thank you

    This actually gives me more that what I was asking for.

    Now can I filter it so I can see only the user’s accounts (profiles) which have been added by the administrator In other words not the built in user accounts.


  • Nethesh

    Found it ...

    Dim DomainUser As String = System.Security.Principal.WindowsIdentity.GetCurrent.Name.Replace("\", "/")

    Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://" & DomainUser)

    Dim User_Name As String = ADEntry.Properties("Name").Value

    This should get the current user name that is logged in.


  • list all User accounts