GetAutodiscoverUrlWithExchangeVersionAndCallback method
Future<Uri>
GetAutodiscoverUrlWithExchangeVersionAndCallback(
- String emailAddress,
- ExchangeVersion requestedServerVersion,
- AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback
Implementation
Future<Uri> GetAutodiscoverUrlWithExchangeVersionAndCallback(
String emailAddress,
ExchangeVersion requestedServerVersion,
AutodiscoverRedirectionUrlValidationCallback
validateRedirectionUrlCallback) async {
AutodiscoverService autodiscoverService =
new AutodiscoverService.withExchangeServiceAndExchangeVersion(
this, requestedServerVersion)
..RedirectionUrlValidationCallback = validateRedirectionUrlCallback
..EnableScpLookup = this.EnableScpLookup;
GetUserSettingsResponse response =
await autodiscoverService.GetUserSettingsWithSmtpAddress(emailAddress,
[UserSettingName.InternalEwsUrl, UserSettingName.ExternalEwsUrl]);
switch (response.ErrorCode) {
case AutodiscoverErrorCode.NoError:
return this
.GetEwsUrlFromResponse(response, autodiscoverService.IsExternal);
case AutodiscoverErrorCode.InvalidUser:
throw new ServiceRemoteException("InvalidUser($emailAddress)");
case AutodiscoverErrorCode.InvalidRequest:
throw new ServiceRemoteException(
"InvalidAutodiscoverRequest(${response.ErrorMessage}");
default:
this.TraceMessage(enumerations.TraceFlags.AutodiscoverConfiguration,
"No EWS Url returned for user $emailAddress, error code is ${response.ErrorCode}");
throw new ServiceRemoteException(response.ErrorMessage!);
}
}