Condividi tramite


HOW TO: Read User Configuration for OWA in Exchange 2010 using EWS Managed API 1.0

The User Configuration operations enable clients to create, delete, retrieve, and update user configuration information. These operations are new in Exchange 2010.

Configuration data consists of groups of related application settings. Each group of settings is stored together in separate stream properties that are set on FAI messages. The OWA configuration its stored in IPM.Configuration.OWA.UserOptions which is also a FAI message in the NON_IPM_SUBTREE.

How do you get to the NON_IPM_SUBTREE?  NON_IPM_SUBTREE is the Parent folder of the root. Some of the properties that you can get are timezone, themeStorageId, autoaddsignature, signaturetext, navigationbarwidth, signaturehtml

Below is a piece of sample code that retrieves the User Configuration for OWA in Exchange 2010.

 using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Exchange.WebServices.Data;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Xml;
using System.Collections;
using System.Net;

namespace ReadUserConfigurationOWA
{
    class Program
    {
        static void Main(string[] args)
        {
            // Connect to Exchange Web Services
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);

           
            //Change the Credentials to suit you needs
            service.Credentials = new WebCredentials("user", "Password", "domain");

            
            //Use Autodiscover or Set the URL manually. Change the email address to match yours
            service.AutodiscoverUrl("user@domain.com");
 
            EnumUserConfig(service);
 
            Console.ReadLine();
        }


        static void EnumUserConfig(ExchangeService service)
        {
            Folder Root = Folder.Bind(service, WellKnownFolderName.Root);

            
            UserConfiguration OWAConfiguration = UserConfiguration.Bind(service, "OWA.UserOptions", Root.ParentFolderId, UserConfigurationProperties.All);

            
            IDictionaryEnumerator OWAEnum = (IDictionaryEnumerator)OWAConfiguration.Dictionary.GetEnumerator();

            
            while (OWAEnum.MoveNext())
            {
                Console.WriteLine("Key : " + OWAEnum.Key);
                Console.WriteLine("Value : " + OWAEnum.Value);
            }
        }
    }
}

Enjoy!