473,326 Members | 2,588 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,326 software developers and data experts.

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 2056
You need to iterate through the result collection..

akin to

mySearcher.Filter =
"(&(objectClass=msExchAdminGroup)(objectCategory=m s-Exch-Admin-Group))";
foreach(System.DirectoryServices.SearchResult result in
mySearcher.FindAll())
{
Console.WriteLine( result.GetDirectoryEntry().Path );
}
Denis
"mpriem" <sp**@mpriem.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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. DirectoryEntry 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 "defaultNamingContext" 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 sDefaultNamingContext =
deRoot.Properties["defaultNamingContext"].Value.ToString();

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

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

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
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...
1
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...
9
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...
3
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...
10
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...
3
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...
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: 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...
18
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...
3
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...
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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....

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.