If you want to have the list of an specific windows group in C# you can get this list by these lines of code below. Notice that you have to add a reference to System.DirectoryServices .
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName);
DirectoryEntry admGroup = localMachine.Children.Find("administrators","group");
object members = admGroup.Invoke("members", null);
foreach (object groupMember in (IEnumerable)members)
{
DirectoryEntry member = new DirectoryEntry(groupMember);
lstUsers.Items.Add(member.Name);
}
you can download the source code here:
http://www.tabatabaei.info/csharpsamples/WindowsGroupMember.rar
Monday, September 10, 2007
How to get list of windows user in C#
Subscribe to:
Post Comments (Atom)
12 comments:
Dude!
That code was just the thing I was looking for - and simple too.
Thanks a million.
Paul.
Hi,
thanks verymuch for code to get the windows group user list,
How can I know the the particular user FirstName and LastName.
please let me know.
Thanks in advance,
Udaya Bhaskar.
thanks
This code is great!
One question, is there something that can be added to list out the nested group members?
Thank you very much
This is great ! thanx a lot .
Thanks a lot...
Thanks It is simple and Sweet
Hi ,
i have a problem in windows .i have one remote server i am able connect that one using this .But after deploying that code in server i am unable to.please help me
Thanks,
Deepthi Immadi
Hi ,
i have a problem in windows .i have one remote server i am able connect that one using this .But after deploying that code in server i am unable to.please help me
Thanks,
Deepthi Immadi
thankss
Can you please share the link to download the code. I really need this code for me to fetch the data from 2000 servers.
Post a Comment