コード例 #1
0
        internal static NetworkCredential GetDefaultTestAccount(TestLiveIdAuthenticationTask.ClientAccessContext context, LiveIdAuthenticationUserTypeEnum userType)
        {
            SmtpAddress?defaultTestUser = null;

            if (!TestConnectivityCredentialsManager.IsExchangeMultiTenant())
            {
                throw new InvalidOperationException();
            }
            if (userType <= LiveIdAuthenticationUserTypeEnum.ManagedBusiness)
            {
                if (userType != LiveIdAuthenticationUserTypeEnum.ManagedConsumer)
                {
                    if (userType == LiveIdAuthenticationUserTypeEnum.ManagedBusiness)
                    {
                        defaultTestUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(context.Instance, context.ConfigurationSession, context.Site, DatacenterUserType.BPOS);
                    }
                }
                else
                {
                    defaultTestUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(context.Instance, context.ConfigurationSession, context.Site, DatacenterUserType.EDU);
                }
            }
            else if (userType == LiveIdAuthenticationUserTypeEnum.FederatedConsumer || userType == LiveIdAuthenticationUserTypeEnum.FederatedBusiness)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(), null);
            }
            if (defaultTestUser == null)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(), null);
            }
            MailboxIdParameter localMailboxId = new MailboxIdParameter(string.Format("{0}", defaultTestUser.Value.Local));
            ADUser             aduser         = TestLiveIdAuthenticationTask.EnsureSingleObject <ADUser>(() => localMailboxId.GetObjects <ADUser>(null, TestLiveIdAuthenticationTask.GetRecipientSession(defaultTestUser.GetValueOrDefault().Domain)));

            if (aduser == null)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(defaultTestUser.ToString()), null);
            }
            ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(aduser.OrganizationId.ToADSessionSettings(), aduser);

            if (exchangePrincipal == null)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(defaultTestUser.ToString()), null);
            }
            NetworkCredential  networkCredential  = new NetworkCredential(defaultTestUser.Value.ToString(), string.Empty, context.WindowsDomain);
            NetworkCredential  networkCredential2 = TestLiveIdAuthenticationTask.MakeCasCredential(networkCredential);
            LocalizedException ex = TestConnectivityCredentialsManager.LoadAutomatedTestCasConnectivityInfo(exchangePrincipal, networkCredential2);

            if (ex != null)
            {
                throw ex;
            }
            networkCredential.Domain   = defaultTestUser.Value.Domain;
            networkCredential.Password = networkCredential2.Password;
            return(networkCredential);
        }
コード例 #2
0
        internal static UserWithCredential GetDefaultTestAccount(CommonTestTasks.ClientAccessContext context)
        {
            SmtpAddress?smtpAddress;

            if (TestConnectivityCredentialsManager.IsExchangeMultiTenant())
            {
                smtpAddress = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(context.Instance, context.ConfigurationSession, context.Site);
            }
            else
            {
                smtpAddress = TestConnectivityCredentialsManager.GetEnterpriseAutomatedTaskUser(context.Site, context.WindowsDomain);
            }
            if (smtpAddress == null)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(), null);
            }
            MailboxIdParameter localMailboxId = new MailboxIdParameter(string.Format("{0}\\{1}", smtpAddress.Value.Domain, smtpAddress.Value.Local));
            ADUser             aduser         = CommonTestTasks.EnsureSingleObject <ADUser>(() => localMailboxId.GetObjects <ADUser>(null, context.RecipientSession));

            if (aduser == null)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(smtpAddress.ToString()), null);
            }
            ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(aduser, null);

            if (exchangePrincipal == null)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(smtpAddress.ToString()), null);
            }
            NetworkCredential networkCredential  = new NetworkCredential(smtpAddress.Value.ToString(), string.Empty, context.WindowsDomain);
            NetworkCredential networkCredential2 = CommonTestTasks.MakeCasCredential(networkCredential);
            bool flag = false;
            LocalizedException ex;

            if (Datacenter.IsLiveIDForExchangeLogin(true) || context.MonitoringContext)
            {
                ex = TestConnectivityCredentialsManager.LoadAutomatedTestCasConnectivityInfo(exchangePrincipal, networkCredential2);
            }
            else
            {
                ex = TestConnectivityCredentialsManager.ResetAutomatedCredentialsAndVerify(exchangePrincipal, networkCredential2, false, out flag);
            }
            if (ex != null)
            {
                throw ex;
            }
            networkCredential.Domain   = smtpAddress.Value.Domain;
            networkCredential.Password = networkCredential2.Password;
            return(new UserWithCredential
            {
                User = aduser,
                Credential = networkCredential
            });
        }
コード例 #3
0
        internal UmConnectivityCredentialsHelper(ADSite site, Server server)
        {
            UmConnectivityCredentialsHelper.DebugTrace("Inside UmConnectivityCredentialsHelper(). ADSite = {0}, Server = {1}", new object[]
            {
                site,
                server
            });
            SmtpAddress?enterpriseAutomatedTaskUser = TestConnectivityCredentialsManager.GetEnterpriseAutomatedTaskUser(site, server.Domain);

            this.userName = TestCasConnectivity.GetInstanceUserNameFromTestUser(enterpriseAutomatedTaskUser);
            this.domain   = server.Domain;
        }
コード例 #4
0
        private void PerformMonitoringServiceBasicCmdletTest(ref MonitoringServiceBasicCmdletOutcome result)
        {
            SmtpAddress?multiTenantAutomatedTaskUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(this, null, null, DatacenterUserType.EDU);

            if (multiTenantAutomatedTaskUser == null)
            {
                throw new MailboxNotFoundException(new MailboxIdParameter(), null);
            }
            result.Update(MonitoringServiceBasicCmdletResultEnum.Success, null);
            if (this.MonitoringContext)
            {
                this.monitoringData.Events.Add(new MonitoringEvent(TestMonitoringServiceBasicCmdletTask.CmdletMonitoringEventSource, 1000, EventTypeEnumeration.Success, string.Format("TestMonitoringServiceBasicCmdlet succeeded. Test user returned: [{0}]", multiTenantAutomatedTaskUser.ToString())));
            }
        }
コード例 #5
0
        private static bool FindPassword(ExchangePrincipal ep, NetworkCredential nc)
        {
            UmConnectivityCredentialsHelper.DebugTrace("Inside FindPassword()", new object[0]);
            LocalizedException ex = TestConnectivityCredentialsManager.LoadAutomatedTestCasConnectivityInfo(ep, nc);

            if (ex != null)
            {
                UmConnectivityCredentialsHelper.DebugTrace("Inside FindPassword(): TestConnectivityCredentialsManager.LoadAutomatedTestCasConnectivityInfo returned : {0}", new object[]
                {
                    ex.ToString()
                });
                return(false);
            }
            return(true);
        }
コード例 #6
0
        internal static bool ResetMailboxPassword(ExchangePrincipal ep, NetworkCredential nc)
        {
            UmConnectivityCredentialsHelper.DebugTrace("Inside UmConnectivityCredentialsHelper: ResetMailboxPassword", new object[0]);
            bool flag             = false;
            LocalizedException ex = TestConnectivityCredentialsManager.ResetAutomatedCredentialsAndVerify(ep, nc, false, out flag);

            if (ex != null)
            {
                UmConnectivityCredentialsHelper.DebugTrace("Inside ResetMailboxPassword(): TestConnectivityCredentialsManager.ResetAutomatedCredentialsAndVerify returned : {0} ", new object[]
                {
                    ex.ToString()
                });
                return(false);
            }
            return(true);
        }
コード例 #7
0
        private void PerformGlobalLocatorServiceTest(ref GlobalLocatorServiceOutcome result)
        {
            bool                      flag                      = true;
            string                    error                     = string.Empty;
            StringBuilder             stringBuilder             = new StringBuilder();
            GlobalLocatorServiceError globalLocatorServiceError = GlobalLocatorServiceError.None;
            Stopwatch                 stopwatch                 = Stopwatch.StartNew();

            try
            {
                SmtpAddress?multiTenantAutomatedTaskUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(this, this.SystemConfigurationSession, this.SystemConfigurationSession.GetLocalSite(), DatacenterUserType.EDU);
                if (multiTenantAutomatedTaskUser == null)
                {
                    throw new MailboxNotFoundException(new MailboxIdParameter(), null);
                }
                IGlobalLocatorServiceReader globalLocatorServiceReader = LocatorServiceClientReader.Create(GlsCallerId.Exchange);
                FindDomainResult            findDomainResult           = globalLocatorServiceReader.FindDomain(new SmtpDomain(multiTenantAutomatedTaskUser.Value.Domain), GlsDirectorySession.AllExoDomainProperties, GlsDirectorySession.AllExoTenantProperties);
                if (string.IsNullOrEmpty(findDomainResult.Domain))
                {
                    flag  = false;
                    error = "Domain not found";
                }
                else
                {
                    stringBuilder.AppendLine("Domain Found");
                }
            }
            catch (CommunicationException ex)
            {
                flag  = false;
                error = ex.Message;
                globalLocatorServiceError = GlobalLocatorServiceError.CommunicationException;
            }
            catch (Exception ex2)
            {
                flag  = false;
                error = ex2.Message;
                globalLocatorServiceError = GlobalLocatorServiceError.OtherException;
            }
            stopwatch.Stop();
            result.Update(flag ? GlobalLocatorServiceResultEnum.Success : GlobalLocatorServiceResultEnum.Failure, stopwatch.Elapsed, error, stringBuilder.ToString());
            if (this.MonitoringContext)
            {
                this.monitoringData.Events.Add(new MonitoringEvent(TestGlobalLocatorServiceTask.CmdletMonitoringEventSource, flag ? 1000 : 2000, flag ? EventTypeEnumeration.Success : EventTypeEnumeration.Error, flag ? Strings.GlobalLocatorServiceSuccess : (Strings.GlobalLocatorServiceFailed(error) + " " + globalLocatorServiceError)));
            }
        }
コード例 #8
0
 protected override void InternalValidate()
 {
     if (this.UserIdentity == null)
     {
         ADSite localSite = base.RootOrgGlobalConfigSession.GetLocalSite();
         string text;
         if (TestConnectivityCredentialsManager.IsExchangeMultiTenant())
         {
             SmtpAddress?multiTenantAutomatedTaskUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(this, base.RootOrgGlobalConfigSession, localSite);
             text = ((multiTenantAutomatedTaskUser != null) ? multiTenantAutomatedTaskUser.Value.ToString() : null);
         }
         else
         {
             SmtpAddress?enterpriseAutomatedTaskUser = TestConnectivityCredentialsManager.GetEnterpriseAutomatedTaskUser(localSite, "CasDomain.com");
             text = ((enterpriseAutomatedTaskUser != null) ? enterpriseAutomatedTaskUser.Value.Local : null);
         }
         if (text != null)
         {
             this.UserIdentity = new RecipientIdParameter(text);
             return;
         }
         base.ThrowTerminatingError(new NoDefaultTestAccountException(), (ErrorCategory)1003, null);
     }
 }