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
- using System;
- namespace Active_Directory
- {
- /// <summary>
- /// Summary description for Class1.
- /// </summary>
- class Class1
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- System.DirectoryServices.DirectoryEntry entry =
- new
- System.DirectoryServices.DirectoryEntry(@"LDAP://DC=<rootdomain>");
- System.DirectoryServices.DirectorySearcher mySearcher = new
- System.DirectoryServices.DirectorySearcher(entry);
- mySearcher.Filter =
- "(&(objectClass=msExchAdminGroup)(objectCategory=ms-Exch-Admin-Group))";
- Console.WriteLine(mySearcher.FindAll().Count);
- }
- }
- }