Sunday, 15 April 2012

c# - Get Email Addresses From Exchange Given DirectoryEntry -



c# - Get Email Addresses From Exchange Given DirectoryEntry -

i'm looping through users in our advertisement environment, , reading email address can update in system. i'm using system.directoryservices library. simplified illustration below. i'm finding mail attribute not right , missing though user has valid mailbox setup , functional in exchange. so, question is, given directoryentry, there way list user's primary email address (and ideally aliases) exchange other reading mail attribute? i've seen examples utilize proxyaddresses attribute, these don't seem reliable either. looking solution comes straight exchange. no if-and-or-buts it. email address.

directorysearcher search = new directorysearcher("(&(mail=*))"); search.pagesize = 1000; search.propertiestoload.add("mail"); foreach( searchresult result in search.findall() ) { directoryentry entry = result.getdirectoryentry(); console.writeline(entry.properties["mail"].value); }

exchange doesn't have separate info store data. it's stored in ad. if collect info via exchange api (ews or powershell), you're getting same data. proxyaddresses attribute place in ad.

c# active-directory exchange-server-2007

No comments:

Post a Comment