Exchange EWS: This is returning X500 address instead of valid attendee (smtp) email address.

Vineet Kumar 21 Reputation points
2022-04-19T07:50:34.667+00:00

Dear team,

While fetching attendee data from Exchange using EWS, for some user (for some clients), we are receiving X500 address instead of valid email address.

So, Please answer below queries:

1. How to replicate the same on our environment (ie how to get X500 address for adding this for exchange Email)?
2. How to handle this X500 Address ( ie steps to convert this X500 address into valid email address)?
3. How to Validate X500 Address ( ie to find whether this is valid X500 address or not)?
4. Is there any other property in response which can return valid Email Address?

Below is detail explanation:

1 How we are getting the X500 address?

We are not trying to fetch X500 address.
We are fetching meeting information from Exchange using EWS and retrieving Attendee information from response. But in response, for some users, we found X500 address instead of attendee email address, which is not valid email address.

2 What EWS request is used to get the X500 address?

We are using BeginSyncFolderItems and EndSyncFolderItems.

3 Steps to call EWS programatically:

a) Create object of ExchangeService.
List down other propeties ie PropertySet | FolderId | ObjectState
Url : https://outlook.office365.com/EWS/Exchange.asmx
Credentials will be OAuthCredentials (ie new OAuthCredentials(token))
ExchangeService ExchangeServiceProcessor = new ExchangeService();
Then we call BeginSyncFolderItems.
ExchangeServiceProcessor.BeginSyncFolderItems(,,,,,,,,)

b) Then in response, we fetch the services ie
var ExchangeServiceProcessor = ((dynamic)ObjAsyncResult.AsyncState).Service;
Then we call EndSyncFolderItems ie
ChangeCollection<ItemChange> ChangedAppointment = ExchangeServiceProcessor.EndSyncFolderItems(ObjAsyncResult);
Then we fetch the Itemid.

c) Then we call serviceResponse collection based on itemId ie
exchangeServiceProcessor.BindToItems(ListOfIdsToLoad, PropertiesToLoad);

d) Then we fetch the appointment with response ie
Appointment ConvertedAppointment = (Appointment)BindResponse.Item;
This will further provides us attendee ie appointment.OptionalAttendees | appointment.RequiredAttendees.
Here we have Microsoft.Exchange.WebServices.Data.EmailAddress object which have Name & Address values.

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
505 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,335 questions
{count} votes

Accepted answer
  1. Glen Scales 4,431 Reputation points
    2022-04-20T00:06:22.69+00:00

    Exchange always stores the Addresses for directory objects (eg things in the GAL) in the native EX Address (X500) address format. So the most common case you would see an EX address that doesn't get resolved which you use GetItem (or BindToItems) in you logic is where the directory object was deleted. Eg you have a recurring meeting that has attendees and one of those attendees leaves the company and the user account is deleted. If you want to reproduce this

    Create a Test account
    Create a meeting and invite that test account to that meeting so they are an attendee
    Delete the Test account and wait for the directory replication to happen.

    Try to retrieve the meeting you created, because the account nolonger exists it won't be able to resolve the EX Address to SMTP so you will just get the EX Address back.

    The other cause I've see for this is when mailboxes are migrated using third party products that don't do the address translation correctly.

    How to handle this X500 Address ( ie steps to convert this X500 address into valid email address)?

    If the address exists in the GAL then resolvename should be able to resolve it to the SMTP address https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-resolve-ambiguous-names-by-using-ews-in-exchange-2013 (where this won't work if the directory object is hidden from the GAL).

    How to Validate X500 Address ( ie to find whether this is valid X500 address or not)?

    ResolveName should be able to do that or a Directory lookup of the proxyaddresses (eg use the Graph)

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Vineet Kumar 21 Reputation points
    2022-04-24T17:30:44.92+00:00

    Thanks @Glen Scales for reply.

    We are not able to create X500 address format.
    Using some logging, we found that this returns LegacyExchangeDN, and LegacyExchangeDN can be resloved with ResolveName.

    Please have a look on below points and suggest:

    1. How to create X500 address using Exchange Admin Center?
    2. Can you please provide me something (may be powershell command) to create/fetch X500 address?
      3.We have written the code to resolve the email address if X.500 string comes but we want to replicate it on our end.
      For that we extracted LegacyExchangeDN using powershell command (Get-Mailbox -Identity user@keyman .onmicrosoft.com | ft legacyExchangeDN). After that we added the LegacyExchangeDN value in user’s new email address like in the screen shot below. This user already as SMTP address added which we are not able to delete.
      ![196061-microsoftteams-image.png
      But still, we are getting the user’s SMTP address when we try to fetch the Event’s attendee information.
      How we can get new X.500 value that we added?
      4.Three days ago, We delete the user from exchange but still we are able to fetch below json informations from Exchange ie
      "{\r\n \"ResponseType\": 0,\r\n \"LastResponseTime\": null,\r\n \"Name\": \"deleteuser@o3651.domain.com\",\r\n \"Address\": \"deleteuser@o3651.domain.com\",\r\n \"RoutingType\": \"SMTP\",\r\n \"MailboxType\": 1,\r\n \"Id\": null\r\n}"
      Am i missing something?
    3. Any third party product to give info about X500 address?

    Please suggest.


  2. Vineet Kumar 21 Reputation points
    2022-05-24T07:46:35.1+00:00

    Thanks @Glen Scales .
    We are not able to replicate this but using exchangeService.ResolveName, we are able to fix this.

    If anything else come out, then i will be back to you again.

    Again big thanks to you for your prompt reply.

    0 comments No comments