AutodiscoverService.GetUserSettings method

Retrieves the specified user settings for an SMTP address.

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

'Declaration
Public Function GetUserSettings ( _
	userSmtpAddress As String, _
	ParamArray userSettingNames As UserSettingName() _
) As GetUserSettingsResponse
'Usage
Dim instance As AutodiscoverService
Dim userSmtpAddress As String
Dim userSettingNames As UserSettingName()
Dim returnValue As GetUserSettingsResponse

returnValue = 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: