473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

List the users

I want my program to create a list of every user in the domain that is part
of a special group. Any ideas?
Nov 16 '05 #1
4 1525
Check out the DirectoryServices Namespace.
You'll need to include a reference to System.DirectoryServices.dll in your project first.
Nov 16 '05 #2
>I want my program to create a list of every user in the domain that is part
of a special group. Any ideas?


Check out System.DirectoryServices - bind to the group in question,
and enumerate its "member" property:

DirectoryEntry deGroup = new
DirectoryEntry("LDAP://cn=YourGroup,ou=YourOU,dc=YourCOmpany,dc=com");

foreach(object oMember in deGroup.Properties["member"])
{
Console.WriteLine(oMember.ToString());
}

This should give you the list of group members, in "DN" format, e.g.

cn=Joe User,ou=YourOU,dc=YourCOmpany,dc=com
cn=Jane User,ou=YourOU,dc=YourCOmpany,dc=com
cn=Jimmy Userr,ou=YourOU2,dc=YourCOmpany,dc=com
cn=Tammy Userr,ou=YourOU2,dc=YourCOmpany,dc=com
........

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 16 '05 #3
Marc Scheuner [MVP ADSI] <m.********@inova.SPAMBEGONE.ch> wrote in
news:91********************************@4ax.com:
I want my program to create a list of every user in the domain that is
part of a special group. Any ideas?


Check out System.DirectoryServices - bind to the group in question,
and enumerate its "member" property:

DirectoryEntry deGroup = new
DirectoryEntry("LDAP://cn=YourGroup,ou=YourOU,dc=YourCOmpany,dc=com");

foreach(object oMember in deGroup.Properties["member"])
{
Console.WriteLine(oMember.ToString());
}

This should give you the list of group members, in "DN" format, e.g.

cn=Joe User,ou=YourOU,dc=YourCOmpany,dc=com
cn=Jane User,ou=YourOU,dc=YourCOmpany,dc=com
cn=Jimmy Userr,ou=YourOU2,dc=YourCOmpany,dc=com
cn=Tammy Userr,ou=YourOU2,dc=YourCOmpany,dc=com
.......

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch


How do I know what ou and dc to use? Where do I find that information?

As you might have figured out, I'm new to Active Directory and LDAP, so
if you have any good references on the net that might explain the
basics...
Nov 16 '05 #4
>How do I know what ou and dc to use?

No - how could I - that's *YOUR* directory! ;-)
Where do I find that information?


In the directory, silly ;-) But I agree - it can be a bit tricky to
find these things, if you don't know what they are.

Suggestion: download one of my ADSI browsers, they should give you an
idea of what your directory is, and what kind of OU's and DC's you
have.

http://adsi.mvps.org/adsi/Delphi/adsibrowser.html
http://adsi.mvps.org/adsi/CSharp/beavertail.html

Enjoy!

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thomas Heller | last post by:
I have created a py2exe mailing list. This list should be used to ask for help using py2exe, and to suggest and discuss new features or other changes to py2exe. The list is public, posting is...
4
by: David | last post by:
I am creating a web community site where each user can have a list of buddies. I have struck a bit of a problem though. I am designing my db model and have two entities called users containing...
0
by: Bart Lateur | last post by:
This seems so basic, but the common browsers (in particular Firefox and MSIE on Windows) succeed to mess it up. The basic HTML is this: <!-- an image floating on the left --> <img...
2
by: TK | last post by:
How can I show a list of OS users and groups in an ASP.NET page? Is there MSDN or SDK articles? please help. TK
5
by: kpp9c | last post by:
I have a several list of songs that i pick from, lets, say that there are 10 songs in each list and there are 2 lists. For a time i pick from my songs, but i only play a few of the songs in that...
3
by: idletask | last post by:
I have an application that has many windows. One window is used for order processing. I would like this window to display the other users who are also performing order processing (the idea is to...
2
by: Lysander | last post by:
I have not seen this feature documented before, so I thought I would share it with you, as I will be using it in a later article. For a combo or list box, the source data is normally a...
30
ADezii
by: ADezii | last post by:
For this Tip, we will show you an extremely handy, multi-user, feature of Jet that allows you to manage Users more effectively. You can create a special, provider-specific Recordset in ADO that...
27
by: Mark | last post by:
Hi all, I have a scenario where I have a list like this: User Score 1 0 1 1 1 5 2 3 2 1
14
by: shapper | last post by:
Hello, I am creating a list as follows: list<person>users = (from p in database.Users); I get an error on list saying: "a get or set accessor expected" What am I doing wrong? Thanks,
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.