Export (0) Print
Expand All

AutodiscoverService.GetUserSettings method

EWS Managed API

Retrieves the specified user settings for an SMTP address.

Namespace:  Microsoft.Exchange.WebServices.Autodiscover
Assembly:  Microsoft.Exchange.WebServices (in Microsoft.Exchange.WebServices.dll)

'Declaration
PublicFunctionGetUserSettings ( _
	userSmtpAddressAsString, _
	ParamArrayuserSettingNamesAsUserSettingName() _
) AsGetUserSettingsResponse
'Usage
DiminstanceAsAutodiscoverServiceDimuserSmtpAddressAsStringDimuserSettingNamesAsUserSettingName()
DimreturnValueAsGetUserSettingsResponsereturnValue = instance.GetUserSettings(userSmtpAddress, _
	userSettingNames)

Parameters

userSmtpAddress
Type: System.String

The SMTP address of the user.

userSettingNames
Type: []

The user setting names.

Return value

Type: Microsoft.Exchange.WebServices.Autodiscover.GetUserSettingsResponse
The requested settings for the specified user.

The GetUserSettings method does not follow address and URL redirections. Only the requested user settings are retrieved, if they exist.

The following code example shows how to use the GetUserSettings method to retrieve the UserDisplayName, CasVersion, and other user settings requested in the userSettingNames parameter. The user setting name and value are displayed.

public static GetUserSettingsResponse GetUserSettings(
     AutodiscoverService service,
     string emailAddress,
     int maxHops,
     params UserSettingName[] settings)
     {
        Uri url = null;
        GetUserSettingsResponse response = null;

        for (int attempt = 0; attempt < maxHops; attempt++)
        {
             service.Url = url;
             service.EnableScpLookup = (attempt < 2);

             response = service.GetUserSettings(emailAddress, settings);

             if (response.ErrorCode == AutodiscoverErrorCode.RedirectAddress)
             {
                 url = new Uri(response.RedirectTarget);
             }
             else if (response.ErrorCode == AutodiscoverErrorCode.RedirectUrl)
             {
                url = new Uri(response.RedirectTarget);
             }
             else
             {
                 return response;
             }
         }

         throw new Exception("No suitable Autodiscover endpoint was found.");
     }

Show:
© 2014 Microsoft