private void InternalPerformLiveIdAuthentication(out bool success, out LiveIdAuthenticationError error, out string iisLogs, out TimeSpan latency)
        {
            int             num           = 1009;
            string          uri           = string.Format("net.tcp://{0}:{1}/Microsoft.Exchange.Security.Authentication.FederatedAuthService", this.Server.ToString(), num);
            NetTcpBinding   binding       = new NetTcpBinding(SecurityMode.Transport);
            EndpointAddress remoteAddress = new EndpointAddress(uri);

            using (AuthServiceClient authServiceClient = new AuthServiceClient(binding, remoteAddress))
            {
                error = LiveIdAuthenticationError.None;
                byte[]    bytes     = Encoding.Default.GetBytes(this.MailboxCredential.UserName);
                byte[]    bytes2    = Encoding.Default.GetBytes(this.ConvertToUnsecureString(this.MailboxCredential.Password));
                Stopwatch stopwatch = Stopwatch.StartNew();
                try
                {
                    TestFailoverFlags testFailoverFlags;
                    if (this.TestFailOver == FailoverFlags.Random)
                    {
                        if (!this.PreferOfflineAuth)
                        {
                            TestFailoverFlags[] array;
                            if (this.UserType == LiveIdAuthenticationUserTypeEnum.ManagedConsumer)
                            {
                                array = new TestFailoverFlags[]
                                {
                                    TestFailoverFlags.HRDRequest,
                                    TestFailoverFlags.HRDResponse,
                                    TestFailoverFlags.LiveIdRequest,
                                    TestFailoverFlags.LiveIdResponse,
                                    TestFailoverFlags.OrgIdRequest,
                                    TestFailoverFlags.OrgIdResponse,
                                    TestFailoverFlags.HRDRequestTimeout,
                                    TestFailoverFlags.LiveIdRequestTimeout,
                                    TestFailoverFlags.OrgIdRequestTimeout
                                };
                            }
                            else
                            {
                                array = new TestFailoverFlags[]
                                {
                                    TestFailoverFlags.HRDRequest,
                                    TestFailoverFlags.HRDResponse,
                                    TestFailoverFlags.OrgIdRequest,
                                    TestFailoverFlags.OrgIdResponse,
                                    TestFailoverFlags.HRDRequestTimeout,
                                    TestFailoverFlags.OrgIdRequestTimeout
                                };
                            }
                            testFailoverFlags = array[new Random().Next(0, array.Length)];
                        }
                        else
                        {
                            TestFailoverFlags[] array2;
                            if (this.UserType == LiveIdAuthenticationUserTypeEnum.ManagedConsumer)
                            {
                                array2 = new TestFailoverFlags[]
                                {
                                    TestFailoverFlags.OfflineHRD,
                                    TestFailoverFlags.OfflineAuthentication,
                                    TestFailoverFlags.LowPasswordConfidence,
                                    TestFailoverFlags.LiveIdRequest,
                                    TestFailoverFlags.LiveIdResponse
                                };
                            }
                            else
                            {
                                array2 = new TestFailoverFlags[]
                                {
                                    TestFailoverFlags.OfflineHRD,
                                    TestFailoverFlags.OfflineAuthentication,
                                    TestFailoverFlags.LowPasswordConfidence
                                };
                            }
                            testFailoverFlags = array2[new Random().Next(0, array2.Length)];
                        }
                    }
                    else
                    {
                        testFailoverFlags = (TestFailoverFlags)this.TestFailOver;
                    }
                    AuthOptions authOptions = AuthOptions.SyncAD;
                    if (this.TestLegacyAPI)
                    {
                        authOptions |= AuthOptions.ReturnWindowsIdentity;
                    }
                    if (this.SyncADBackendOnly)
                    {
                        authOptions |= AuthOptions.SyncADBackEndOnly;
                    }
                    if (this.LiveIdXmlAuth)
                    {
                        authOptions |= AuthOptions.LiveIdXmlAuth;
                    }
                    string     text;
                    AuthStatus authStatus = authServiceClient.LogonCommonAccessTokenFederationCredsTest(uint.MaxValue, bytes, bytes2, authOptions, null, null, null, null, Guid.NewGuid(), new bool?(this.PreferOfflineAuth), testFailoverFlags, out text, out iisLogs);
                    if (this.TestFailOver != FailoverFlags.None)
                    {
                        iisLogs = testFailoverFlags.ToString() + "." + iisLogs;
                    }
                    error = ((authStatus == AuthStatus.LogonSuccess) ? LiveIdAuthenticationError.None : LiveIdAuthenticationError.LoginFailure);
                    if (this.IgnoreLowPasswordConfidence && iisLogs != null && iisLogs.IndexOf("low confidence") > 0)
                    {
                        error = LiveIdAuthenticationError.None;
                    }
                }
                catch (CommunicationException ex)
                {
                    iisLogs = ex.Message;
                    error   = LiveIdAuthenticationError.CommunicationException;
                }
                catch (InvalidOperationException ex2)
                {
                    iisLogs = ex2.Message;
                    error   = LiveIdAuthenticationError.InvalidOperationException;
                }
                catch (Exception ex3)
                {
                    iisLogs = ex3.Message;
                    error   = LiveIdAuthenticationError.OtherException;
                }
                stopwatch.Stop();
                success = (error == LiveIdAuthenticationError.None);
                latency = stopwatch.Elapsed;
            }
        }