CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: windows users

  1. #1
    Join Date
    Aug 2007
    Posts
    135

    windows users

    i am trying to list all windows users on a system using C#. An user with administrator rights will be using the application.

    i found very few links for the same using google.
    How can i achieve the same? I would also like to access per user appData folder.
    Last edited by ChessMaster; June 12th, 2009 at 02:08 AM.

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: windows users

    All local users, or all users in domain?
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  3. #3
    Join Date
    Aug 2007
    Posts
    135

    Re: windows users

    will need both on different circumstances

  4. #4
    Join Date
    Aug 2007
    Posts
    135

    Re: windows users

    ok some progress finally

    Code:
    ArrayList GetSystemUsers()
    {
    ArrayList users = new ArrayList();
    DirectoryEntry root = new DirectoryEntry("WinNT://" + Environment.MachineName);
    DirectoryEntry admGroup = root.Children.Find("users", "group");
    object members = admGroup.Invoke("members", null);
    foreach (object groupMember in (IEnumerable)members)
    {
    DirectoryEntry member = new DirectoryEntry(groupMember);
    string str = string.Empty;
    users.Add(member.Name);
    }
    return users;
    }


    the code gives me what i am after, but not completely. Maybe i havent understood how to use the DirectoryServices.

    The above returns users who belong to the users group.
    If i need administrators list i need to run that again for administrators, and for guests.
    How can i retrieve the whole list in one call?

    and....the above call gives me some other values which confuses me.

    For administrators, i get.... Domain Admins, & myAdmin. myAdmin is a valid user. Why is Domain Admins returned?
    Similarly for users, i get other values along with the user list. (INTERACTIVE, Authenticated Users, ASPNET, Domain Users along with the actual usernames who belong to the user group).

    Someway i can just get the list of users?

    thanks

  5. #5
    Join Date
    Aug 2007
    Posts
    135

    Re: windows users

    anyone??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured