I have the following LDAP query which retrieves all of the email addresses associated with a domain, in Actve Directory. This works fine, however secondary email addresses are not detected, ie. a user might have 5 attached email addresses, but the primary one is only retrieved. How would I get all email addresses for each Active Directory object ( Users, Contact, Group etc..)???
System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry("LDAP://" + dom);System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);mySearcher.Filter = ("(objectClass=*)");foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll()){ try { System.DirectoryServices.DirectoryEntry de = resEnt.GetDirectoryEntry(); string emailaddress = de.Properties["Mail"].Value.ToString(); Console.WriteLine(emailaddress.ToString()); } catch (Exception ex) { }}
otherMailbox
I've added this however it does not show the other user mailbox addresses?