Exemplo n.º 1
0
        public static NspiPrincipal FromUserSid(SecurityIdentifier sid, string userDomain)
        {
            NspiPrincipal principal = null;

            if (!string.IsNullOrEmpty(userDomain))
            {
                MiniRecipient miniRecipient = NspiPrincipal.FindMiniRecipientBySid(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(userDomain), sid);
                if (miniRecipient != null)
                {
                    principal = new NspiPrincipal(miniRecipient);
                }
            }
            else if (Configuration.IsDatacenter)
            {
                ExTraceGlobals.NspiTracer.TraceWarning <SecurityIdentifier>(0L, "We have to do a fan out query for user {0} because of legacy client.", sid);
                DirectoryHelper.DoAdCallAndTranslateExceptions(delegate
                {
                    MiniRecipient miniRecipientFromUserId = PartitionDataAggregator.GetMiniRecipientFromUserId(sid);
                    if (miniRecipientFromUserId != null)
                    {
                        principal = new NspiPrincipal(miniRecipientFromUserId);
                    }
                }, "ADAccountPartitionLocator::GetAllAccountPartitionIds");
            }
            else
            {
                principal = NspiPrincipal.FromUserSid(ADSessionSettings.FromRootOrgScopeSet(), sid);
            }
            return(principal ?? new NspiPrincipal(sid));
        }
        public void ReloadPrincipal()
        {
            string      text        = this.currentExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
            SmtpAddress smtpAddress = new SmtpAddress(text);

            this.currentExchangePrincipal = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(smtpAddress.Domain), text);
        }
Exemplo n.º 3
0
            public UserResolver(string userId, string orgId)
            {
                this.userId = userId;
                ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(orgId);

                this.session = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.PartiallyConsistent, null, sessionSettings, ConfigScopes.TenantSubTree, 1127, ".ctor", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ConfigurationSettings\\SettingOverrideSync.cs");
            }
Exemplo n.º 4
0
        private static bool TryGetADRecipient(Trace tracer, ADRecipientCache <TransportMiniRecipient> recipientCache, MailRecipient mailRecipient, out ADRecipient recipient)
        {
            recipient = null;
            ProxyAddress           proxyAddress   = new SmtpProxyAddress((string)mailRecipient.Email, true);
            TransportMiniRecipient recipientEntry = recipientCache.FindAndCacheRecipient(proxyAddress).Data;

            if (recipientEntry == null)
            {
                tracer.TraceWarning <RoutingAddress>(0L, "Could not find recipient entry for {0}", mailRecipient.Email);
                return(false);
            }
            ADRecipient tempRecipient = null;

            ADNotificationAdapter.TryRunADOperation(delegate()
            {
                SmtpAddress smtpAddress           = new SmtpAddress(proxyAddress.AddressString);
                ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(smtpAddress.Domain);
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, LcidMapper.DefaultLcid, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 178, "TryGetADRecipient", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\agents\\UM\\UMAgentUtil.cs");
                tempRecipient = tenantOrRootOrgRecipientSession.Read(recipientEntry.Id);
            });
            if (tempRecipient == null)
            {
                tracer.TraceWarning <ADObjectId>(0L, "Could not read recipient object for {0}", recipientEntry.Id);
                return(false);
            }
            recipient = tempRecipient;
            return(true);
        }
 // Token: 0x06000011 RID: 17 RVA: 0x000024D8 File Offset: 0x000006D8
 private static MailboxConnectivity CheckMailboxConnectivity(MailboxConnectivity mailboxConnectivity)
 {
     try
     {
         mailboxConnectivity.Message = "Getting ADSessionSettings";
         ADSessionSettings adsessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(mailboxConnectivity.TenantAcceptedDomain);
         if (adsessionSettings == null)
         {
             mailboxConnectivity.Message = "ADSessionSettings were not found.";
             return(mailboxConnectivity);
         }
         mailboxConnectivity.Message = "Creating IRecipientSession";
         IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, adsessionSettings, 223, "CheckMailboxConnectivity", "f:\\15.00.1497\\sources\\dev\\Management\\src\\ServiceHost\\Servicelets\\AuditLogSearch\\Program\\AuditLogSearchHealthHandler.cs");
         if (tenantOrRootOrgRecipientSession == null)
         {
             mailboxConnectivity.Message = "IRecipientSession was not found.";
             return(mailboxConnectivity);
         }
         bool   flag = mailboxConnectivity.ExchangeUserId.CompareTo(Guid.Empty) == 0;
         ADUser aduser;
         if (flag)
         {
             mailboxConnectivity.Message = "Getting OrganizationId";
             OrganizationId organizationId = OrganizationId.FromAcceptedDomain(mailboxConnectivity.TenantAcceptedDomain);
             mailboxConnectivity.Message = "Finding arbitration mailbox";
             aduser = AdminAuditLogHelper.GetTenantArbitrationMailbox(organizationId);
             mailboxConnectivity.ExchangeUserId = aduser.ExchangeGuid;
         }
         else
         {
             mailboxConnectivity.Message = "Finding ADRecipient";
             ADRecipient adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuidIncludingAlternate(mailboxConnectivity.ExchangeUserId);
             aduser = (adrecipient as ADUser);
         }
         if (aduser == null)
         {
             mailboxConnectivity.Message = "ADUser was not found.";
             return(mailboxConnectivity);
         }
         mailboxConnectivity.Message = "Getting ExchangePrincipal";
         ExchangePrincipal principal = ExchangePrincipal.FromADUser(aduser, null);
         mailboxConnectivity.Message = "Creating EwsAuditClient";
         EwsAuditClient client = new EwsAuditClient(new EwsConnectionManager(principal, OpenAsAdminOrSystemServiceBudgetTypeType.Default, ExTraceGlobals.ServiceletTracer), TimeSpan.FromSeconds(5.0), ExTraceGlobals.ServiceletTracer);
         mailboxConnectivity.Message = "Checking connectivity";
         AuditLogSearchHealthHandler.CheckMailboxConnectivity(client, false);
         mailboxConnectivity.Message = "Checking connectivity (archive)";
         AuditLogSearchHealthHandler.CheckMailboxConnectivity(client, true);
         mailboxConnectivity.Message = "Ok";
         mailboxConnectivity.Success = true;
     }
     catch (Exception ex)
     {
         mailboxConnectivity.Message  += " FAILED.";
         mailboxConnectivity.Exception = ex.ToString();
     }
     return(mailboxConnectivity);
 }
Exemplo n.º 6
0
 public User FindByExchangeGuidIncludingAlternate(Guid exchangeGuid, string tenantDomain, IRoutingDiagnostics diagnostics)
 {
     return(this.Execute <User>(delegate
     {
         ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(tenantDomain);
         IRecipientSession tenantOrRootOrgRecipientSession = this.directorySessionFactoryInstance.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 64, "FindByExchangeGuidIncludingAlternate", "f:\\15.00.1497\\sources\\dev\\cafe\\src\\Routing\\Providers\\ActiveDirectoryUserProvider.cs");
         ADRawEntry rawEntry = ActiveDirectoryUserProvider.FindByExchangeGuidIncludingAlternate(exchangeGuid, tenantOrRootOrgRecipientSession, diagnostics);
         return ActiveDirectoryUserProvider.CreateUserFromAdRawEntry(rawEntry);
     }, "FindByExchangeGuidIncludingAlternate failed"));
 }
Exemplo n.º 7
0
 public User FindBySmtpAddress(SmtpAddress smtpAddress, IRoutingDiagnostics diagnostics)
 {
     return(this.Execute <User>(delegate
     {
         SmtpProxyAddress proxyAddress = new SmtpProxyAddress(smtpAddress.ToString(), true);
         ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(smtpAddress.Domain);
         IRecipientSession tenantOrRootOrgRecipientSession = this.directorySessionFactoryInstance.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 88, "FindBySmtpAddress", "f:\\15.00.1497\\sources\\dev\\cafe\\src\\Routing\\Providers\\ActiveDirectoryUserProvider.cs");
         ADRawEntry rawEntry = ActiveDirectoryUserProvider.FindByProxyAddress(proxyAddress, tenantOrRootOrgRecipientSession, diagnostics);
         return ActiveDirectoryUserProvider.CreateUserFromAdRawEntry(rawEntry);
     }, "FindBySmtpAddress failed"));
 }
Exemplo n.º 8
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            CalendarLog calendarLog = this.CalendarLogs.FirstOrDefault <CalendarLog>();

            if (calendarLog == null)
            {
                return;
            }
            CalendarDiagnosticAnalyzer calendarDiagnosticAnalyzer;

            if (calendarLog.IsFileLink)
            {
                calendarDiagnosticAnalyzer = new CalendarDiagnosticAnalyzer(null, this.DetailLevel);
            }
            else
            {
                CalendarLogId calendarLogId = calendarLog.Identity as CalendarLogId;
                UriHandler    uriHandler    = new UriHandler(calendarLogId.Uri);
                string        host          = uriHandler.Host;
                SmtpAddress   address       = new SmtpAddress(uriHandler.UserName, host);
                if (!address.IsValidAddress)
                {
                    base.WriteError(new InvalidADObjectOperationException(Strings.Error_InvalidAddress((string)address)), ErrorCategory.InvalidData, null);
                }
                ExchangePrincipal principal = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(host), (string)address, RemotingOptions.AllowCrossSite);
                calendarDiagnosticAnalyzer = new CalendarDiagnosticAnalyzer(principal, this.DetailLevel);
            }
            try
            {
                CalendarLog[] array;
                if (!string.IsNullOrEmpty(this.GlobalObjectId))
                {
                    array = (from f in this.CalendarLogs
                             where f.CleanGlobalObjectId == this.GlobalObjectId
                             select f).ToArray <CalendarLog>();
                }
                else
                {
                    array = this.CalendarLogs;
                }
                CalendarLog[] calendarLogs             = array;
                IEnumerable <CalendarLogAnalysis> logs = calendarDiagnosticAnalyzer.AnalyzeLogs(calendarLogs);
                base.WriteObject(CalendarLogAnalysisSerializer.Serialize(logs, this.OutputAs, this.DetailLevel, true));
            }
            catch (InvalidLogCollectionException)
            {
                base.WriteError(new InvalidADObjectOperationException(Strings.Error_MultipleItemsFound), ErrorCategory.InvalidData, null);
            }
            TaskLogger.LogExit();
        }
Exemplo n.º 9
0
 public User FindByLiveIdMemberName(SmtpAddress liveIdMemberName, string organizationContext, IRoutingDiagnostics diagnostics)
 {
     return(this.Execute <User>(delegate
     {
         string text = organizationContext;
         if (string.IsNullOrEmpty(text))
         {
             text = liveIdMemberName.Domain;
         }
         ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(text);
         ITenantRecipientSession recipientSession = this.directorySessionFactoryInstance.CreateTenantRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 140, "FindByLiveIdMemberName", "f:\\15.00.1497\\sources\\dev\\cafe\\src\\Routing\\Providers\\ActiveDirectoryUserProvider.cs");
         ADRawEntry rawEntry = ActiveDirectoryUserProvider.FindByLiveIdMemberName(liveIdMemberName, recipientSession, diagnostics);
         return ActiveDirectoryUserProvider.CreateUserFromAdRawEntry(rawEntry);
     }, "FindByLiveIdMemberName failed"));
 }
        // Token: 0x060006CD RID: 1741 RVA: 0x00025EEC File Offset: 0x000240EC
        internal override GetSyncStateResult GetExchangeDiagnosticsInfoData(DiagnosableParameters arguments)
        {
            ParsedCallData     parsedCallData = this.ParseCallData(arguments.Argument);
            ExchangePrincipal  mailboxOwner   = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(parsedCallData.Mailbox.Domain), parsedCallData.Mailbox.ToString(), RemotingOptions.AllowCrossSite);
            GetSyncStateResult result;

            using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.CurrentCulture, "Client=ActiveSync"))
            {
                GetSyncStateResult data = SyncStateDiagnostics.GetData(mailboxSession, parsedCallData);
                if (parsedCallData.FidMapping)
                {
                    this.FillFidMapping(data, mailboxSession);
                }
                result = data;
            }
            return(result);
        }
Exemplo n.º 11
0
 protected PublishedFolder(string domain, SecurityIdentifier sid, StoreObjectId folderId) : this(folderId)
 {
     Util.ThrowOnNullArgument(sid, "user");
     this.sid = sid;
     using (DisposeGuard disposeGuard = this.Guard())
     {
         this.AcquireBudgetAndStartTiming();
         disposeGuard.Success();
     }
     try
     {
         this.sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(domain);
     }
     catch (CannotResolveTenantNameException arg)
     {
         ExTraceGlobals.SharingTracer.TraceError <string, CannotResolveTenantNameException>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Cannot resolve tenant name {0}.Error: {1}", domain, arg);
     }
 }
Exemplo n.º 12
0
        public override string Lookup(out SecurityIdentifier sid)
        {
            sid = null;
            ADUser aduser;

            try
            {
                ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(this.domain);
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 67, "Lookup", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\ObscureUrlKey.cs");
                aduser = (tenantOrRootOrgRecipientSession.FindByExchangeGuid(this.mailboxGuid) as ADUser);
                if (aduser == null)
                {
                    ExTraceGlobals.SharingTracer.TraceError <Guid>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Cannot find User object for mailbox guid {0}.", this.mailboxGuid);
                    return(null);
                }
            }
            catch (CannotResolveTenantNameException arg)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, Guid, CannotResolveTenantNameException>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Cannot resolve tenant name {0} for mailbox guid {1}.Error: {2}", this.domain, this.mailboxGuid, arg);
                return(null);
            }
            catch (ADTransientException arg2)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, Guid, ADTransientException>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Transient exception {0} for mailbox guid {1}.Error: {2}", this.domain, this.mailboxGuid, arg2);
                return(null);
            }
            catch (DataSourceOperationException arg3)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, Guid, DataSourceOperationException>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): DataSourceOperationException  {0} for mailbox guid {1}.Error: {2}", this.domain, this.mailboxGuid, arg3);
                return(null);
            }
            sid = aduser.Sid;
            string folder = aduser.SharingAnonymousIdentities.GetFolder(this.urlId);

            if (string.IsNullOrEmpty(folder))
            {
                ExTraceGlobals.SharingTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Not found sharing anonymous identity for mailbox guid {0} with url id {1}.", this.mailboxGuid, this.urlId);
            }
            else
            {
                ExTraceGlobals.SharingTracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Get sharing anonymous identity for mailbox guid {0} with url id {1}: Folder Id = {2}.", this.mailboxGuid, this.urlId, folder);
            }
            return(folder);
        }
Exemplo n.º 13
0
        public override string Lookup(out SecurityIdentifier sid)
        {
            sid = null;
            ADSessionSettings sessionSettings;

            try
            {
                sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(this.smtpAddress.Domain);
            }
            catch (CannotResolveTenantNameException arg)
            {
                ExTraceGlobals.SharingTracer.TraceError <SmtpAddress, CannotResolveTenantNameException>((long)this.GetHashCode(), "PublicUrlKey.Lookup(): Cannot resolve tenant name for address {0}.Error: {1}", this.smtpAddress, arg);
                return(null);
            }
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 79, "Lookup", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\PublicUrlKey.cs");

            ADUser[] array = tenantOrRootOrgRecipientSession.FindADUser(null, QueryScope.SubTree, this.filterBySmtpAddress, null, 1);
            if (array == null || array.Length == 0)
            {
                ExTraceGlobals.SharingTracer.TraceError <SmtpAddress>((long)this.GetHashCode(), "PublicUrlKey.Lookup(): Cannot find ADUser object for smtp address {0}.", this.smtpAddress);
                return(null);
            }
            ADUser aduser = array[0];

            sid = aduser.Sid;
            string folder = aduser.SharingAnonymousIdentities.GetFolder(this.urlId);

            if (string.IsNullOrEmpty(folder))
            {
                ExTraceGlobals.SharingTracer.TraceDebug <SmtpAddress, string>((long)this.GetHashCode(), "PublicUrlKey.Lookup(): Not found sharing anonymous identity for user {0} with url id {1}.", this.smtpAddress, this.urlId);
            }
            else
            {
                ExTraceGlobals.SharingTracer.TraceDebug <SmtpAddress, string, string>((long)this.GetHashCode(), "PublicUrlKey.Lookup(): Get sharing anonymous identity for user {0} with url id {1}: Folder Id = {2}.", this.smtpAddress, this.urlId, folder);
            }
            return(folder);
        }
Exemplo n.º 14
0
        internal bool TryAcquireBudget()
        {
            if (this.budget != null)
            {
                throw new InvalidOperationException("Budget already acquired");
            }
            Exception ex2;

            try
            {
                ADSessionSettings settings;
                if (!string.IsNullOrEmpty(this.userDomain))
                {
                    settings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(this.userDomain);
                }
                else
                {
                    settings = ADSessionSettings.FromRootOrgScopeSet();
                }
                this.budget = StandardBudget.Acquire(this.clientSecurityContext.UserSid, BudgetType.Rca, settings);
                return(true);
            }
            catch (DataValidationException ex)
            {
                ex2 = ex;
            }
            catch (ADTransientException ex3)
            {
                ex2 = ex3;
            }
            catch (ADOperationException ex4)
            {
                ex2 = ex4;
            }
            RfriContext.ReferralTracer.TraceError <string>((long)this.ContextHandle, "TryAcquireBudget exception: {0}", ex2.Message);
            return(false);
        }
Exemplo n.º 15
0
 private static bool CheckForSpecialRmsOnlineTenantMembershipQuery(string recipientAddress, string groupAddress, out bool isMemberOfTenant)
 {
     isMemberOfTenant = false;
     if (new SmtpAddress(groupAddress).Local.Equals("AllStaff-7184AB3F-CCD1-46F3-8233-3E09E9CF0E66", StringComparison.OrdinalIgnoreCase))
     {
         try
         {
             isMemberOfTenant = ServerManager.IsUserMemberOfTenant(recipientAddress, ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(new SmtpAddress(groupAddress).Domain));
         }
         catch (NonUniqueRecipientException ex)
         {
             throw new ADOperationException(ex.LocalizedString, ex);
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 16
0
        private string[] GetProxyAddresses(string address)
        {
            if (string.IsNullOrEmpty(address))
            {
                return(null);
            }
            int num = 0;

            string[]     array        = null;
            Exception    ex           = null;
            ADRawEntry   adrawEntry   = null;
            ProxyAddress proxyAddress = ProxyAddress.Parse(address);

            if (proxyAddress is InvalidProxyAddress)
            {
                ex = ((InvalidProxyAddress)proxyAddress).ParseException;
                LocalizedException exception = new LocalizedException(Strings.WarningProxyAddressIsInvalid(address, ex.Message));
                base.WriteError(exception, ErrorCategory.InvalidArgument, null);
                return(null);
            }
            if (this.recipSession == null)
            {
                ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(SmtpAddress.Parse(address).Domain);
                this.recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.FullyConsistent, sessionSettings, 977, "GetProxyAddresses", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\LogSearch\\GetMessageTrackingLog.cs");
                if (!this.recipSession.IsReadConnectionAvailable())
                {
                    this.recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.FullyConsistent, sessionSettings, 986, "GetProxyAddresses", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\LogSearch\\GetMessageTrackingLog.cs");
                }
            }
            AcceptedDomain acceptedDomain = null;
            bool           flag;

            do
            {
                flag = false;
                try
                {
                    this.GetRecipientInformation(proxyAddress.ToString(), out adrawEntry, out acceptedDomain);
                }
                catch (DataValidationException ex2)
                {
                    ex = ex2;
                }
                catch (TransientException ex3)
                {
                    if (num < 3)
                    {
                        flag = true;
                        num++;
                        Thread.Sleep(1000);
                    }
                    else
                    {
                        ex = ex3;
                    }
                }
            }while (flag);
            if (ex != null)
            {
                this.WriteWarning(Strings.WarningProxyListUnavailable(address, ex.GetType().Name + ": " + ex.Message));
                return(null);
            }
            if (adrawEntry == null)
            {
                return(null);
            }
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses];
            string address2 = (string)adrawEntry[ADRecipientSchema.LegacyExchangeDN];

            array = new string[proxyAddressCollection.Count + 1];
            int num2 = 0;
            SmtpProxyAddress smtpProxyAddress;

            if (acceptedDomain != null && SmtpProxyAddress.TryEncapsulate(ProxyAddressPrefix.LegacyDN.PrimaryPrefix, address2, acceptedDomain.DomainName.Domain, out smtpProxyAddress))
            {
                array[0] = smtpProxyAddress.AddressString;
            }
            foreach (ProxyAddress proxyAddress2 in proxyAddressCollection)
            {
                num2++;
                SmtpProxyAddress smtpProxyAddress2 = null;
                if (proxyAddress2.Prefix == ProxyAddressPrefix.Smtp)
                {
                    array[num2] = proxyAddress2.AddressString;
                }
                else if (acceptedDomain != null && SmtpProxyAddress.TryEncapsulate(proxyAddress2, acceptedDomain.DomainName.Domain, out smtpProxyAddress2))
                {
                    array[num2] = smtpProxyAddress2.AddressString;
                }
            }
            return(array);
        }
Exemplo n.º 17
0
        private static bool FindUser(string username, string domain, out ADUser user)
        {
            UmConnectivityCredentialsHelper.DebugTrace("Inside FindUser()", new object[0]);
            user = null;
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(domain), 500, "FindUser", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\um\\UmConnectivityCredentialsHelper.cs");
            string            sUserPrincipalName = username + "@" + domain;

            try
            {
                using (WindowsIdentity windowsIdentity = new WindowsIdentity(sUserPrincipalName))
                {
                    user = (ADUser)tenantOrRootOrgRecipientSession.FindBySid(windowsIdentity.User);
                }
            }
            catch (SecurityException)
            {
            }
            catch (UnauthorizedAccessException)
            {
            }
            catch (ArgumentException)
            {
            }
            catch (LocalizedException)
            {
            }
            if (user == null)
            {
                string accountName = domain + "\\" + username;
                try
                {
                    user = (ADUser)tenantOrRootOrgRecipientSession.FindByAccountName <ADRecipient>(domain, accountName);
                }
                catch (LocalizedException)
                {
                }
            }
            if (user == null)
            {
                if (username.Length > 20)
                {
                    username = username.Substring(0, 20);
                }
                try
                {
                    user = (ADUser)tenantOrRootOrgRecipientSession.FindByAccountName <ADRecipient>(domain, username);
                }
                catch (LocalizedException)
                {
                }
            }
            return(user != null);
        }
Exemplo n.º 18
0
        private void PerformArchiveConnectivityTest(ref ArchiveConnectivityOutcome result)
        {
            bool flag  = false;
            bool flag2 = false;

            try
            {
                SmtpAddress       userSmtp          = this.UserSmtp;
                ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(userSmtp.Domain), userSmtp.ToString());
                if (exchangePrincipal != null)
                {
                    if (this.IncludeArchiveMRMConfiguration || !string.IsNullOrEmpty(this.MessageId))
                    {
                        this.LogonPrimary(exchangePrincipal);
                        result.PrimaryMRMConfiguration  = this.primaryFAI;
                        result.PrimaryLastProcessedTime = this.primaryLastProcessedTime;
                    }
                    flag = true;
                    ADObjectId        objectId = exchangePrincipal.ObjectId;
                    IRecipientSession tenantOrRootOrgRecipientSession;
                    if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled)
                    {
                        tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.FullyConsistent, exchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings(), 276, "PerformArchiveConnectivityTest", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Monitoring\\ArchiveConnectivity\\TestArchiveConnectivityTask.cs");
                    }
                    else
                    {
                        tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.FullyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 284, "PerformArchiveConnectivityTest", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Monitoring\\ArchiveConnectivity\\TestArchiveConnectivityTask.cs");
                    }
                    ADUser aduser = tenantOrRootOrgRecipientSession.FindADUserByObjectId(objectId);
                    this.complianceConfiguration   = aduser.ElcMailboxFlags.ToString();
                    result.ComplianceConfiguration = this.complianceConfiguration;
                    if (exchangePrincipal.GetArchiveMailbox() == null)
                    {
                        result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, Strings.ArchiveConnectivityResultArchiveNotProvisioned);
                    }
                    else
                    {
                        if (aduser.ArchiveDomain != null)
                        {
                            result.ArchiveDomain = aduser.ArchiveDomain.ToString();
                            flag2 = true;
                        }
                        if (aduser.ArchiveDatabase != null)
                        {
                            result.ArchiveDatabase = aduser.ArchiveDatabase.ToString();
                        }
                        if (aduser.RecipientType == RecipientType.UserMailbox)
                        {
                            if (flag2)
                            {
                                if (ArchiveStatusFlags.Active != aduser.ArchiveStatus)
                                {
                                    result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, Strings.ArchiveConnectivityResultArchiveNotActive);
                                }
                                else if (this.LogonArchive(this.GetArchivePrincipal(exchangePrincipal, aduser)))
                                {
                                    result.Update(ArchiveConnectivityResultEnum.Success, "");
                                }
                            }
                            else if (this.LogonArchive(this.GetArchivePrincipal(exchangePrincipal, aduser)))
                            {
                                result.Update(ArchiveConnectivityResultEnum.Success, "");
                            }
                        }
                        if (this.IncludeArchiveMRMConfiguration)
                        {
                            result.ArchiveMRMConfiguration  = this.archiveFAI;
                            result.ArchiveLastProcessedTime = this.archiveLastProcessedTime;
                        }
                    }
                }
                this.mrmProperties = this.mrmPropReport.ToString();
                if (!string.IsNullOrEmpty(this.mrmProperties))
                {
                    result.ItemMRMProperties = this.mrmProperties;
                }
                else if (!string.IsNullOrEmpty(this.MessageId))
                {
                    result.ItemMRMProperties = "Item not found.";
                }
            }
            catch (ObjectNotFoundException ex)
            {
                if (!flag)
                {
                    result.Update(ArchiveConnectivityResultEnum.PrimaryFailure, this.GetAllInnerExceptions(ex));
                }
                else
                {
                    result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, this.GetAllInnerExceptions(ex));
                }
            }
            catch (ConnectionFailedTransientException ex2)
            {
                result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, this.GetAllInnerExceptions(ex2));
            }
            catch (AutoDAccessException ex3)
            {
                result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, this.GetAllInnerExceptions(ex3));
            }
            catch (StoragePermanentException ex4)
            {
                result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, this.GetAllInnerExceptions(ex4));
            }
            catch (StorageTransientException ex5)
            {
                result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, this.GetAllInnerExceptions(ex5));
            }
            catch (ArgumentException ex6)
            {
                result.Update(ArchiveConnectivityResultEnum.ArchiveFailure, this.GetAllInnerExceptions(ex6));
            }
        }
Exemplo n.º 19
0
        private void SendMapiMessageHelper(bool setLamNotificationId, string lamNotificationId, SendMapiMailDefinition mapiMailDefinition, bool returnOutParameters, out string entryId, out string internetMessageId, out Guid senderMbxGuid)
        {
            entryId           = string.Empty;
            internetMessageId = string.Empty;
            senderMbxGuid     = Guid.Empty;
            ExchangePrincipal mailboxOwner;

            if (mapiMailDefinition.SenderMbxGuid != Guid.Empty)
            {
                mailboxOwner = ExchangePrincipal.FromMailboxData(mapiMailDefinition.SenderMbxGuid, mapiMailDefinition.SenderMdbGuid, new List <CultureInfo>(0));
            }
            else
            {
                string domainPartOfEmailAddress = MapiMessageSubmitter.GetDomainPartOfEmailAddress(mapiMailDefinition.SenderEmailAddress);
                mailboxOwner = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(domainPartOfEmailAddress), mapiMailDefinition.SenderEmailAddress);
            }
            using (MailboxSession mailboxSession = MailboxSession.OpenAsTransport(mailboxOwner, "Client=Monitoring;Action=MapiSubmitLAMProbe"))
            {
                using (MessageItem messageItem = MessageItem.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Outbox)))
                {
                    messageItem.ClassName = mapiMailDefinition.MessageClass;
                    if (setLamNotificationId)
                    {
                        messageItem[MessageItemSchema.MapiSubmitLamNotificationId] = lamNotificationId;
                        messageItem[MessageItemSchema.XLAMNotificationId]          = lamNotificationId;
                    }
                    messageItem[MessageItemSchema.DoNotDeliver] = (mapiMailDefinition.DoNotDeliver ? "Supress" : "Deliver");
                    if (mapiMailDefinition.DropMessageInHub)
                    {
                        messageItem[MessageItemSchema.DropMessageInHub] = "FrontEnd-CAT-250";
                        messageItem[MessageItemSchema.SystemProbeDrop]  = "OnEndOfHeaders";
                    }
                    messageItem.Subject = mapiMailDefinition.MessageSubject;
                    BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextPlain);
                    using (TextWriter textWriter = messageItem.Body.OpenTextWriter(configuration))
                    {
                        textWriter.Write(mapiMailDefinition.MessageBody);
                    }
                    messageItem.Recipients.Add(new Participant(mapiMailDefinition.RecipientEmailAddress, mapiMailDefinition.RecipientEmailAddress, "SMTP"), RecipientItemType.To);
                    if (mapiMailDefinition.DeleteAfterSubmit)
                    {
                        messageItem.SendWithoutSavingMessage();
                    }
                    else
                    {
                        messageItem.Send();
                    }
                    if (returnOutParameters)
                    {
                        senderMbxGuid = mailboxSession.MailboxGuid;
                        messageItem.Load(new PropertyDefinition[]
                        {
                            StoreObjectSchema.EntryId,
                            ItemSchema.InternetMessageId
                        });
                        object obj      = messageItem.TryGetProperty(StoreObjectSchema.EntryId);
                        byte[] entryId2 = (byte[])obj;
                        entryId = MapiMessageSubmitter.EntryIdString(entryId2);
                        object obj2 = messageItem.TryGetProperty(ItemSchema.InternetMessageId);
                        internetMessageId = obj2.ToString();
                    }
                }
            }
        }
Exemplo n.º 20
0
        private DeletionResult DeleteMessageFromOutboxHelper(DeleteMapiMailDefinition deleteMapiMailDefinition)
        {
            DeletionResult    result = DeletionResult.Fail;
            string            domainPartOfEmailAddress = MapiMessageSubmitter.GetDomainPartOfEmailAddress(deleteMapiMailDefinition.SenderEmailAddress);
            ExchangePrincipal mailboxOwner             = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(domainPartOfEmailAddress), deleteMapiMailDefinition.SenderEmailAddress);
            QueryFilter       queryFilter = new AndFilter(new List <QueryFilter>(2)
            {
                new TextFilter(ItemSchema.InternetMessageId, deleteMapiMailDefinition.InternetMessageId, MatchOptions.FullString, MatchFlags.IgnoreCase),
                new TextFilter(StoreObjectSchema.ItemClass, deleteMapiMailDefinition.MessageClass, MatchOptions.FullString, MatchFlags.IgnoreCase)
            }.ToArray());

            using (MailboxSession mailboxSession = MailboxSession.OpenAsTransport(mailboxOwner, "Client=Monitoring;Action=MapiSubmitLAMProbe"))
            {
                using (Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.Outbox))
                {
                    using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, queryFilter, null, new PropertyDefinition[]
                    {
                        ItemSchema.Id
                    }))
                    {
                        object[][] rows = queryResult.GetRows(1);
                        if (rows == null || rows.Length == 0)
                        {
                            result = DeletionResult.NoMatchingMessage;
                        }
                        else
                        {
                            mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                            {
                                ((VersionedId)rows[0][0]).ObjectId
                            });
                            result = DeletionResult.Success;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 21
0
        // Token: 0x06000AFA RID: 2810 RVA: 0x0002C438 File Offset: 0x0002A638
        internal override MailAppsResult GetExchangeDiagnosticsInfoData(DiagnosableParameters argument)
        {
            MailAppsResult mailAppsResult = new MailAppsResult();
            string         text           = argument.Argument;

            if (!string.IsNullOrEmpty(text))
            {
                string value = null;
                string text2 = ",val=";
                int    num   = text.IndexOf(text2);
                if (num != -1)
                {
                    value = text.Substring(num + text2.Length);
                    text  = argument.Argument.Substring(0, num);
                }
                MailAppsArgument mailAppsArgument = new MailAppsArgument(text);
                if (mailAppsArgument.HasArgument("org") && mailAppsArgument.HasArgument("cmd"))
                {
                    bool              flag      = false;
                    string            argument2 = mailAppsArgument.GetArgument <string>("org");
                    ExchangePrincipal exchangePrincipal;
                    if (mailAppsArgument.HasArgument("usr"))
                    {
                        string            argument3  = mailAppsArgument.GetArgument <string>("usr");
                        ADSessionSettings adSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(argument2);
                        exchangePrincipal = ExchangePrincipal.FromProxyAddress(adSettings, argument3 + "@" + argument2, RemotingOptions.AllowCrossSite);
                    }
                    else
                    {
                        ADUser orgMailbox = OrgExtensionTable.GetOrgMailbox(argument2);
                        exchangePrincipal = ExchangePrincipal.FromADUser(orgMailbox, null);
                        flag = true;
                    }
                    using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(exchangePrincipal, CultureInfo.CurrentCulture, "Client=WebServices"))
                    {
                        using (UserConfiguration folderConfiguration = UserConfigurationHelper.GetFolderConfiguration(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox), "ExtensionMasterTable", UserConfigurationTypes.XML, true, false))
                        {
                            using (Stream xmlStream = folderConfiguration.GetXmlStream())
                            {
                                if (string.Equals(mailAppsArgument.GetArgument <string>("cmd"), "set", StringComparison.OrdinalIgnoreCase) && num != -1)
                                {
                                    xmlStream.SetLength(0L);
                                    bool flag2 = string.IsNullOrEmpty(value);
                                    if (!flag2)
                                    {
                                        using (StreamWriter streamWriter = new StreamWriter(xmlStream, Encoding.UTF8))
                                        {
                                            streamWriter.Write(value);
                                        }
                                    }
                                    folderConfiguration.Save();
                                    if (flag)
                                    {
                                        OrgEmptyMasterTableCache.Singleton.Update(exchangePrincipal.MailboxInfo.OrganizationId, flag2);
                                    }
                                    mailAppsResult.Message = "Raw value saved.";
                                }
                                else
                                {
                                    using (StreamReader streamReader = new StreamReader(xmlStream, true))
                                    {
                                        mailAppsResult.RawMasterTable = streamReader.ReadToEnd();
                                        if (mailAppsArgument.HasArgument("len"))
                                        {
                                            int argument4 = mailAppsArgument.GetArgument <int>("len");
                                            if (argument4 > 0 && argument4 < mailAppsResult.RawMasterTable.Length)
                                            {
                                                mailAppsResult.RawMasterTable = mailAppsResult.RawMasterTable.Substring(0, argument4);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(mailAppsResult);
        }
Exemplo n.º 22
0
        private static void GetLogonUserInfo(SecurityIdentifier sid, string smtpDomain, out string smtpAddress, out string displayName, out string puid)
        {
            string smtpAddressTemporary = sid.ToString();
            string displayNameTemporary = sid.ToString();
            string puidTemporary        = string.Empty;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(smtpDomain), 339, "GetLogonUserInfo", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\attachment\\CachedAttachmentInfo.cs");
                PropertyDefinition[] properties = new PropertyDefinition[]
                {
                    ADRecipientSchema.PrimarySmtpAddress,
                    ADRecipientSchema.LegacyExchangeDN,
                    ADRecipientSchema.DisplayName,
                    ADUserSchema.NetID
                };
                ADRawEntry entry = tenantOrRootOrgRecipientSession.FindADRawEntryBySid(sid, properties);
                try
                {
                    CachedAttachmentInfo.SafeGetValue(entry, ADRecipientSchema.PrimarySmtpAddress, ref smtpAddressTemporary);
                    CachedAttachmentInfo.SafeGetValue(entry, ADRecipientSchema.DisplayName, ref displayNameTemporary);
                    CachedAttachmentInfo.SafeGetValue(entry, ADUserSchema.NetID, ref puidTemporary);
                }
                catch (NotInBagPropertyErrorException)
                {
                }
            });
            smtpAddress = smtpAddressTemporary;
            displayName = displayNameTemporary;
            puid        = puidTemporary;
        }
Exemplo n.º 23
0
        private MultiValuedProperty <string> AcceptedDomainNamesGetter(ADOrganizationConfig org)
        {
            MultiValuedProperty <string> multiValuedProperty = new MultiValuedProperty <string>();

            if (!string.IsNullOrEmpty(org.MicrosoftExchangeRecipientPrimarySmtpAddress.Domain))
            {
                IConfigurationSession          tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(org.MicrosoftExchangeRecipientPrimarySmtpAddress.Domain), 215, "AcceptedDomainNamesGetter", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\GetOrganization.cs");
                ADPagedReader <AcceptedDomain> adpagedReader = tenantOrTopologyConfigurationSession.FindPaged <AcceptedDomain>(null, QueryScope.SubTree, null, null, 0);
                using (IEnumerator <AcceptedDomain> enumerator = adpagedReader.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AcceptedDomain acceptedDomain = enumerator.Current;
                        multiValuedProperty.Add(acceptedDomain.DomainName.Address);
                    }
                    return(multiValuedProperty);
                }
            }
            if (org.SharedConfigurationInfo == null)
            {
                this.WriteWarning(Strings.WarningPrimaryExchangeRecipientNotSet(this.Identity.ToString()));
            }
            return(multiValuedProperty);
        }
Exemplo n.º 24
0
 protected override IConfigDataProvider CreateSession()
 {
     return(DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(this.Identity.ToString()), 97, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Support\\WebDns\\GetWebDnsRecord.cs"));
 }