|
-
June 12th, 2009, 02:02 AM
#1
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.
-
June 12th, 2009, 02:19 AM
#2
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. 
-
June 12th, 2009, 03:04 AM
#3
Re: windows users
will need both on different circumstances
-
June 12th, 2009, 05:08 AM
#4
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
-
June 14th, 2009, 11:07 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|