473,395 Members | 1,856 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,395 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 1853
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: Charles Arthur | last post by:
    How do i turn on java script on a villaon, callus and itel keypad mobile phone
    0
    by: ryjfgjl | last post by:
    In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
    0
    BarryA
    by: BarryA | last post by:
    What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
    1
    by: nemocccc | last post by:
    hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
    1
    by: Sonnysonu | last post by:
    This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
    0
    marktang
    by: marktang | last post by:
    ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
    0
    by: Hystou | last post by:
    Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
    0
    by: Hystou | last post by:
    Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
    0
    tracyyun
    by: tracyyun | last post by:
    Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

    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.