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)
public GetUserSettingsResponse GetUserSettings( string userSmtpAddress, params UserSettingName[] 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.GetUserSettingsResponseThe requested settings for the specified user.
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: