internal static string ExecuteAnonymousLyncAutodiscoverRedirect(string requestUrl, int redirectCount) { string empty = string.Empty; if (redirectCount >= 10) { return(empty); } HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUrl); httpWebRequest.Accept = "application/vnd.microsoft.rtc.autodiscover+xml;v=1"; LyncAutodiscoverRequestState lyncAutodiscoverRequestState = new LyncAutodiscoverRequestState(); lyncAutodiscoverRequestState.Request = httpWebRequest; try { HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); if (httpWebResponse.StatusCode == HttpStatusCode.OK && LyncAutodiscoverWorker.GetAuthenticatedAutodiscoverEndpointFromHttpWebResponse(httpWebResponse, redirectCount, out empty)) { return(empty); } } catch (WebException) { } return(empty); }
internal static void ProcessLyncAnonymousAutodiscoverResponse(IAsyncResult asyncResult) { LyncAutodiscoverRequestState lyncAutodiscoverRequestState = (LyncAutodiscoverRequestState)asyncResult.AsyncState; HttpWebRequest request = lyncAutodiscoverRequestState.Request; if (request != null) { try { HttpWebResponse httpWebResponse = (HttpWebResponse)request.EndGetResponse(asyncResult); string targetUrl; if (httpWebResponse.StatusCode == HttpStatusCode.OK && LyncAutodiscoverWorker.GetAuthenticatedAutodiscoverEndpointFromHttpWebResponse(httpWebResponse, 0, out targetUrl)) { lyncAutodiscoverRequestState.TargetUrl = targetUrl; } } catch (WebException) { lyncAutodiscoverRequestState.TargetUrl = string.Empty; } LyncAutodiscoverWorker.allDone.Set(); } }