473,241 Members | 1,858 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,241 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 1844
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
    by: jianzs | last post by:
    Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
    0
    by: abbasky | last post by:
    ### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
    2
    isladogs
    by: isladogs | last post by:
    The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
    0
    by: fareedcanada | last post by:
    Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
    0
    Git
    by: egorbl4 | last post by:
    Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
    0
    by: MeoLessi9 | last post by:
    I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
    0
    by: DolphinDB | last post by:
    The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
    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
    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...

    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.