Getting user configuration objects by using the EWS Managed API 2.0

Last modified: February 06, 2014

Applies to: EWS Managed APIĀ | Exchange Server 2010

Note: This content applies to the EWS Managed API 2.0 and earlier versions. For the latest information about the EWS Managed API, see Web services in Exchange.

You can use the Exchange Web Services (EWS) Managed API to get user configuration objects on folders in an Exchange mailbox.

Note

The user configuration objects feature is available in versions of Exchange starting with Exchange Server 2010.

Example

The following example shows how to get a user configuration object named "MyCustomSettingName" on the Inbox folder. This example assumes that the XML and binary data are strings.

static void GetUserConfiguration(ExchangeService service)
{
   // Bind to a user configuration object. This results in a call to EWS.
   UserConfiguration usrConfig = UserConfiguration.Bind(service,
                                                        "MyCustomSettingName",
                                                        WellKnownFolderName.Inbox,
                                                        UserConfigurationProperties.All);
   // Display the returned property values.
   Console.WriteLine("User Config Identifier: " + usrConfig.ItemId.UniqueId);
   Console.WriteLine("XmlData: " + Encoding.UTF8.GetString(usrConfig.XmlData));
   Console.WriteLine("BinaryData: " + Encoding.UTF8.GetString(usrConfig.BinaryData));
}
Sub GetUserConfiguration(ByVal service As ExchangeService)

  ' Binds to an user configuration object. Results in a call to EWS.
  Dim configuration As UserConfiguration = UserConfiguration.Bind(service, _
                                                                  "MyCustomSettingName", _
                                                                  WellKnownFolderName.Inbox, _
                                                                  UserConfigurationProperties.All)

  Console.WriteLine(("User Config Identifier: " & configuration.ItemId.UniqueId))
  Console.WriteLine(("XmlData: " & Encoding.UTF8.GetString(configuration.XmlData)))
  Console.WriteLine(("BinaryData: " & Encoding.UTF8.GetString(configuration.BinaryData)))
End Sub

Compiling the code

For information about compiling this code, see Getting started with the EWS Managed API 2.0.

Robust programming

  • Write appropriate error handling code for common search errors.

  • Review the client request XML that is sent to the Exchange server.

  • Review the server response XML that is sent from the Exchange server.

  • Set the service binding as shown in Setting the Exchange service URL by using the EWS Managed API 2.0. Do not hard code URLs because if mailboxes move, they might be serviced by a different Client Access server. If the client cannot connect to the service, retry setting the binding by using the AutodiscoverUrl(String) method.

  • Set the target Exchange Web Services schema version by setting the requestedServerVersion parameter of the ExchangeService constructor. For more information, see Versioning EWS requests by using the EWS Managed API 2.0.

Security

  • Use HTTP with SSL for all communication between client and server.

  • Always validate the server certificate that is used for establishing the SSL connections. For more information, see Validating X509 certificates by using the EWS Managed API 2.0.

  • Do not include user names and passwords in trace files.

  • Verify that Autodiscover lookups that use HTTP GET to find an endpoint always prompt for user confirmation; otherwise, they should be blocked.