473,322 Members | 1,352 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,322 software developers and data experts.

Active directory: Get users associated with groups

Hi, can anyone please tell me (Given a group name) how I can retrieve just
those users associated with that group using Active Directory using LDAP??

I am using the code below with not much luck

Expand|Select|Wrap|Line Numbers
  1. DirectoryEntry entry = new DirectoryEntry("LDAP://" +
  2. Domain,"LoginUser","Password");
  3. DirectorySearcher Dsearch = new DirectorySearcher(entry);
  4. Dsearch.Filter = "objectCategory =All users"; // All users is a group in AD
  5.  
TIA
Mark

Jul 21 '05 #1
3 1848
Try using "LDAP://OU=All users,DC=Domain".

HTH, Jakob.
"Mark" wrote:
Hi, can anyone please tell me (Given a group name) how I can retrieve just
those users associated with that group using Active Directory using LDAP??

I am using the code below with not much luck

Expand|Select|Wrap|Line Numbers
  1.  DirectoryEntry entry = new DirectoryEntry("LDAP://" +
  2.  Domain,"LoginUser","Password");
  3.  DirectorySearcher Dsearch = new DirectorySearcher(entry);
  4.  Dsearch.Filter = "objectCategory =All users"; // All users is a group in AD
  5.  

TIA
Mark

Jul 21 '05 #2
Thanks Jakob, I will give this a try
Regards
Mark
"Jakob Christensen" <jc*@REMOVEpension.dk> wrote in message
news:08**********************************@microsof t.com...
Try using "LDAP://OU=All users,DC=Domain".

HTH, Jakob.
"Mark" wrote:
Hi, can anyone please tell me (Given a group name) how I can retrieve just those users associated with that group using Active Directory using LDAP??
I am using the code below with not much luck

Expand|Select|Wrap|Line Numbers
  1.  > DirectoryEntry entry = new DirectoryEntry("LDAP://" +
  2.  > Domain,"LoginUser","Password");
  3.  > DirectorySearcher Dsearch = new DirectorySearcher(entry);
  4.  > Dsearch.Filter = "objectCategory =All users"; // All users is a group in
  • AD
  •  > 

  • TIA
    Mark

    Jul 21 '05 #3
    >Hi, can anyone please tell me (Given a group name) how I can retrieve just
    those users associated with that group using Active Directory using LDAP??


    Insepect the user's "memberOf" property

    DirectoryEntry deUser = new DirectoryEntry("LDAP://......");

    foreach(string sGroupName in deUser.Properties["memberOf"])
    {
    Console.WriteLine(sGroupName);
    }

    This is the easy way of doing it - it will *NOT* show you the user's
    "primary group", nor any nested groups. For those you'd need to
    inspect the user object's "tokenGroups" attribute (which is a
    collection of SID's), and then resolve those SIDs to group names.

    Check out microsoft.public.adsi.general - there have been several
    posts on how to read the full group membership by means of
    "tokenGroups".

    HTH
    Marc

    ================================================== ==============
    Marc Scheuner May The Source Be With You!
    Berne, Switzerland m.scheuner -at- inova.ch
    Jul 21 '05 #4

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

    Similar topics

    4
    by: Frank_00001 | last post by:
    I'm going to need to get a list of users for an upcoming project and Active Directory seems to be a good place to get it. I'm trying to get the "Walkthrough: Viewing Local Directory Objects"...
    2
    by: John | last post by:
    Hi, can anyone please tell me (Given a group name) how I can retrieve just those users associated with that group using Active Directory using LDAP?? I am using the code below with not much luck...
    3
    by: Luis Esteban Valencia | last post by:
    Hello gusys, Is it possible to make my asp.net application add users to the AD , I also want to be able to delete users, modify their information, everything through a website. Thanks for the...
    1
    by: tangus via DotNetMonster.com | last post by:
    Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
    4
    by: Patrick.O.Ige | last post by:
    If i want to generate a menu structure depending on who is logged in in an intranet system(using windows authentication) is it better to use the GROUPS in Active Directory or to move the Active...
    2
    by: Jm | last post by:
    Hi All Im not sure of which way to go about this so ill start by explaining what im trying to do and the options ive come up with. ok.. I have a client program which talks to an sql server...
    3
    by: Mark | last post by:
    Hi, can anyone please tell me (Given a group name) how I can retrieve just those users associated with that group using Active Directory using LDAP?? I am using the code below with not much luck...
    4
    by: cpajoe2001 | last post by:
    I am not sure if this is the proper place to put this thread but I have run into a road block. I am writing a web app that will create groups in Active Directory then add users to those groups. I...
    0
    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...
    0
    by: ArrayDB | last post by:
    The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
    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
    by: Faith0G | last post by:
    I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
    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.