private static bool LoadAcceptedDomain(ExSearchResultEntry entry, Connection sourceConnection, TargetConnection targetConnection, object state) { EhfConfigTargetConnection ehfConfigTargetConnection = (EhfConfigTargetConnection)targetConnection; if (!EhfSynchronizer.LoadFullEntry(entry, EhfDomainSynchronizer.AcceptedDomainAllAttributes, ehfConfigTargetConnection)) { return(false); } if (!EhfDomainSynchronizer.ValidateDomainName(entry, ehfConfigTargetConnection.DiagSession)) { return(false); } string configUnitDN = null; if (!EhfDomainSynchronizer.TryGetConfigUnit(entry, ehfConfigTargetConnection.DiagSession, out configUnitDN)) { return(false); } EhfCompanyIdentity ehfCompanyIdentity; if (!ehfConfigTargetConnection.TryGetEhfCompanyIdentity(configUnitDN, "ignoring the object", out ehfCompanyIdentity)) { return(false); } EhfDomainSynchronizer.AddAttributeToChangeEntry(entry, "msExchTenantPerimeterSettingsOrgID", ehfCompanyIdentity.EhfCompanyId.ToString()); EhfDomainSynchronizer.AddAttributeToChangeEntry(entry, "msEdgeSyncEhfCompanyGuid", ehfCompanyIdentity.EhfCompanyGuid.ToString()); return(true); }
private EhfConfigTargetConnection.ConfigObjectType GetSyncObjectType(ExSearchResultEntry entry, string operation) { string objectClass = entry.ObjectClass; if (string.IsNullOrEmpty(objectClass)) { base.DiagSession.LogAndTraceError("Entry <{0}> contains no objectClass attribute in operation {1}; cannot proceed", new object[] { entry.DistinguishedName, operation }); throw new ArgumentException("Entry does not contain objectClass attribute", "entry"); } string a; if ((a = objectClass) != null) { if (a == "msExchAcceptedDomain") { return(EhfConfigTargetConnection.ConfigObjectType.AcceptedDomain); } if (a == "msExchTenantPerimeterSettings") { return(EhfConfigTargetConnection.ConfigObjectType.PerimeterSettings); } } base.DiagSession.LogAndTraceError("Entry <{0}> contains unexpected objectClass value <{1}> in operation {2}; cannot proceed", new object[] { entry.DistinguishedName, objectClass, operation }); throw new ArgumentException("Entry's objectClass is invalid: " + objectClass, "entry"); }
private static bool IsPartnerManagedGroup(ExSearchResultEntry searchEntry, EdgeSyncDiag diagSession) { DirectoryAttribute directoryAttribute; if (!searchEntry.Attributes.TryGetValue("msExchCapabilityIdentifiers", out directoryAttribute) || directoryAttribute == null) { return(false); } foreach (object obj in directoryAttribute.GetValues(typeof(string))) { string text = obj as string; if (!string.IsNullOrEmpty(text)) { Capability capability; if (EnumValidator.TryParse <Capability>(text, EnumParseOptions.AllowNumericConstants | EnumParseOptions.IgnoreCase, out capability)) { if (capability == Capability.Partner_Managed) { return(true); } } else { diagSession.LogAndTraceError("Capability value '{0}' is not in the expected format on the object '{1}'", new object[] { text, searchEntry.DistinguishedName }); } } } return(false); }
public override void HandleDeletedDomain(ExSearchResultEntry entry) { base.HandleDeletedDomain(entry); EhfDomainItem domain = EhfDomainItemVersion2.CreateForOutboundOnlyTombstone(entry, base.DiagSession); base.AddDomainToDisableBatch(domain); }
private EhfAdminSyncChangeBuilder GetAdminBuilderForChange(ExSearchResultEntry entry) { string text; if (!EhfAdminAccountSynchronizer.TryGetOrganizationUnit(entry, base.DiagSession, out text)) { return(null); } EhfAdminSyncChangeBuilder ehfAdminSyncChangeBuilder; if (!this.adminAccountChange.TryGetValue(text, out ehfAdminSyncChangeBuilder)) { DirectoryAttribute attribute = entry.GetAttribute("msExchCU"); if (attribute == null) { base.DiagSession.LogAndTraceError("Could not find ConfigUnitDN for {0}. Every object is expected to contain this attribute.", new object[] { entry.DistinguishedName }); return(null); } string tenantConfigUnitDN = (string)attribute[0]; ehfAdminSyncChangeBuilder = new EhfAdminSyncChangeBuilder(text, tenantConfigUnitDN, base.EhfConnection); this.adminAccountChange.Add(text, ehfAdminSyncChangeBuilder); } return(ehfAdminSyncChangeBuilder); }
private bool TryGetCompanyState(string ouDN, EhfTargetConnection targetConnection, EhfADAdapter configADAdapter, out EhfAdminSyncState adminSyncState) { EhfADAdapter adadapter = this.ehfTargetConnection.ADAdapter; adminSyncState = null; ExSearchResultEntry exSearchResultEntry = adadapter.ReadObjectEntry(ouDN, false, EhfCompanyAdmins.ConfigUnitAttribute); if (exSearchResultEntry == null) { targetConnection.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Could not load object with DN <{0}>; Cannot determine the CompanyId", new object[] { ouDN }); return(false); } DirectoryAttribute attribute = exSearchResultEntry.GetAttribute("msExchCU"); if (attribute == null) { targetConnection.DiagSession.LogAndTraceError("Could not load the Configuration Containter for {0}", new object[] { ouDN }); return(false); } string configUnitDN = (string)attribute[0]; return(EhfCompanySynchronizer.TryGetEhfAdminSyncState(configUnitDN, configADAdapter, targetConnection, "Ignoring admin account changes, will retry in next sync cycle", out adminSyncState)); }
protected virtual bool CompareAttributes(ExSearchResultEntry edgeEntry, ExSearchResultEntry hubEntry, string[] copyAttributes) { int i = 0; while (i < copyAttributes.Length) { string key = copyAttributes[i]; bool flag = edgeEntry.Attributes.ContainsKey(key); bool flag2 = hubEntry.Attributes.ContainsKey(key); bool result; if (flag != flag2) { result = false; } else { if (!flag || this.CompareAttributeValues(edgeEntry.Attributes[key], hubEntry.Attributes[key])) { i++; continue; } result = false; } return(result); } return(true); }
private static bool TryGetMailFlowConnectorId(ExSearchResultEntry entry, string attribute, EdgeSyncDiag diagSession, out int connectorId) { connectorId = EhfDomainSynchronizerVersion2.InvalidConnectorId; DirectoryAttribute attribute2 = entry.GetAttribute(attribute); if (attribute2 == null) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.High, "ConnectorId is null or empty for <{0}>:<{1}>", new object[] { attribute, entry.DistinguishedName }); return(false); } string text = (string)attribute2[0]; if (string.IsNullOrEmpty(text)) { return(false); } if (int.TryParse(text, out connectorId)) { return(true); } diagSession.LogAndTraceError("ConnectorId '{0}' is not in the expected format for <{1}>:<{2}>", new object[] { text, attribute, entry.DistinguishedName }); return(false); }
private static bool TryGetConfigUnit(ExSearchResultEntry entry, EdgeSyncDiag diagSession, out string configUnitDN) { configUnitDN = null; DirectoryAttribute attribute = entry.GetAttribute("msExchCU"); if (attribute != null) { configUnitDN = (string)attribute[0]; } if (string.IsNullOrEmpty(configUnitDN)) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "ConfigUnit root DN is not specified for accepted domain with DN <{0}>; ignoring the object", new object[] { entry.DistinguishedName }); return(false); } if (ExSearchResultEntry.IsDeletedDN(configUnitDN)) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "ConfigUnit root DN <{0}> for accepted domain with DN <{1}> indicates that tenant organization is deleted; ignoring the object", new object[] { configUnitDN, entry.DistinguishedName }); configUnitDN = null; return(false); } return(true); }
private void CreateEhfDomainForNewCompany(ExSearchResultEntry entry, int ehfCompanyId) { EhfDomainItem ehfDomainItem = this.CreateDomainItemForNewCompany(entry, ehfCompanyId); if (ehfDomainItem == null) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Ignoring domain <{0}> for newly-created EHF company <{1}>", new object[] { entry.DistinguishedName, ehfCompanyId }); return; } if (!EhfDomainSynchronizer.ValidateDomainName(entry, base.DiagSession)) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Ignoring unsupported domain <{0}> for newly-created EHF company <{1}>", new object[] { entry.DistinguishedName, ehfCompanyId }); return; } base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Creating domain <{0}> for newly-created EHF company <{1}>", new object[] { entry.DistinguishedName, ehfCompanyId }); this.AddDomainToCreateBatch(ehfDomainItem); }
protected static int GetFlagsValue(string flagsAttrName, ExSearchResultEntry resultEntry, EhfSyncItem syncItem) { DirectoryAttribute attribute = resultEntry.GetAttribute(flagsAttrName); if (attribute == null) { return(0); } string text = (string)attribute[0]; if (string.IsNullOrEmpty(text)) { return(0); } int result; if (!int.TryParse(text, out result)) { syncItem.AddSyncError(syncItem.DiagSession.LogAndTraceError("Unable to parse flags value ({0}) of attribute {1} for AD object ({2}); using default value 0", new object[] { text, flagsAttrName, resultEntry.DistinguishedName })); } return(result); }
public void HandleGroupDeletedEvent(ExSearchResultEntry entry) { if (EhfAdminAccountSynchronizer.IsEventForDeletedOrganization(entry, base.DiagSession)) { throw new InvalidOperationException("Change entry " + entry.DistinguishedName + " is for a deleted organization. The entry should have been ignored from PreDecorate."); } EhfAdminSyncChangeBuilder adminBuilderForChange = this.GetAdminBuilderForChange(entry); base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Encountered a DELETE rolegroup event. ObjectGuid: <{0}>; Company: <{1}>", new object[] { entry.GetObjectGuid(), adminBuilderForChange.TenantOU }); if (adminBuilderForChange != null) { adminBuilderForChange.HandleGroupDeletedEvent(entry); } if (!EhfWellKnownGroup.IsWellKnownPartnerGroupDN(entry.DistinguishedName)) { return; } Guid externalDirectoryObjectId; if (EhfCompanyAdmins.TryGetExternalDirectoryObjectId(entry, base.DiagSession, out externalDirectoryObjectId)) { this.AddGroupToDeleteGroupsBatch(externalDirectoryObjectId); return; } base.DiagSession.LogAndTraceError("Could not find the ExternalDirectoryObjectId for well known partner group {0}", new object[] { entry.DistinguishedName }); }
public void AddGroupMembershipChange(ExSearchResultEntry change) { if (this.IsFullTenantAdminSyncRequired()) { return; } if (EhfWellKnownGroup.IsOrganizationManagementGroup(change)) { this.updateOrgManagementGroup = true; } else if (EhfWellKnownGroup.IsViewOnlyOrganizationManagementGroup(change)) { this.updateViewOnlyOrgManagementGroup = true; } else if (EhfWellKnownGroup.IsAdminAgentGroup(change.DistinguishedName)) { this.updateAdminAgentGroup = true; } else if (EhfWellKnownGroup.IsHelpdeskAgentGroup(change.DistinguishedName)) { this.updateHelpdeskAgentGroup = true; } if (this.IsFullTenantAdminSyncRequired()) { this.ClearCachedChanges(); } else { this.groupChanges.Add(change); } this.SetFullTenantAdminSyncIfTooManyCachedChanges(); }
private bool TryGetEhfMailFlowPartnerFromAD(string mailFlowPartnerDN, out EhfDomainSynchronizerVersion2.EhfMailFlowPartner ehfMailFlowPartner) { ehfMailFlowPartner = null; ExSearchResultEntry exSearchResultEntry = base.EhfConnection.ADAdapter.ReadObjectEntry(mailFlowPartnerDN, false, EhfDomainSynchronizerVersion2.MailFlowPartnerAttributes); if (exSearchResultEntry != null) { int invalidConnectorId = EhfDomainSynchronizerVersion2.InvalidConnectorId; int invalidConnectorId2 = EhfDomainSynchronizerVersion2.InvalidConnectorId; if (!EhfDomainSynchronizerVersion2.TryGetMailFlowConnectorId(exSearchResultEntry, "msExchTransportResellerSettingsInboundGatewayID", base.DiagSession, out invalidConnectorId)) { base.DiagSession.LogAndTraceError("Failed to get the Inbound connectorId for partner <{0}>", new object[] { mailFlowPartnerDN }); } if (!EhfDomainSynchronizerVersion2.TryGetMailFlowConnectorId(exSearchResultEntry, "msExchTransportResellerSettingsOutboundGatewayID", base.DiagSession, out invalidConnectorId2)) { base.DiagSession.LogAndTraceError("Failed to get the Outbound connectorId for partner <{0}>", new object[] { mailFlowPartnerDN }); } ehfMailFlowPartner = new EhfDomainSynchronizerVersion2.EhfMailFlowPartner(invalidConnectorId, invalidConnectorId2); return(true); } return(false); }
public static EhfDomainItem CreateForOutboundOnlyTombstone(ExSearchResultEntry entry, EdgeSyncDiag diagSession) { EhfDomainItem ehfDomainItem = EhfDomainItem.CreateForTombstone(entry, diagSession); ehfDomainItem.Domain.Name = AcceptedDomain.FormatEhfOutboundOnlyDomainName(ehfDomainItem.Domain.Name, ehfDomainItem.Domain.DomainGuid.Value); return(ehfDomainItem); }
public void HandleOrganizationDeletedEvent(ExSearchResultEntry entry) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Ignoring the Organization Delete event for org {0}", new object[] { entry.DistinguishedName }); }
public static bool TryGetExternalDirectoryObjectId(ExSearchResultEntry entry, EdgeSyncDiag diagSession, out Guid externalDirectoryObjectId) { externalDirectoryObjectId = Guid.Empty; DirectoryAttribute attribute = entry.GetAttribute("msExchExternalDirectoryObjectId"); if (attribute == null || attribute.Count == 0) { diagSession.LogAndTraceError("msExchExternalDirectoryObjectId attribute is not set on '{0}'", new object[] { entry.DistinguishedName }); return(false); } string text = (string)attribute[0]; if (!GuidHelper.TryParseGuid(text, out externalDirectoryObjectId)) { diagSession.LogAndTraceError("msExchExternalDirectoryObjectId attribute in '{0}' is set to an invalid Guid '{1}'", new object[] { entry.DistinguishedName, text }); return(false); } return(true); }
public override SyncResult OnDeleteEntry(ExSearchResultEntry entry) { EhfRecipientTargetConnection.AdminObjectType syncObjectType = this.GetSyncObjectType(entry, "Delete"); SyncResult result; switch (syncObjectType) { case EhfRecipientTargetConnection.AdminObjectType.MailboxUser: this.adminSync.HandleWlidDeletedEvent(entry); result = SyncResult.Deleted; break; case EhfRecipientTargetConnection.AdminObjectType.Organization: this.adminSync.HandleOrganizationDeletedEvent(entry); result = SyncResult.Deleted; break; case EhfRecipientTargetConnection.AdminObjectType.UniversalSecurityGroup: this.adminSync.HandleGroupDeletedEvent(entry); result = SyncResult.Deleted; break; default: throw new InvalidOperationException("EhfRecipientTargetConnection.GetSyncObjectType() returned unexpected value " + syncObjectType); } return(result); }
public void HandleOrganizationAddedEvent(ExSearchResultEntry entry) { this.ehfTargetConnection.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.High, "Encountered a ADD organization event. The org '{0}' is set to do a complete adminsync", new object[] { this.tenantOU }); this.SetFullTenantAdminSyncRequired(); }
private static bool IsEntryMailEnabledUser(ExSearchResultEntry entry, RecipientTypeDetails recipientTypeDetail) { if (recipientTypeDetail != RecipientTypeDetails.None) { return(recipientTypeDetail == RecipientTypeDetails.MailUser); } return(entry.Attributes.ContainsKey("mailNickname") && !entry.Attributes.ContainsKey("msExchHomeServerName")); }
public bool FilterOrLoadFullEntry(ExSearchResultEntry entry) { bool flag = false; string tenantOU; bool isOrgChange; return(this.TryGetTenantOrgUnitDNForChange(entry, out tenantOU, out isOrgChange, ref flag) && !this.IgnoreChange(entry, tenantOU, isOrgChange, ref flag) && (flag || EhfSynchronizer.LoadFullEntry(entry, EhfAdminAccountSynchronizer.AdminSyncAllAttributes, base.EhfConnection))); }
public void HandleWlidDeletedEvent(ExSearchResultEntry entry) { if (this.IsFullTenantAdminSyncRequired()) { return; } this.deletedObjects.Add(entry.GetObjectGuid()); this.SetFullTenantAdminSyncIfTooManyCachedChanges(); }
public void AddWlidChanges(ExSearchResultEntry change) { if (this.IsFullTenantAdminSyncRequired()) { return; } this.liveIdChanges.Add(change); this.SetFullTenantAdminSyncIfTooManyCachedChanges(); }
public static EhfCompanyAdmins CreateEhfCompanyAdmins(EhfAdminSyncChangeBuilder ehfAdminSyncChangeBuilder, EhfTargetConnection ehfTargetConnection, EhfADAdapter configADAdapter) { ExSearchResultEntry exSearchResultEntry = configADAdapter.ReadObjectEntry(ehfAdminSyncChangeBuilder.ConfigUnitDN, false, EhfCompanyAdmins.OtherWellKnownObjectsAttribute); if (exSearchResultEntry == null) { ehfTargetConnection.DiagSession.LogAndTraceError("Could not find Configuration Unit for company {0}. The config naming context is either not replicated or the organization is deleted", new object[] { ehfAdminSyncChangeBuilder.TenantOU }); return(null); } string text = null; string text2 = null; DirectoryAttribute attribute = exSearchResultEntry.GetAttribute("otherWellKnownObjects"); if (attribute == null) { ehfTargetConnection.DiagSession.LogAndTraceError("Could not find OtherWellKnownObjects attribute in Configuration Unit object for company {0}.", new object[] { ehfAdminSyncChangeBuilder.TenantOU }); return(null); } foreach (object obj in attribute.GetValues(typeof(string))) { DNWithBinary dnwithBinary; if (DNWithBinary.TryParse(obj as string, out dnwithBinary)) { try { Guid b = new Guid(dnwithBinary.Binary); if (WellKnownGuid.EoaWkGuid == b) { text = dnwithBinary.DistinguishedName; } if (WellKnownGuid.EraWkGuid == b) { text2 = dnwithBinary.DistinguishedName; } if (text != null && text2 != null) { break; } } catch (ArgumentException exception) { ehfTargetConnection.DiagSession.LogAndTraceException(exception, "OtherWellKnownObjects attribute for company {0} contains an entry with invalid Binary part.", new object[] { ehfAdminSyncChangeBuilder.TenantOU }); } } } return(new EhfCompanyAdmins(ehfAdminSyncChangeBuilder, ehfTargetConnection, text, text2, configADAdapter)); }
public static EhfAdminSyncState Create(EhfCompanyIdentity companyIdentity, ExSearchResultEntry entry, EhfTargetConnection targetConnection) { return(new EhfAdminSyncState(companyIdentity, targetConnection) { orgAdminMembers = EhfAdminSyncState.GetAdminStateFromAttribute(entry, "msExchTargetServerAdmins"), viewOnlyOrgAdminMembers = EhfAdminSyncState.GetAdminStateFromAttribute(entry, "msExchTargetServerViewOnlyAdmins"), adminAgentMembers = EhfAdminSyncState.GetAdminStateFromAttribute(entry, "msExchTargetServerPartnerAdmins"), helpDeskAgentMembers = EhfAdminSyncState.GetAdminStateFromAttribute(entry, "msExchTargetServerPartnerViewOnlyAdmins") }); }
private OrganizationProvisioningFlags GetProvisioningFlags(ExSearchResultEntry entry) { int result; if (EhfAdminAccountSynchronizer.TryGetFlagsValue("msExchProvisioningFlags", entry, out result)) { return((OrganizationProvisioningFlags)result); } return(OrganizationProvisioningFlags.None); }
public static EhfDomainItem CreateIfAuthoritative(ExSearchResultEntry entry, int ehfCompanyId, EdgeSyncDiag diagSession) { EhfDomainItem ehfDomainItem = new EhfDomainItem(entry, ehfCompanyId, diagSession); if (ehfDomainItem.AcceptedDomainType != AcceptedDomainType.Authoritative) { return(null); } return(ehfDomainItem); }
private static bool ValidateDomainName(ExSearchResultEntry entry, EdgeSyncDiag diagSession) { DirectoryAttribute attribute = entry.GetAttribute("msExchAcceptedDomainName"); string text = null; if (attribute != null) { text = (string)attribute[0]; } if (string.IsNullOrEmpty(text)) { diagSession.LogAndTraceError("Accepted domain object with DN <{0}> does not contain domain name; ignoring the object", new object[] { entry.DistinguishedName }); return(false); } if (text.StartsWith("*", StringComparison.Ordinal)) { diagSession.LogAndTraceError("Wildcard accepted domain <{0}> with DN <{1}> cannot be sync'd", new object[] { text, entry.DistinguishedName }); return(false); } if (text.Contains("_")) { diagSession.LogAndTraceError("Accepted domain <{0}> with DN <{1}> cannot be sync'd because it contains one or more underscore characters", new object[] { text, entry.DistinguishedName }); return(false); } if (!text.Contains(".")) { diagSession.LogAndTraceError("Accepted domain <{0}> with DN <{1}> cannot be sync'd because it is a top level domain", new object[] { text, entry.DistinguishedName }); return(false); } if (text.Length > 255) { diagSession.LogAndTraceError("Accepted domain name <{0}> with DN <{1}> is too long; ignoring the domain", new object[] { text, entry.DistinguishedName }); return(false); } return(true); }
public void CreateOrDeleteEhfDomain(ExSearchResultEntry entry) { EhfDomainItem ehfDomainItem = EhfDomainItem.CreateForActive(entry, base.DiagSession); if (ehfDomainItem.AcceptedDomainType == AcceptedDomainType.Authoritative) { this.AddDomainToCreateBatch(ehfDomainItem); return; } this.AddDomainToDisableBatch(ehfDomainItem); }
private void ThrowIfAdminSyncNotEnabled(string dn, ExSearchResultEntry entry) { if (this.IsSyncEnabledCacheFull()) { return; } if (!this.syncEnabledConfigCache[dn]) { throw new InvalidOperationException(string.Format("Adminsync is not enabled for tenant <{0}>, but still got a change entry <{1}>", dn, entry.DistinguishedName)); } }