Enumerate Users

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bryan

    Enumerate Users

    How can I get a list of all users currently logged into a Windows Server?
    My program will be a windows service that has administrative access, so I
    should have the correct access to do this.

    Thanks for any help,
    Bryan


  • Bryan

    #2
    Re: Enumerate Users

    PLEEEEEEEEEEEEE EEEEEEASE HELP...

    I have tried many things, but just cant seem to get it!.. The closest I
    have come is to get a list of "LogonId" that represent a connection...
    If anyone has any tips I sure would appreciate it...

    TIA,
    Bryan

    [snip]

    String ToClient = "";
    //SelectQuery query = new SelectQuery("Wi n32_NetworkClie nt"); // NO
    (returns network info)
    //SelectQuery query = new SelectQuery("Wi n32_NetworkConn ection"); // NO
    (returns nothing!)
    SelectQuery query = new SelectQuery("Wi n32_LogonSessio n"); // NO (returns
    some kind of number (Login ID) rahter than the actual user ID)
    //SelectQuery query = new SelectQuery("Wi n32_Account"); // NO (returns
    everything...)
    //SelectQuery query = new SelectQuery("Wi n32_ServerConne ction"); // NO
    (returns nothing!)
    //SelectQuery query = new SelectQuery("Wi n32_ServerSessi on"); // NO
    (returns nothing!)
    //SelectQuery query = new SelectQuery("Wi n32_UserAccount "); // Returns
    info as expected (but returns all). "Name" is the User ID

    try
    {
    ManagementObjec tSearcher searcher = new ManagementObjec tSearcher(query );
    foreach (ManagementObje ct mo in searcher.Get())
    {
    ToClient += "~" + (String)mo["Caption"] + ", " + (String)mo["Descriptio n"]
    + ", " + (String)mo["LogonId"] + ", " + (String)mo["Name"] + ", " +
    (String)mo["Status"];

    }
    } catch (Exception e) {
    ToClient += "Error: " + e.ToString();
    }

    return ToClient;


    "Bryan" <bryansp_msX@ho tmailX.comX> wrote in message
    news:OWp0lP9pDH A.2064@TK2MSFTN GP11.phx.gbl...[color=blue]
    > How can I get a list of all users currently logged into a Windows Server?
    > My program will be a windows service that has administrative access, so I
    > should have the correct access to do this.
    >
    > Thanks for any help,
    > Bryan
    >
    >[/color]


    Comment

    Working...