473,569 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Directory Query issue

Hi,

I am trying to enumerate Exchange Admin groups, but fail to with the
folowing code. Can someone help me with this issue.
The executing user has sufficient permissions.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2.  
  3. namespace Active_Directory
  4. {
  5. /// <summary>
  6. /// Summary description for Class1.
  7. /// </summary>
  8. class Class1
  9. {
  10. /// <summary>
  11. /// The main entry point for the application.
  12. /// </summary>
  13. [STAThread]
  14. static void Main(string[] args)
  15. {
  16. System.DirectoryServices.DirectoryEntry entry =
  17. new
  18. System.DirectoryServices.DirectoryEntry(@"LDAP://DC=<rootdomain>");
  19.  
  20. System.DirectoryServices.DirectorySearcher mySearcher = new
  21. System.DirectoryServices.DirectorySearcher(entry);
  22. mySearcher.Filter =
  23. "(&(objectClass=msExchAdminGroup)(objectCategory=ms-Exch-Admin-Group))";
  24. Console.WriteLine(mySearcher.FindAll().Count);
  25. }
  26. }
  27. }
  28.  
  29.  
Nov 17 '05 #1
3 2063
You need to iterate through the result collection..

akin to

mySearcher.Filt er =
"(&(objectClass =msExchAdminGro up)(objectCateg ory=ms-Exch-Admin-Group))";
foreach(System. DirectoryServic es.SearchResult result in
mySearcher.Find All())
{
Console.WriteLi ne( result.GetDirec toryEntry().Pat h );
}
Denis
"mpriem" <sp**@mpriem.co m> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Hi,

I am trying to enumerate Exchange Admin groups, but fail to with the
folowing code. Can someone help me with this issue.
The executing user has sufficient permissions.

Expand|Select|Wrap|Line Numbers
  1.  using System;
  2.  namespace Active_Directory
  3.  {
  4.  /// <summary>
  5.  /// Summary description for Class1.
  6.  /// </summary>
  7.  class Class1
  8.  {
  9.  /// <summary>
  10.  /// The main entry point for the application.
  11.  /// </summary>
  12.  [STAThread]
  13.  static void Main(string[] args)
  14.  {
  15.  System.DirectoryServices.DirectoryEntry entry =
  16.  new
  17.  System.DirectoryServices.DirectoryEntry(@"LDAP://DC=<rootdomain>");
  18.  System.DirectoryServices.DirectorySearcher mySearcher = new
  19.  System.DirectoryServices.DirectorySearcher(entry);
  20.  mySearcher.Filter =
  21.  "(&(objectClass=msExchAdminGroup)(objectCategory=ms-Exch-Admin-Group))";
  22.  Console.WriteLine(mySearcher.FindAll().Count);
  23.  }
  24.  }
  25.  }
  26.  

Nov 17 '05 #2
>I am trying to enumerate Exchange Admin groups, but fail to with the
folowing code. Can someone help me with this issue. DirectoryEnt ry entry = new DirectoryEntry( @"LDAP://DC=<rootdomain> ");


Can you spell out this LDAP path completely? What exactly is it? If
the DirEntry that you start off from is wrong, your search will never
work. You should try to use the "defaultNamingC ontext" from RootDSE
for your search, unless you have a clear reason NOT to use that as a
starting point.

--------------------------------
DirectoryEntry deRoot = new DirectoryEntry( "LDAP://RootDSE");

string sDefaultNamingC ontext =
deRoot.Properti es["defaultNamingC ontext"].Value.ToString ();

DirectoryEntry entry = new DirectoryEntry( "LDAP://" +
sDefaultNamingC ontext);

--------------------------------

Also, I've never successfully used the .Count property on the
collection returned by FindAll() - I'd just iterate over all the
entries to verify that you get anything back.

Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
Nov 17 '05 #3
Thanks Guys,

It works now. Even the .Count property. I thinks I messed up the DN.

Regards,

Mark

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 17 '05 #4

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

Similar topics

2
2133
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an issue with Active Directory. Our network consists of Windows-2000 Servers (SP 4) and Windows-2000 workstations and Windows-XP workstations. We...
1
4739
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I...
9
3166
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated Windows authentication. The error occurs on the FindAll method. The exceptions are as follows. anyway of getting the code working with Integrated...
3
2640
by: Adrian Parker | last post by:
At the moment, we have a simple user id / password entry screen to login to our website, the data credentials are held in our database. We've now been asked to integrate with active directory so that users on the lan who are already logged in via active directory no longer need to log into the website, but automatically are logged in using...
10
4039
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to Pop up windows Authentication box so that user will give his userId, Password & domain name for authenticaion. After that I want to take these...
3
11282
by: Lucky | last post by:
Hi guys, after long long time. i'm back again with another problem. this time i think the problem is very very interesting and i really need you help on this. i'm trying to connect to the Active Directory. for that i've added one linked server to connect to the active directory. and then query like this: adding linked server:
2
5955
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 use the System.DirectoryServices.ActiveDirectory namespace. I don't even know if this is the right way to go as I can't seem to find anything in that...
0
5403
by: Chung Leong | last post by:
In this brief tutorial I'll describe how you retrieve information from an Active Directory through the OLE-DB extension. While it is possible to use the LDAP extension to achieve the same goal, as you will see using Microsoft's OLE-DB provider is much easier. You will need to download and install the OLE-DB extension. Here's the location...
18
23766
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample code/examples? Thanks in advance, Arthur
3
1508
by: =?Utf-8?B?S2Fp?= | last post by:
Hi all, I need to access information from Active Directory from my ASP.net 2.0 application (vb.net). Therefore I made a DLL which retrieves the data from Active Directory. This works fine, all tests successfull. But when I call this DLL from my web application (currently installed on my local SQL Server) I always get an error message: ...
0
7698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7673
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.