// Token: 0x060000BB RID: 187 RVA: 0x0000858C File Offset: 0x0000678C
        private void SetActiveSyncDeviceContainerPermissions(ActiveSyncDevices container)
        {
            ADDeviceManager.ReadStaticADData(this.protocolLogger);
            RawSecurityDescriptor rawSecurityDescriptor = null;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                rawSecurityDescriptor = this.session.ReadSecurityDescriptor(container.Id);
            });
            if (rawSecurityDescriptor == null)
            {
                if (this.protocolLogger != null)
                {
                    this.protocolLogger.SetValue(ProtocolLoggerData.Error, "ADObjectWithNoSecurityDescriptor");
                }
                AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, EASServerStrings.NullNTSD(container.Id.DistinguishedName), true);
                throw ex;
            }
            AirSyncDiagnostics.TraceDebug <string>(this.tracer, this, "Setting ACL on device container for user \"{0}\".", this.userName);
            ActiveDirectorySecurity acl = new ActiveDirectorySecurity();

            byte[] array = new byte[rawSecurityDescriptor.BinaryLength];
            rawSecurityDescriptor.GetBinaryForm(array, 0);
            acl.SetSecurityDescriptorBinaryForm(array);
            acl.AddAccessRule(new ActiveDirectoryAccessRule(ADDeviceManager.exchangeServersGroupSid, ActiveDirectoryRights.CreateChild | ActiveDirectoryRights.DeleteChild | ActiveDirectoryRights.ListChildren | ActiveDirectoryRights.ReadProperty | ActiveDirectoryRights.WriteProperty | ActiveDirectoryRights.ListObject, AccessControlType.Allow, ADDeviceManager.activeSyncDeviceClass, ActiveDirectorySecurityInheritance.None));
            acl.AddAccessRule(new ActiveDirectoryAccessRule(ADDeviceManager.exchangeServersGroupSid, ActiveDirectoryRights.Delete | ActiveDirectoryRights.ReadProperty | ActiveDirectoryRights.WriteProperty | ActiveDirectoryRights.ListObject, AccessControlType.Allow, ActiveDirectorySecurityInheritance.Children, ADDeviceManager.activeSyncDeviceClass));
            ADNotificationAdapter.RunADOperation(delegate()
            {
                this.session.SaveSecurityDescriptor(container, new RawSecurityDescriptor(acl.GetSecurityDescriptorBinaryForm(), 0));
            });
        }
 public void Start(bool initiallyPaused, ServiceState targetRunningState)
 {
     lock (this.syncObject)
     {
         this.paused = initiallyPaused;
         ADNotificationAdapter.RunADOperation(delegate()
         {
             try
             {
                 StoreDriverSubmission.localIp = Dns.GetHostEntry(Dns.GetHostName());
             }
             catch (SocketException ex)
             {
                 this.storeDriverTracer.StoreDriverSubmissionTracer.TraceFail <string>(this.storeDriverTracer.MessageProbeActivityId, 0L, "Start failed: {0}", ex.ToString());
                 StoreDriverSubmission.LogEvent(MSExchangeStoreDriverSubmissionEventLogConstants.Tuple_StoreDriverSubmissionGetLocalIPFailure, null, new object[]
                 {
                     ex
                 });
                 throw new TransportComponentLoadFailedException(ex.Message, ex);
             }
             StoreDriverSubmission.receivedHeaderTcpInfo = StoreDriverSubmission.FormatIPAddress(StoreDriverSubmission.localIp.AddressList[0]);
             this.storeDriverTracer.StoreDriverSubmissionTracer.TracePass(this.storeDriverTracer.MessageProbeActivityId, 0L, "Start submission");
             this.StartSubmission();
         }, 1);
     }
 }
        private bool TryReadCookie(IConfigurationSession session, out Cookie cookie)
        {
            ADObjectId cookieContainerId = null;
            Container  cookieContainer   = null;

            cookie = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                cookieContainerId = this.GetCookieContainerId(session);
                cookieContainer   = session.Read <Container>(cookieContainerId);
            }, 3);

            if (adoperationResult.Succeeded)
            {
                using (MultiValuedProperty <byte[]> .Enumerator enumerator = cookieContainer.EdgeSyncCookies.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        byte[] bytes = enumerator.Current;
                        cookie = Cookie.Deserialize(Encoding.ASCII.GetString(bytes));
                    }
                }
            }
            return(adoperationResult.Succeeded);
        }
示例#4
0
 private static void HandleConfigurationChange(ADNotificationEventArgs args)
 {
     try
     {
         if (Interlocked.Increment(ref RmsClientManagerLog.notificationHandlerCount) == 1)
         {
             Server            localServer       = null;
             ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
             {
                 ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 1191, "HandleConfigurationChange", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\rightsmanagement\\RmsClientManagerLog.cs");
                 localServer = topologyConfigurationSession.FindLocalServer();
             });
             if (!adoperationResult.Succeeded)
             {
                 RmsClientManagerLog.Tracer.TraceError <Exception>(0L, "Failed to get the local server.  Unable to reload the log configuration. Error {0}", adoperationResult.Exception);
             }
             else
             {
                 RmsClientManagerLog.Configure(localServer);
             }
         }
     }
     finally
     {
         Interlocked.Decrement(ref RmsClientManagerLog.notificationHandlerCount);
     }
 }
        // Token: 0x0600001C RID: 28 RVA: 0x00002F60 File Offset: 0x00001160
        private bool RegisterConfigurationChangeHandlers(out ADOperationResult opResult)
        {
            ExTraceGlobals.ServiceTracer.TraceDebug(0L, "TransportService register configuration change notifications");
            Server server;

            if (ADNotificationAdapter.TryReadConfiguration <Server>(delegate()
            {
                Server result;
                try
                {
                    result = TransportService.adConfigurationSession.FindLocalServer();
                }
                catch (LocalServerNotFoundException)
                {
                    result = null;
                }
                return(result);
            }, out server, out opResult))
            {
                opResult = ADNotificationAdapter.TryRunADOperation(delegate()
                {
                    if (this.receiveConnectorNotificationCookie == null)
                    {
                        this.receiveConnectorNotificationCookie = TransportADNotificationAdapter.Instance.RegisterForLocalServerReceiveConnectorNotifications(server.Id, new ADNotificationCallback(this.ConnectorsConfigUpdate));
                        ExTraceGlobals.ServiceTracer.TraceDebug <ADObjectId>(0L, "TransportService registered for Receive Connector configuration change notifications (server id={0})", server.Id);
                    }
                    this.serverNotificationCookie = TransportADNotificationAdapter.Instance.RegisterForExchangeServerNotifications(server.Id, new ADNotificationCallback(this.ServerConfigUpdate));
                    ExTraceGlobals.ServiceTracer.TraceDebug <ADObjectId>(0L, "TransportService registered for Server configuration change notifications (server id={0})", server.Id);
                });
                return(opResult.Succeeded);
            }
            ExTraceGlobals.ServiceTracer.TraceDebug(0L, "TransportService failed to get local server. Failed to register for configuration change notifications.");
            return(false);
        }
示例#6
0
 // Token: 0x06000092 RID: 146 RVA: 0x000041E3 File Offset: 0x000023E3
 protected override void InternalExecute()
 {
     ADNotificationAdapter.TryRunADOperation(delegate()
     {
         this.InternalTaskExecute();
     });
 }
示例#7
0
        private static IEnumerable <ADRawEntry> ReadDkmAdObjects(IRootOrganizationRecipientSession session, string dkmContainerName, string rootDomain, StringBuilder detailStatus)
        {
            string dkmContainerDN = TestDataCenterDKMAccess.CreateDkmContainerDN(dkmContainerName, rootDomain);

            ADRawEntry[]      dkmObjects        = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                dkmObjects = session.Find(new ADObjectId(dkmContainerDN), QueryScope.SubTree, new CustomLdapFilter("(objectClass=contact)"), null, -1, new ADPropertyDefinition[]
                {
                    ADObjectSchema.Name
                });
            });

            if (!adoperationResult.Succeeded)
            {
                detailStatus.AppendFormat("Failed to read DKM objects under DN {0} with exception {1}", dkmContainerDN, (adoperationResult.Exception == null) ? "N/A" : adoperationResult.Exception.Message);
                return(null);
            }
            if (dkmObjects.Length == 0)
            {
                detailStatus.AppendFormat("Failed to find any DKM objects under DN {0}. Examine the ACL settings on DKM objects to ensure the Exchange Servers group is allowed.", dkmContainerDN);
                return(null);
            }
            return(dkmObjects);
        }
        protected virtual void UpdateRecipientSyncStateValueInAD(RecipientSyncOperation operation)
        {
            if (this.updateConnection == null)
            {
                ADObjectId        rootId            = null;
                ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                {
                    PooledLdapConnection readConnection = this.ConfigSession.GetReadConnection(this.sourceConnection.Fqdn, ref rootId);
                    this.updateConnection = new Connection(readConnection, EdgeSyncSvc.EdgeSync.AppConfig);
                }, 3);
                if (!adoperationResult.Succeeded)
                {
                    ExTraceGlobals.TargetConnectionTracer.TraceError <string>((long)this.GetHashCode(), "Failed to get AD connection to update SyncState because of {0}", adoperationResult.Exception.Message);
                    throw new ExDirectoryException("Failed to get AD connection to update SyncState", adoperationResult.Exception);
                }
            }
            byte[]        array   = RecipientSyncState.SerializeRecipientSyncState(operation.RecipientSyncState);
            ModifyRequest request = new ModifyRequest(operation.DistinguishedName, DirectoryAttributeOperation.Replace, "msExchExternalSyncState", new object[]
            {
                array
            });

            this.updateConnection.SendRequest(request);
            ExTraceGlobals.TargetConnectionTracer.TraceDebug <string>((long)this.GetHashCode(), "Successfully updated SyncState in AD for {0}", operation.DistinguishedName);
            base.LogSession.LogEvent(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, operation.DistinguishedName, "Successfully synced to MSERV and updated SyncState");
        }
        private MserveTargetConnection.TenantSyncControl GetTenantSyncControlSettingFromAD(ADObjectId tenantCUId, string key)
        {
            ExchangeConfigurationUnit tenantCU      = null;
            int               tryCount              = 0;
            string            savedDomainController = this.ConfigSession.DomainController;
            ADOperationResult adoperationResult     = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                if (tryCount++ == 0)
                {
                    this.ConfigSession.DomainController = this.sourceConnection.Fqdn;
                }
                else
                {
                    this.ConfigSession.DomainController = savedDomainController;
                }
                tenantCU = this.ConfigSession.Read <ExchangeConfigurationUnit>(tenantCUId);
            }, 2);

            this.ConfigSession.DomainController = savedDomainController;
            if (!adoperationResult.Succeeded)
            {
                throw new ExDirectoryException(string.Format("Failed to read user's ExchangeConfigurationUnit {0}", tenantCUId.DistinguishedName), adoperationResult.Exception);
            }
            if (tenantCU == null)
            {
                throw new ExDirectoryException(string.Format("Failed to read user's ExchangeConfigurationUnit {0} because AD returns null", tenantCUId.DistinguishedName), null);
            }
            base.LogSession.LogEvent(EdgeSyncLoggingLevel.High, EdgeSyncEvent.TargetConnection, tenantCUId.DistinguishedName, "OrgStatus:" + tenantCU.OrganizationStatus);
            if (!tenantCU.IsOrganizationReadyForMservSync)
            {
                throw new ExDirectoryException(string.Format("Warning: ExchangeConfigurationUnit {0} with OrgStatus {1} is not ready for Mserv Sync yet.", tenantCUId.DistinguishedName, tenantCU.OrganizationStatus), null);
            }
            return(new MserveTargetConnection.TenantSyncControl(tenantCU.SyncMEUSMTPToMServ, tenantCU.SyncMBXAndDLToMServ));
        }
示例#10
0
 private bool RegisterChangeNotification(IConfigurationSession session, CacheNotificationHandler cacheNotificationHandler, bool throwExceptions)
 {
     if (!OrganizationId.ForestWideOrgId.Equals(this.organizationId))
     {
         return(true);
     }
     try
     {
         this.notificationCookie = ADNotificationAdapter.RegisterChangeNotification <TConfig>(this.organizationId.ConfigurationUnit ?? session.GetOrgContainerId(), new ADNotificationCallback(TenantConfigurationCacheableItem <TConfig> .HandleChangeNotification), new CacheNotificationArgs(cacheNotificationHandler, this.organizationId));
     }
     catch (TransientException)
     {
         if (!throwExceptions)
         {
             return(false);
         }
         throw;
     }
     catch (DataSourceOperationException)
     {
         if (!throwExceptions)
         {
             return(false);
         }
         throw;
     }
     return(true);
 }
示例#11
0
        public static ADRawEntry GetSender(IRecipientSession session, ProxyAddress sendingAs, ADPropertyDefinition[] properties)
        {
            ADRawEntry        sender            = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                sender = session.FindByProxyAddress(sendingAs, properties);
            });

            if (!adoperationResult.Succeeded)
            {
                if (adoperationResult.Exception is NonUniqueRecipientException)
                {
                    string message = Strings.descMailTipsSenderNotUnique(sendingAs.ToString());
                    throw new SenderNotUniqueException(message);
                }
                throw adoperationResult.Exception;
            }
            else
            {
                if (sender == null)
                {
                    string message2 = Strings.descMailTipsSenderNotFound(sendingAs.ToString());
                    throw new SenderNotFoundException(message2);
                }
                return(sender);
            }
        }
示例#12
0
        // Token: 0x0600101E RID: 4126 RVA: 0x00041FE0 File Offset: 0x000401E0
        protected override void OnServerChangeCallback(ADNotificationEventArgs args)
        {
            if (args != null)
            {
                this.tracer.TraceDebug <string, string>(0L, "OnServerChangeCallback notification change type {0}, object ID {1}", args.ChangeType.ToString(), (args.Id == null) ? "(null)" : args.Id.ToString());
            }
            if (args.ChangeType == ADNotificationChangeType.ModifyOrAdd && args.Id != null)
            {
                Server            server;
                ADOperationResult adoperationResult;
                if (ADNotificationAdapter.TryReadConfiguration <Server>(() => this.configurationSession.Read <Server>(args.Id), out server, out adoperationResult))
                {
                    lock (this.serversLock)
                    {
                        if (this.servers != null && this.servers.IsChangeIgnorable(server))
                        {
                            return;
                        }
                        goto IL_107;
                    }
                }
                this.tracer.TraceError <ADObjectId, Exception>(0L, "Failed to read server object with Id {0} due to {1}", args.Id, adoperationResult.Exception);
            }
IL_107:
            base.ReadConfiguration();
        }
示例#13
0
        protected void InternalRead(IConfigurationSession session, bool force = false)
        {
            T newData = default(T);
            OrganizationProperties organizationProperties;

            if (!OrganizationPropertyCache.TryGetOrganizationProperties(this.organizationId, out organizationProperties) || force || !organizationProperties.TryGetValue <T>(out newData))
            {
                int retryCount = 3;
                ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                {
                    newData = this.Read(session);
                }, retryCount);
                if (adoperationResult.Exception != null)
                {
                    CachedOrganizationConfiguration.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToReadConfigurationFromAD, adoperationResult.Exception.GetType().FullName, new object[]
                    {
                        typeof(T).Name,
                        adoperationResult.Exception.GetType().FullName,
                        adoperationResult.Exception.Message
                    });
                    throw adoperationResult.Exception;
                }
                if (adoperationResult.Succeeded && organizationProperties != null)
                {
                    organizationProperties.SetValue <T>(newData);
                }
            }
            this.data = newData;
        }
示例#14
0
        private static bool IsInternal(string domainStringRepresentation, OrganizationId organizationId)
        {
            IConfigurationSession session = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), 145, "IsInternal", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\EdgeExtensibility\\IsInternalResolver.cs");
            ADPagedReader <Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain> acceptedDomains = null;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                acceptedDomains = session.FindAllPaged <Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain>();
            }, 3);
            foreach (Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain acceptedDomain in acceptedDomains)
            {
                if (acceptedDomain.DomainType != AcceptedDomainType.ExternalRelay)
                {
                    SmtpDomainWithSubdomains smtpDomainWithSubdomains = new SmtpDomainWithSubdomains(acceptedDomain.DomainName.Domain, acceptedDomain.DomainName.IncludeSubDomains || acceptedDomain.MatchSubDomains);
                    if (smtpDomainWithSubdomains.Match(domainStringRepresentation) >= 0)
                    {
                        return(true);
                    }
                }
            }
            ADPagedReader <DomainContentConfig> remoteDomains = null;

            ADNotificationAdapter.TryRunADOperation(delegate()
            {
                remoteDomains = session.FindAllPaged <DomainContentConfig>();
            });
            foreach (DomainContentConfig domainContentConfig in remoteDomains)
            {
                if (domainContentConfig.IsInternal && domainContentConfig.DomainName.Match(domainStringRepresentation) >= 0)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#15
0
 public static void DoAdCallAndTranslateExceptions(ADOperation call, bool expectObject, string debugContext)
 {
     Util.ThrowOnNullArgument(call, "call");
     try
     {
         ADNotificationAdapter.RunADOperation(call);
     }
     catch (DataValidationException innerException)
     {
         if (expectObject)
         {
             throw new ObjectNotFoundException(ServerStrings.ADUserNotFound, innerException);
         }
     }
     catch (DataSourceOperationException ex)
     {
         throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, null, "MigrationHelperBase::{0}. Failed for [{1}], due to directory exception.", new object[]
         {
             ex,
             debugContext
         });
     }
     catch (DataSourceTransientException ex2)
     {
         throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "MigrationHelperBase::{0}. Failed for [{1}], due to directory exception.", new object[]
         {
             ex2,
             debugContext
         });
     }
 }
        internal void ReadConfiguration()
        {
            StateType state = default(StateType);

            this.PreAdOperation(ref state);
            base.CheckDisposed();
            this.TryRegisterForADNotifications();
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                this.AdOperation(ref state);
            }, 2);

            if (adoperationResult.Succeeded)
            {
                if (this.adNotificationCookie != null)
                {
                    this.UpdateTimer(this.periodicReadInterval);
                }
            }
            else
            {
                this.LogFailure(ADConfigurationLoader <ADConfigType, StateType> .FailureLocation.ADConfigurationLoading, adoperationResult.Exception);
                if (this.adNotificationCookie != null)
                {
                    this.UpdateTimer(this.failureRetryInterval);
                }
            }
            this.PostAdOperation(state, adoperationResult.Succeeded);
        }
        private bool PopulateCache()
        {
            OrganizationBaseCache.Tracer.TraceDebug <OrganizationId>((long)this.GetHashCode(), "Searching for AcceptedDomain instances associated with OrganizationId '{0}'", base.OrganizationId);
            AcceptedDomain[]  acceptedDomains   = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                acceptedDomains = ((ITenantConfigurationSession)this.Session).FindAllAcceptedDomainsInOrg(this.OrganizationId.ConfigurationUnit);
            });

            if (!adoperationResult.Succeeded)
            {
                OrganizationBaseCache.Tracer.TraceError <OrganizationId, Exception>((long)this.GetHashCode(), "Unable to find AcceptedDomain instances associated with the OrganizationId '{0}' due to exception: {1}", base.OrganizationId, adoperationResult.Exception);
                throw adoperationResult.Exception;
            }
            if (acceptedDomains == null || acceptedDomains.Length == 0)
            {
                OrganizationBaseCache.Tracer.TraceError <OrganizationId>((long)this.GetHashCode(), "Unable to find any AcceptedDomain associated with the OrganizationId '{0}'", base.OrganizationId);
                return(adoperationResult.Succeeded);
            }
            Dictionary <string, AuthenticationType> dictionary = new Dictionary <string, AuthenticationType>(acceptedDomains.Length, StringComparer.OrdinalIgnoreCase);

            for (int i = 0; i < acceptedDomains.Length; i++)
            {
                dictionary[acceptedDomains[i].DomainName.Domain] = acceptedDomains[i].RawAuthenticationType;
            }
            this.namespaceAuthenticationTypeHash = dictionary;
            OrganizationBaseCache.Tracer.TraceDebug <EnumerableTracer <string> >((long)this.GetHashCode(), "Found the following Accepted Domains: {0}", new EnumerableTracer <string>(this.namespaceAuthenticationTypeHash.Keys));
            return(adoperationResult.Succeeded);
        }
 protected override void InternalDispose(bool disposing)
 {
     if (disposing)
     {
         if (this.periodicTimer != null)
         {
             this.periodicTimer.Dispose(true);
             lock (this.periodicTimerLock)
             {
                 this.periodicTimer = null;
             }
         }
         lock (this.notificationLock)
         {
             if (this.adNotificationCookie != null)
             {
                 ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                 {
                     ADNotificationAdapter.UnregisterChangeNotification(this.adNotificationCookie);
                 }, 2);
                 if (!adoperationResult.Succeeded)
                 {
                     this.LogFailure(ADConfigurationLoader <ADConfigType, StateType> .FailureLocation.ADNotificationRegistration, adoperationResult.Exception);
                 }
                 this.adNotificationCookie = null;
             }
             this.hasUnregisteredNotification = true;
         }
     }
 }
示例#19
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);
        }
        private ADObjectId GetPolicyIdFromAD(OrganizationId key)
        {
            ExTraceGlobals.MobileDevicePolicyTracer.Information <OrganizationId>((long)this.GetHashCode(), "MobileDevicePolicyIdCacheByOrganization.GetPolicyFromAD({0})", key);
            ADSessionSettings     settings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(key);
            IConfigurationSession session  = this.GetConfigSession(settings);
            ADObjectId            rootId   = session.GetOrgContainerId();
            QueryFilter           filter   = new BitMaskAndFilter(MobileMailboxPolicySchema.MobileFlags, 4096UL);
            SortBy     sortBy   = new SortBy(ADObjectSchema.WhenChanged, SortOrder.Descending);
            ADObjectId policyId = null;

            try
            {
                ADNotificationAdapter.RunADOperation(delegate()
                {
                    MobileMailboxPolicy[] array = session.Find <MobileMailboxPolicy>(rootId, QueryScope.SubTree, filter, sortBy, 1);
                    if (array != null && array.Length > 0)
                    {
                        policyId = array[0].Id;
                        OrgIdADObjectWrapper key2 = new OrgIdADObjectWrapper(policyId, key);
                        if (!MobileDevicePolicyCache.Instance.Contains(key2))
                        {
                            MobileDevicePolicyData mobileDevicePolicyDataFromMobileMailboxPolicy = MobileDevicePolicyDataFactory.GetMobileDevicePolicyDataFromMobileMailboxPolicy(array[0]);
                            MobileDevicePolicyCache.Instance.TryAdd(key2, ref mobileDevicePolicyDataFromMobileMailboxPolicy);
                        }
                    }
                });
            }
            catch (LocalizedException arg)
            {
                ExTraceGlobals.MobileDevicePolicyTracer.TraceError <OrganizationId, LocalizedException>((long)this.GetHashCode(), "MobileDevicePolicyIdCacheByOrganization.GetPolicyIdFromAD({0}) threw exception: {1}", key, arg);
                throw;
            }
            ExTraceGlobals.MobileDevicePolicyTracer.Information <OrganizationId, ADObjectId>((long)this.GetHashCode(), "MobileDevicePolicyIdCacheByOrganization.GetPolicyFromAD({0}) returned: {1}", key, policyId);
            return(policyId);
        }
示例#21
0
 internal override void InvokeWebService(IConfigurationSession session, EhfTargetServerConfig config, EhfProvisioningService provisioningService)
 {
     IPAddress[] array  = null;
     IPAddress[] array2 = null;
     if (this.dnsServerIPAddresses != null && this.fqdnTemplate != null)
     {
         ADSite site = null;
         ADNotificationAdapter.TryRunADOperation(delegate()
         {
             site = ((ITopologyConfigurationSession)session).GetLocalSite();
         });
         if (site == null)
         {
             base.WriteError(new InvalidOperationException("Unable to find ADSite object"), ErrorCategory.InvalidOperation, null);
         }
         Dns dns = new Dns();
         dns.Timeout    = TimeSpan.FromSeconds(30.0);
         dns.ServerList = new DnsServerList();
         dns.ServerList.Initialize(this.dnsServerIPAddresses.ToArray());
         array = this.ResolveInboundVirtualIPs(dns, site.PartnerId, this.fqdnTemplate);
     }
     if (this.outboundIPAddresses != null && this.outboundIPAddresses.Count > 0)
     {
         array2 = this.outboundIPAddresses.ToArray();
     }
     if (array != null || array2 != null)
     {
         CompanyResponseInfo companyResponseInfo = provisioningService.UpdateReseller(config.ResellerId, array, array2);
         if (companyResponseInfo.Status != ResponseStatus.Success)
         {
             this.HandleFailure(companyResponseInfo);
         }
     }
 }
示例#22
0
        private static ObjectSecurity GetServerAdminSecurity()
        {
            FileSecurity securityDescriptor = null;

            ADNotificationAdapter.TryRunADOperation(delegate()
            {
                ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 578, "GetServerAdminSecurity", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\ProcessAccessManager.cs");
                Server server = null;
                try
                {
                    server = topologyConfigurationSession.FindLocalServer();
                }
                catch (LocalServerNotFoundException)
                {
                    return;
                }
                RawSecurityDescriptor rawSecurityDescriptor = server.ReadSecurityDescriptor();
                if (rawSecurityDescriptor != null)
                {
                    securityDescriptor = new FileSecurity();
                    byte[] array       = new byte[rawSecurityDescriptor.BinaryLength];
                    rawSecurityDescriptor.GetBinaryForm(array, 0);
                    securityDescriptor.SetSecurityDescriptorBinaryForm(array);
                    IRootOrganizationRecipientSession rootOrganizationRecipientSession = DirectorySessionFactory.Default.CreateRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 605, "GetServerAdminSecurity", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\ProcessAccessManager.cs");
                    SecurityIdentifier exchangeServersUsgSid  = rootOrganizationRecipientSession.GetExchangeServersUsgSid();
                    FileSystemAccessRule fileSystemAccessRule = new FileSystemAccessRule(exchangeServersUsgSid, FileSystemRights.ReadData, AccessControlType.Allow);
                    securityDescriptor.SetAccessRule(fileSystemAccessRule);
                    SecurityIdentifier identity = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);
                    fileSystemAccessRule        = new FileSystemAccessRule(identity, FileSystemRights.ReadData, AccessControlType.Allow);
                    securityDescriptor.AddAccessRule(fileSystemAccessRule);
                    return;
                }
            }, 3);
            return(securityDescriptor);
        }
        // Token: 0x06000007 RID: 7 RVA: 0x0000254C File Offset: 0x0000074C
        protected override bool TryReadServerConfig()
        {
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                TransportADNotificationAdapter.Instance.RegisterForMsExchangeTransportServiceDeletedEvents();
            }, 0);

            if (!adoperationResult.Succeeded)
            {
                TransportService.logger.LogEvent(TransportEventLogConstants.Tuple_FailedToRegisterForDeletedObjectsNotification, null, new object[]
                {
                    adoperationResult.Exception
                });
                ExTraceGlobals.ServiceTracer.TraceError <Exception>(0L, "Failed to register for Deleted object notifications. Details {0}", adoperationResult.Exception);
                ProcessManagerService.StopService();
            }
            this.readingConfigOnStart = true;
            ADOperationResult adoperationResult2;
            bool flag = this.ReadServerConfig(out adoperationResult2);

            this.readingConfigOnStart = false;
            if (!flag)
            {
                this.GenerateConfigFailureEventLog(adoperationResult2.Exception);
                return(false);
            }
            return(true);
        }
示例#24
0
 private static void SubscribeForNotifications()
 {
     if (LocalServerCache.notification == null && LocalServerCache.localServer != null)
     {
         LocalServerCache.notification = ADNotificationAdapter.RegisterChangeNotification <Server>(LocalServerCache.localServer.Id, new ADNotificationCallback(LocalServerCache.NotificationHandler));
     }
 }
示例#25
0
        private bool TrySetExternalOrgId(OrganizationId orgId)
        {
            if (orgId.Equals(OrganizationId.ForestWideOrgId))
            {
                this.externalOrganizationIdString = string.Empty;
                return(true);
            }
            ExchangeConfigurationUnit configUnitPassedToDelegate = null;
            Guid empty = Guid.Empty;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                IConfigurationSession configurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId), 241, "TrySetExternalOrgId", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\DirectoryContext.cs");
                configUnitPassedToDelegate = configurationSession.Read <ExchangeConfigurationUnit>(orgId.ConfigurationUnit);
            });

            if (!adoperationResult.Succeeded)
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string, Exception>(0, "Failed to get ExternalOrgId from AD. {0} Error: {1}", (adoperationResult.ErrorCode == ADOperationErrorCode.PermanentError) ? "Permanent" : "Retriable", adoperationResult.Exception);
                return(false);
            }
            if (configUnitPassedToDelegate == null || !Guid.TryParse(configUnitPassedToDelegate.ExternalDirectoryOrganizationId, out empty))
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Failed read ExternalOrgId from AD Session", new object[0]);
                return(false);
            }
            this.externalOrganizationIdString = empty.ToString();
            return(true);
        }
示例#26
0
        private TransportService GetDefaultTransportServiceRole()
        {
            ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 258, "GetDefaultTransportServiceRole", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\AgentLog\\GetAgentLog.cs");
            Server            localServer         = null;
            ADOperationResult adoperationResult   = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                localServer = session.FindLocalServer();
            });

            if (!adoperationResult.Succeeded)
            {
                base.WriteError(adoperationResult.Exception, ErrorCategory.ReadError, null);
            }
            ServerRole currentServerRole = localServer.CurrentServerRole;

            if ((currentServerRole & ServerRole.HubTransport) != ServerRole.None)
            {
                return(TransportService.Hub);
            }
            if ((currentServerRole & ServerRole.Edge) != ServerRole.None)
            {
                return(TransportService.Edge);
            }
            if ((currentServerRole & ServerRole.FrontendTransport) != ServerRole.None)
            {
                return(TransportService.FrontEnd);
            }
            if ((currentServerRole & ServerRole.Mailbox) != ServerRole.None)
            {
                return(TransportService.MailboxDelivery);
            }
            return(TransportService.Hub);
        }
        public static MultiValuedProperty <CredentialRecord> Load(Server edgeServer)
        {
            ITopologyConfigurationSession          configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 103, "Load", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\Common\\Validation\\CredentialRecord.cs");
            MultiValuedProperty <CredentialRecord> credentialRecords    = new MultiValuedProperty <CredentialRecord>();

            ADNotificationAdapter.TryReadConfigurationPaged <Server>(() => configurationSession.FindAllServersWithVersionNumber(Server.E2007MinVersion), delegate(Server server)
            {
                if (server.IsHubTransportServer && server.EdgeSyncCredentials != null && server.EdgeSyncCredentials.Count != 0)
                {
                    foreach (byte[] data in server.EdgeSyncCredentials)
                    {
                        EdgeSyncCredential edgeSyncCredential = EdgeSyncCredential.DeserializeEdgeSyncCredential(data);
                        if (edgeSyncCredential.EdgeServerFQDN.Equals(edgeServer.Fqdn, StringComparison.OrdinalIgnoreCase))
                        {
                            CredentialRecord credentialRecord     = new CredentialRecord();
                            credentialRecord.TargetEdgeServerFQDN = edgeSyncCredential.EdgeServerFQDN;
                            credentialRecord.ESRAUsername         = edgeSyncCredential.ESRAUsername;
                            credentialRecord.EffectiveDate        = new DateTime(edgeSyncCredential.EffectiveDate).ToLocalTime();
                            credentialRecord.Duration             = new TimeSpan(edgeSyncCredential.Duration);
                            credentialRecord.IsBootStrapAccount   = edgeSyncCredential.IsBootStrapAccount;
                            credentialRecords.Add(credentialRecord);
                        }
                    }
                }
            });
            return(credentialRecords);
        }
 // Token: 0x0600002B RID: 43 RVA: 0x000035DC File Offset: 0x000017DC
 internal override void OnStart()
 {
     lock (ModeratedDLApplication.SyncRoot)
     {
         if (ModeratedDLApplication.refCount == 0)
         {
             MessageTrackingLog.Start("MSGTRKMA");
             Server server = null;
             ADNotificationAdapter.TryRunADOperation(delegate()
             {
                 ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 144, "OnStart", "f:\\15.00.1497\\sources\\dev\\Approval\\src\\Applications\\ModeratedDLApplication\\ModeratedDLApplication.cs");
                 this.serverConfigNotificationCookie = ADNotificationAdapter.RegisterChangeNotification <Server>(topologyConfigurationSession.GetOrgContainerId(), new ADNotificationCallback(ModeratedDLApplication.ServerChangeCallback));
                 server = topologyConfigurationSession.ReadLocalServer();
                 Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain acceptedDomain = topologyConfigurationSession.GetDefaultAcceptedDomain();
                 if (acceptedDomain != null && acceptedDomain.DomainName.SmtpDomain != null)
                 {
                     this.defaultAcceptedDomain = acceptedDomain.DomainName.SmtpDomain.Domain;
                 }
             });
             if (server == null)
             {
                 ModeratedDLApplication.diag.TraceError((long)this.GetHashCode(), "Cannot read local server for message tracking");
             }
             MessageTrackingLog.Configure(server);
         }
         ModeratedDLApplication.refCount++;
     }
     base.OnStart();
 }
示例#29
0
        internal T FindSiteEdgeSyncConnector <T>(IConfigurationSession session, ADObjectId siteId, out bool hasOneConnectorEnabledInCurrentForest) where T : EdgeSyncConnector, new()
        {
            List <T> connectors = new List <T>();

            hasOneConnectorEnabledInCurrentForest = true;
            ADNotificationAdapter.ReadConfigurationPaged <T>(() => session.FindPaged <T>(siteId, QueryScope.SubTree, null, null, 0), delegate(T connector)
            {
                if (connector.Enabled)
                {
                    connectors.Add(connector);
                }
            }, 3);
            if (connectors.Count == 0)
            {
                ADNotificationAdapter.ReadConfigurationPaged <T>(() => session.FindPaged <T>(null, QueryScope.SubTree, null, null, 0), delegate(T connector)
                {
                    if (connector.Enabled)
                    {
                        connectors.Add(connector);
                    }
                }, 3);
                hasOneConnectorEnabledInCurrentForest = (connectors.Count > 0);
                return(default(T));
            }
            return(connectors[0]);
        }
        // Token: 0x060000BA RID: 186 RVA: 0x0000843C File Offset: 0x0000663C
        private bool CleanUpMangledDevices(List <MobileDevice> mobileDevices, out int noOfDevicesRemoved)
        {
            noOfDevicesRemoved = 0;
            ExDateTime utcNow = ExDateTime.UtcNow;

            for (int i = mobileDevices.Count - 1; i >= 0; i--)
            {
                MobileDevice device = mobileDevices[i];
                if (ADDeviceManager.DnIsMangled(device.Name) || ADDeviceManager.DnIsMangled(device.DeviceId))
                {
                    ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                    {
                        this.session.Delete(device);
                    });
                    if (!adoperationResult.Succeeded)
                    {
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during . Message:{0}", adoperationResult.Exception.Message);
                    }
                    noOfDevicesRemoved++;
                    mobileDevices.RemoveAt(i);
                }
                TimeSpan t = ExDateTime.UtcNow.Subtract(utcNow);
                if (t >= GlobalSettings.MaxCleanUpExecutionTime)
                {
                    AirSyncDiagnostics.TraceDebug <int, double>(ExTraceGlobals.RequestsTracer, null, "Done Cleaning up stale devices. DevicesCleaned:{0}, ExecutionTime(in ms):{1}", noOfDevicesRemoved, t.TotalMilliseconds);
                    return(false);
                }
            }
            return(true);
        }