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

enumerate Users in Activedirectory group

Hi all,

I am able to read groups in the domain but not able to
read the members within each group. can somebody help?

here goes the code

DirectoryEntry m_obDirEntry=new DirectoryEntry
("LDAP://mydomain");
SearchResultCollection results;
DirectorySearcher srch = new DirectorySearcher
(m_obDirEntry);
srch.Filter = "(objectClass=Group)";
results = srch.FindAll();

foreach (SearchResult src in results)
{

ActiveDs.IADsGroup grp=(ActiveDs.IADsGroup)
(src.GetDirectoryEntry().NativeObject);
Response.Write(grp.Name+"<br>");

// from here i want to read the names of the members in
this group

}
Nov 18 '05 #1
3 4409
Shiv,

For any group you want to see the members of use "cn" (Common Name) for your
filter and one of the group names returned from your original query. Then
just repeat the query exactly as you've written the first one with the new
filter.

This will return all entries inside of the group.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"shiv" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
Hi all,

I am able to read groups in the domain but not able to
read the members within each group. can somebody help?

here goes the code

DirectoryEntry m_obDirEntry=new DirectoryEntry
("LDAP://mydomain");
SearchResultCollection results;
DirectorySearcher srch = new DirectorySearcher
(m_obDirEntry);
srch.Filter = "(objectClass=Group)";
results = srch.FindAll();

foreach (SearchResult src in results)
{

ActiveDs.IADsGroup grp=(ActiveDs.IADsGroup)
(src.GetDirectoryEntry().NativeObject);
Response.Write(grp.Name+"<br>");

// from here i want to read the names of the members in
this group

}

Nov 18 '05 #2
hi justin,

thanks for the reply. I tried to do that but failed to get
the results. here's what i did

after i get a ActiveDs.ISDSGroup,

I create one more directorySearcher giving the same
DirectoryEntry,
Filter it by filter=""(objectClass=Group)("+grp.Name+")"
where drp is ActiveDs.IsdsGroup.
and after looping through the results i get the same
results back. it seems the filter is not working. is the
filter string correct in my case?

thanks and regards
shiv
-----Original Message-----
Shiv,

For any group you want to see the members of use "cn" (Common Name) for yourfilter and one of the group names returned from your original query. Thenjust repeat the query exactly as you've written the first one with the newfilter.

This will return all entries inside of the group.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"shiv" <an*******@discussions.microsoft.com> wrote in messagenews:00****************************@phx.gbl...
Hi all,

I am able to read groups in the domain but not able to
read the members within each group. can somebody help?

here goes the code

DirectoryEntry m_obDirEntry=new DirectoryEntry
("LDAP://mydomain");
SearchResultCollection results;
DirectorySearcher srch = new DirectorySearcher
(m_obDirEntry);
srch.Filter = "(objectClass=Group)";
results = srch.FindAll();

foreach (SearchResult src in results)
{

ActiveDs.IADsGroup grp=(ActiveDs.IADsGroup)
(src.GetDirectoryEntry().NativeObject);
Response.Write(grp.Name+"<br>");

// from here i want to read the names of the members in
this group

}

.

Nov 18 '05 #3
Shiv,

At the second level your filter should not contain group at all. Just
"cn=[Main Group Name Returned From First Pull]"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"shiv" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
hi justin,

thanks for the reply. I tried to do that but failed to get
the results. here's what i did

after i get a ActiveDs.ISDSGroup,

I create one more directorySearcher giving the same
DirectoryEntry,
Filter it by filter=""(objectClass=Group)("+grp.Name+")"
where drp is ActiveDs.IsdsGroup.
and after looping through the results i get the same
results back. it seems the filter is not working. is the
filter string correct in my case?

thanks and regards
shiv
-----Original Message-----
Shiv,

For any group you want to see the members of use "cn"

(Common Name) for your
filter and one of the group names returned from your

original query. Then
just repeat the query exactly as you've written the first

one with the new
filter.

This will return all entries inside of the group.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"shiv" <an*******@discussions.microsoft.com> wrote in

message
news:00****************************@phx.gbl...
Hi all,

I am able to read groups in the domain but not able to
read the members within each group. can somebody help?

here goes the code

DirectoryEntry m_obDirEntry=new DirectoryEntry
("LDAP://mydomain");
SearchResultCollection results;
DirectorySearcher srch = new DirectorySearcher
(m_obDirEntry);
srch.Filter = "(objectClass=Group)";
results = srch.FindAll();

foreach (SearchResult src in results)
{

ActiveDs.IADsGroup grp=(ActiveDs.IADsGroup)
(src.GetDirectoryEntry().NativeObject);
Response.Write(grp.Name+"<br>");

// from here i want to read the names of the members in
this group

}

.

Nov 18 '05 #4

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

Similar topics

1
by: Kjell Wilhelmsen | last post by:
Hi ... I'm working on a program that's importing/exporting data between our Intranet and our ActiveDirectory and Exchange server. Does anybody out there know how to create a meeting in a users...
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
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 =...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
0
by: Morten Fagermoen | last post by:
Hi! I have a function that returns a System.Collections.Generic.List(Of String) of the users in a specified group. It seems to work fine with an exception of the Domain Users group. When I...
1
by: killbill | last post by:
Hi All, I am struggling with a problem, i want to add ActiveDirectory user to Global Security Group using C# and DirectoryServices. Any suggestiion ??? Thanks.
2
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
I'm trying to get a list of user accounts on the local computer - the same list you see when you are about to log in to Windows XP or Vista. This needs to work on a home computer (not connected to...
2
by: rote | last post by:
My sceanrio is this on an asp.net 2.0 freamework. I want to use any of the data controls e.g Gridview,DetailView etc.. But i want some buttons e.g update,edit save etc to be enable or disabled...
14
by: Naraendirakumar R.R. | last post by:
I have a client in the healthcare industry who would prefer to store the connection string in a centralized location in their Active Directory repository. Has anybody done this? What has your...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.