I want to access via VB.Net the active directory.
I want to list all the users and groups in AD and, if it's possible, also the exchange mailbox of each users...
All users across all OU's in your AD ?? There could be many....
THis is C# - should be easy to convert to VB.NET - you'll need to use
the DirectorySearcher class:
DirectorySearcher oSrch = new DirectorySearcher("");
oSrch.Filter = "(&(objectClass=user)(objectCategory=user))";
oSrch.SearchScope = SearchScope.Subtree;
oSrch.PropertiesToLoad.Add("givenName");
oSrch.PropertiesToLoad.Add("sn");
oSrch.PropertiesToLoad.Add("mail");
foreach(SearchResult oRes in oSrch.FindAll())
{
Console.WriteLine("User: " +
oRes.Properties["givenName"].Value.ToString() + " " +
oRes.Properties["sn"].Value.ToString() + " / E-Mail: " +
oRes.Properties["mail"].Value.ToString();
}
It searches the directory, load the "givenName" and "sn" (Surname") as
well as "mail" (e-mail address) properties for the search results, and
loops through the results.
For groups, you'll just need to adjust the filter accordingly.
Marc