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); }
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); }
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); } } }
// 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); }
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); }
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 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); }
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); }
private static PolicyData LoadDefaultPolicySetting(IConfigurationSession scopedSession, ProtocolLogger protocolLogger) { MobileMailboxPolicy[] mobileMaiboxPolicies = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { mobileMaiboxPolicies = scopedSession.Find <MobileMailboxPolicy>(scopedSession.GetOrgContainerId().GetDescendantId(new ADObjectId("CN=Mobile Mailbox Policies")), QueryScope.OneLevel, ADNotificationManager.filter, ADNotificationManager.sortBy, 3); }); if (!adoperationResult.Succeeded) { AirSyncDiagnostics.TraceDebug <ADObjectId, string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during LoadDefaultPolicySettings for OrgID {0}. Message - {1}", scopedSession.GetOrgContainerId(), adoperationResult.Exception.Message); throw adoperationResult.Exception; } protocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc); if (mobileMaiboxPolicies == null || mobileMaiboxPolicies.Length == 0) { AirSyncDiagnostics.TraceInfo <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "no default policy setting found for OrgId {0}", scopedSession.GetOrgContainerId()); return(null); } AirSyncDiagnostics.TraceInfo <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "LoadDefaultPolicySetting from AD.Policy Id {0}", mobileMaiboxPolicies[0].Id); if (mobileMaiboxPolicies.Length > 1) { ADNotificationManager.HandleMultipleDefaultPolicies(mobileMaiboxPolicies, scopedSession.GetOrgContainerId(), protocolLogger); protocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc); } return(ADNotificationManager.AddPolicyToCache(mobileMaiboxPolicies[0], scopedSession.SessionSettings.CurrentOrganizationId.PartitionId)); }
// 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); }
public static EdgeSyncEhfConnector GetConnector(IConfigurationSession session, EdgeSyncEhfConnectorIdParameter connectorId, Task task) { EdgeSyncEhfConnector connector = null; ADNotificationAdapter.TryRunADOperation(delegate() { if (connectorId != null) { if (connectorId.InternalADObjectId != null) { connector = session.Read <EdgeSyncEhfConnector>(connectorId.InternalADObjectId); return; } } else { connector = Utils.FindEnabledEhfSyncConnector(session, null); } }); if (connector == null) { task.WriteError(new InvalidOperationException("Unable to find EHF connector object"), ErrorCategory.InvalidOperation, null); } return(connector); }
private IList <Guid> FindLocalDatabasesFromAD() { MailboxDatabase[] databases = null; IList <Guid> list = new List <Guid>(); ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { databases = this.GetLocalServer().GetMailboxDatabases(); }); if (adoperationResult.ErrorCode != ADOperationErrorCode.Success || databases == null) { return(list); } foreach (MailboxDatabase mailboxDatabase in databases) { bool flag = mailboxDatabase.IsValid && mailboxDatabase.Mounted != null && mailboxDatabase.Mounted.Value; if (flag) { list.Add(mailboxDatabase.Guid); } else { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, string.Format("FindLocalDatabasesFromAD: skip offline database {0}", mailboxDatabase.Guid), null); } } this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, string.Format("FindLocalDatabasesFromAD: found {0} database on local server", list.Count), null); return(list); }
protected override ServiceEndpoint CreateOnCacheMiss(string serviceEndpointId, ref bool shouldAdd) { WeatherConfigurationCache.Tracer.TraceDebug <string>((long)this.GetHashCode(), "WeatherConfigurationCache.CreateOnCacheMiss called for service endpoint id: {0}", serviceEndpointId); ServiceEndpoint endpoint = null; try { ADNotificationAdapter.TryRunADOperation(delegate() { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.FullyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 259, "CreateOnCacheMiss", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ConfigurationCache\\WeatherConfigurationCache.cs"); ServiceEndpointContainer endpointContainer = topologyConfigurationSession.GetEndpointContainer(); endpoint = endpointContainer.GetEndpoint(serviceEndpointId); }); } catch (EndpointContainerNotFoundException) { WeatherConfigurationCache.Tracer.TraceDebug(0L, "WeatherConfigurationCache: Endpoint Container doesn't exist."); } catch (ServiceEndpointNotFoundException) { WeatherConfigurationCache.Tracer.TraceDebug <string>(0L, "WeatherConfigurationCache: Endpoint '{0}' doesn't exist.", serviceEndpointId); } catch (LocalizedException arg) { WeatherConfigurationCache.Tracer.TraceError <LocalizedException>(0L, "WeatherConfigurationCache: Unable to read service endpoint due to exception: {0}", arg); } return(endpoint); }
private VariantConfigurationSnapshot GetDiagnosticInfoSnapshot(SettingOverrideSync.SettingOverrideDiagnosableArgument argument, out string error) { IConstraintProvider constraintProvider = MachineSettingsContext.Local; if (argument.HasArgument("user")) { string userId = argument.GetArgument <string>("user"); if (!string.IsNullOrWhiteSpace(userId)) { string orgId = null; if (argument.HasArgument("org")) { orgId = argument.GetArgument <string>("org"); } if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled&& string.IsNullOrEmpty(orgId)) { error = "Org is required."; return(null); } ADUser user = null; ADNotificationAdapter.TryRunADOperation(delegate() { user = new SettingOverrideSync.UserResolver(userId, orgId).Resolve(); }, 3); if (user == null) { error = "User not found."; return(null); } constraintProvider = user.GetContext(null); } } error = null; return(VariantConfiguration.GetSnapshot(constraintProvider, null, null)); }
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; }
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); }
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); } }
// 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(); }
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"); }
// Token: 0x06000092 RID: 146 RVA: 0x000041E3 File Offset: 0x000023E3 protected override void InternalExecute() { ADNotificationAdapter.TryRunADOperation(delegate() { this.InternalTaskExecute(); }); }
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)); }
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); }
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 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); } }
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; } } }
// 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); }
// Token: 0x0600108F RID: 4239 RVA: 0x00060D40 File Offset: 0x0005EF40 private ADOperationResult TryRunPerGroupADOperation(ADOperation adOperation, string groupDN) { ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(adOperation, 3); switch (adoperationResult.ErrorCode) { case ADOperationErrorCode.RetryableError: GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_GroupExpansionHaltedWarning, this.GetOrganizationIdString(), new object[] { adoperationResult.Exception.GetType().Name, groupDN, adoperationResult.Exception }); break; case ADOperationErrorCode.PermanentError: GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_GroupExpansionHaltedError, this.GetOrganizationIdString(), new object[] { adoperationResult.Exception.GetType().Name, groupDN, adoperationResult.Exception }); break; } return(adoperationResult); }
private void ProcessAllFederationTrusts() { FederationTrust[] federationTrusts = null; this.Context.Logger.Log(MigrationEventType.Information, "Retrieving Federation Trust Configuration", new object[0]); ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { ADObjectId orgContainerId = this.session.GetOrgContainerId(); ADObjectId descendantId = orgContainerId.GetDescendantId(FederationTrust.FederationTrustsContainer); federationTrusts = this.session.Find <FederationTrust>(descendantId, QueryScope.SubTree, null, null, ADGenericPagedReader <FederationTrust> .DefaultPageSize); }); if (adoperationResult != ADOperationResult.Success) { this.Context.Logger.Log(MigrationEventType.Warning, "Unable to read Federation Trusts, result = {0}", new object[] { adoperationResult.ErrorCode.ToString() }); if (adoperationResult.Exception != null && adoperationResult.Exception is TransientException) { throw adoperationResult.Exception; } return; } else { if (federationTrusts == null) { this.Context.Logger.Log(MigrationEventType.Information, "No Federation Trusts found", new object[0]); return; } foreach (FederationTrust federationTrust in federationTrusts) { if (this.StopEvent.WaitOne(0, false)) { return; } this.Context.Logger.Log(MigrationEventType.Information, "Processing Federation Trust {0}", new object[] { federationTrust.Name }); if (federationTrust.TokenIssuerMetadataEpr == null) { this.Context.Logger.LogTerseEvent(MigrationEventType.Error, MSExchangeAuthAdminEventLogConstants.Tuple_InvalidTrustedIssuerConfiguration, new string[] { federationTrust.Name }); } else if (this.ProcessFederationTrust(federationTrust)) { this.session.Save(federationTrust); this.Context.Logger.LogTerseEvent(MigrationEventType.Information, MSExchangeAuthAdminEventLogConstants.Tuple_TrustedIssuerUpdated, new string[] { federationTrust.Name }); } } return; } }
private static ADOperationResult GetLocalServer() { return(ADNotificationAdapter.TryRunADOperation(delegate() { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 246, "GetLocalServer", "f:\\15.00.1497\\sources\\dev\\Management\\src\\ServiceHost\\Servicelets\\DiagnosticsAggregation\\Program\\DiagnosticsAggregationServicelet.cs"); DiagnosticsAggregationServicelet.localServer = topologyConfigurationSession.FindLocalServer(); })); }
public static bool TryLoadLocalSiteTopology(string domainController, out ReplicationTopology topology, out Exception exception) { topology = null; exception = null; ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 154, "TryLoadLocalSiteTopology", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\Common\\Validation\\ReplicationTopology.cs"); ADSite localSite = null; EdgeSyncServiceConfig edgeSyncServiceConfig = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { localSite = session.GetLocalSite(); if (localSite == null) { throw new ADTransientException(Strings.CannotGetLocalSite); } edgeSyncServiceConfig = session.Read <EdgeSyncServiceConfig>(localSite.Id.GetChildId("EdgeSyncService")); }, 3); if (!adoperationResult.Succeeded) { exception = adoperationResult.Exception; return(false); } if (edgeSyncServiceConfig == null) { topology = new ReplicationTopology(session, null, localSite, null); return(true); } ReplicationTopology resultTopology = null; adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { Server server = session.FindLocalServer(); resultTopology = new ReplicationTopology(session, server, localSite, edgeSyncServiceConfig); QueryFilter filter = Util.BuildServerFilterForSite(localSite.Id); ADPagedReader <Server> adpagedReader = session.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0); resultTopology.siteEdgeServers.Clear(); resultTopology.siteHubServers.Clear(); foreach (Server server2 in adpagedReader) { if (server2.IsEdgeServer) { resultTopology.siteEdgeServers.Add(server2); } if (server2.IsHubTransportServer) { resultTopology.siteHubServers.Add(server2); } } }, 3); if (!adoperationResult.Succeeded) { exception = adoperationResult.Exception; return(false); } topology = resultTopology; return(true); }