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 override ADObjectId GetCookieContainerId() { if (EhfTargetConnection.cookieContainerId == null) { EhfTargetConnection.cookieContainerId = EhfTargetConnection.GetCookieContainerId(this.ConfigSession); } return(EhfTargetConnection.cookieContainerId); }
public EhfAdminAccountSynchronizer(EhfTargetConnection ehfConnection, EhfSyncErrorTracker errorTracker) : base(ehfConnection) { if (errorTracker.CriticalTransientFailureCount != 0 || errorTracker.PermanentFailureCount != 0 || errorTracker.AllTransientFailuresCount != 0) { throw new ArgumentException(string.Format("There should not be any failures before the sync cycle starts. Critical {0}; Permanent {1} AllTransientFailures {2}", errorTracker.CriticalTransientFailureCount, errorTracker.PermanentFailureCount, errorTracker.AllTransientFailuresCount)); } EhfAdminAccountSynchronizer.cycleCount++; base.DiagSession.Tracer.TraceDebug <int>((long)base.DiagSession.GetHashCode(), "Creating EhfAdminAccountSynchronizer ({0})", EhfAdminAccountSynchronizer.cycleCount); this.errorTracker = errorTracker; }
public EhfAdminSyncChangeBuilder(string tenantOU, string tenantConfigUnitDN, EhfTargetConnection targetConnection) { if (string.IsNullOrEmpty(tenantOU)) { throw new ArgumentNullException("tenantOU"); } if (string.IsNullOrEmpty(tenantConfigUnitDN)) { throw new ArgumentNullException("tenantConfigUnitDN"); } this.tenantOU = tenantOU; this.tenantConfigUnitDN = tenantConfigUnitDN; this.ehfTargetConnection = targetConnection; }
private static bool TryGetPerimeterConfigEntry(string configUnitDN, EhfADAdapter adAdapter, EdgeSyncDiag diagSession, string missingIdAction, string[] attributes, out ExSearchResultEntry perimeterSettingsEntry) { ADObjectId perimeterConfigObjectIdFromConfigUnitId = EhfTargetConnection.GetPerimeterConfigObjectIdFromConfigUnitId(new ADObjectId(configUnitDN)); perimeterSettingsEntry = adAdapter.ReadObjectEntry(perimeterConfigObjectIdFromConfigUnitId.DistinguishedName, false, attributes); if (perimeterSettingsEntry == null) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Unable to read Perimeter Settings object for ConfigUnit root DN <{0}>; {1}", new object[] { configUnitDN, missingIdAction }); return(false); } return(true); }
protected static bool LoadFullEntry(ExSearchResultEntry entry, string[] attributeNames, EhfTargetConnection ehfConnection) { ExSearchResultEntry exSearchResultEntry = ehfConnection.ADAdapter.ReadObjectEntry(entry.DistinguishedName, true, attributeNames); if (exSearchResultEntry == null) { ehfConnection.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Could not load object with DN <{0}>; ignoring the object", new object[] { entry.DistinguishedName }); return(false); } foreach (KeyValuePair <string, DirectoryAttribute> keyValuePair in exSearchResultEntry.Attributes) { if (!entry.Attributes.ContainsKey(keyValuePair.Key)) { entry.Attributes.Add(keyValuePair.Key, keyValuePair.Value); } } return(true); }
public EhfSynchronizer(EhfTargetConnection ehfConnection) { this.ehfConnection = ehfConnection; }
public EhfDomainSynchronizerVersion2(EhfTargetConnection ehfConnection) : base(ehfConnection) { }
private EhfCompanyAdmins(EhfAdminSyncChangeBuilder builder, EhfTargetConnection targetConnection, string orgManagementGroupDN, string viewOnlyOrgManagementGroupDN, EhfADAdapter configADAdapter) { EhfWellKnownGroup ehfWellKnownGroup = null; EhfWellKnownGroup ehfWellKnownGroup2 = null; EhfWellKnownGroup ehfWellKnownGroup3 = null; EhfWellKnownGroup ehfWellKnownGroup4 = null; this.tenantOU = builder.TenantOU; this.ehfTargetConnection = targetConnection; if (builder.DeletedObjects.Count != 0) { this.CacheAdminSyncState(configADAdapter); } bool flag = builder.UpdateOrgManagementGroup || builder.HasDirectChangeForGroup(orgManagementGroupDN) || (this.ehfAdminSyncState != null && this.AdminGroupMemberDeleted(builder, this.ehfAdminSyncState.OrganizationManagmentMembers, orgManagementGroupDN)); bool flag2 = builder.UpdateViewOnlyOrgManagementGroup || builder.HasDirectChangeForGroup(viewOnlyOrgManagementGroupDN) || (this.ehfAdminSyncState != null && this.AdminGroupMemberDeleted(builder, this.ehfAdminSyncState.ViewOnlyOrganizationManagmentMembers, viewOnlyOrgManagementGroupDN)); bool flag3 = builder.UpdateAdminAgentGroup || (this.ehfAdminSyncState != null && this.AdminGroupMemberDeleted(builder, this.ehfAdminSyncState.AdminAgentMembers, EhfCompanyAdmins.AdminAgentGroupNamePrefix)); bool flag4 = builder.UpdateHelpdeskAgentGroup || (this.ehfAdminSyncState != null && this.AdminGroupMemberDeleted(builder, this.ehfAdminSyncState.HelpdeskAgentMembers, EhfCompanyAdmins.HelpdeskAgentGroupNamePrefix)); if ((flag || builder.GroupChanges.Count != 0 || builder.LiveIdChanges.Count != 0) && orgManagementGroupDN != null) { ehfWellKnownGroup = this.GetMembersOfGroupFromDN(orgManagementGroupDN, false, targetConnection.DiagSession); } if ((flag2 || builder.GroupChanges.Count != 0 || builder.LiveIdChanges.Count != 0) && viewOnlyOrgManagementGroupDN != null) { ehfWellKnownGroup2 = this.GetMembersOfGroupFromDN(viewOnlyOrgManagementGroupDN, false, targetConnection.DiagSession); } if (builder.GroupChanges.Count != 0 || builder.LiveIdChanges.Count != 0 || flag3 || flag4) { string text = null; string text2 = null; foreach (ExSearchResultEntry exSearchResultEntry in this.ehfTargetConnection.ADAdapter.PagedScan(this.tenantOU, EhfCompanyAdmins.PartnerAdminGroupFilter, new string[0])) { targetConnection.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Found a Partner Admin group {0}", new object[] { exSearchResultEntry.DistinguishedName }); if (exSearchResultEntry.DistinguishedName.StartsWith(EhfWellKnownGroup.AdminAgentGroupDnPrefix)) { text = exSearchResultEntry.DistinguishedName; } else if (exSearchResultEntry.DistinguishedName.StartsWith(EhfWellKnownGroup.HelpdeskAgentGroupDnPrefix)) { text2 = exSearchResultEntry.DistinguishedName; } } targetConnection.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "AdminAgentPartnerGroup={0}; HelpDeskAgentPartnerGroup = {1}", new object[] { text ?? "<null>", text2 ?? "<null>" }); if (flag3 && text != null) { ehfWellKnownGroup3 = this.GetMembersOfGroupFromDN(text, true, targetConnection.DiagSession); } if (flag4 && text2 != null) { ehfWellKnownGroup4 = this.GetMembersOfGroupFromDN(text2, true, targetConnection.DiagSession); } } EdgeSyncDiag diagSession = builder.EhfTargetConnection.DiagSession; if (!flag && ehfWellKnownGroup != null && (EhfCompanyAdmins.RelevantChangePresent <AdminSyncUser>(builder.GroupChanges, ehfWellKnownGroup.SubGroups, diagSession) || EhfCompanyAdmins.RelevantChangePresent <MailboxAdminSyncUser>(builder.LiveIdChanges, ehfWellKnownGroup.GroupMembers, diagSession))) { flag = true; } if (!flag2 && ehfWellKnownGroup2 != null && (EhfCompanyAdmins.RelevantChangePresent <AdminSyncUser>(builder.GroupChanges, ehfWellKnownGroup2.SubGroups, diagSession) || EhfCompanyAdmins.RelevantChangePresent <MailboxAdminSyncUser>(builder.LiveIdChanges, ehfWellKnownGroup2.GroupMembers, diagSession))) { flag2 = true; } if (!flag3 && ehfWellKnownGroup3 != null && (EhfCompanyAdmins.RelevantChangePresent <AdminSyncUser>(builder.GroupChanges, ehfWellKnownGroup3.SubGroups, diagSession) || EhfCompanyAdmins.RelevantChangePresent <MailboxAdminSyncUser>(builder.LiveIdChanges, ehfWellKnownGroup3.GroupMembers, diagSession))) { flag3 = true; } if (!flag4 && ehfWellKnownGroup4 != null && (EhfCompanyAdmins.RelevantChangePresent <AdminSyncUser>(builder.GroupChanges, ehfWellKnownGroup4.SubGroups, diagSession) || EhfCompanyAdmins.RelevantChangePresent <MailboxAdminSyncUser>(builder.LiveIdChanges, ehfWellKnownGroup4.GroupMembers, diagSession))) { flag4 = true; } if (flag) { this.organizationManagement = ehfWellKnownGroup; } if (flag2) { this.viewOnlyOrganizationManagement = ehfWellKnownGroup2; } if (flag3) { this.adminAgent = ehfWellKnownGroup3; } if (flag4) { this.helpdeskAgent = ehfWellKnownGroup4; } if (this.IsSyncRequired) { this.CacheAdminSyncState(configADAdapter); } }
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)); }
private EhfAdminSyncState(EhfCompanyIdentity companyIdentity, EhfTargetConnection targetConnection) { this.ehfTargetConnection = targetConnection; this.ehfCompanyIdentity = companyIdentity; }
public static EhfAdminSyncState Create(EhfCompanyAdmins admins, bool addOrgAdminState, bool addViewOnlyOrgAdminState, bool addAdminAgentState, bool addHelpDeskAgentState, EhfTargetConnection targetConnection) { EhfAdminSyncState ehfAdminSyncState = admins.EhfAdminSyncState; EhfAdminSyncState ehfAdminSyncState2 = new EhfAdminSyncState(admins.EhfCompanyIdentity, targetConnection); ehfAdminSyncState2.orgAdminMembers = ehfAdminSyncState2.GetNewState(admins.OrganizationMangement, ehfAdminSyncState.orgAdminMembers, addOrgAdminState); ehfAdminSyncState2.viewOnlyOrgAdminMembers = ehfAdminSyncState2.GetNewState(admins.ViewonlyOrganizationManagement, ehfAdminSyncState.viewOnlyOrgAdminMembers, addViewOnlyOrgAdminState); ehfAdminSyncState2.adminAgentMembers = ehfAdminSyncState2.GetNewState(admins.AdminAgent, ehfAdminSyncState.adminAgentMembers, addAdminAgentState); ehfAdminSyncState2.helpDeskAgentMembers = ehfAdminSyncState2.GetNewState(admins.HelpdeskAgent, ehfAdminSyncState.helpDeskAgentMembers, addHelpDeskAgentState); return(ehfAdminSyncState2); }
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") }); }
public static bool TryGetEhfAdminSyncState(string configUnitDN, EhfADAdapter adAdapter, EhfTargetConnection targetConnection, string missingIdAction, out EhfAdminSyncState ehfAdminSyncState) { ehfAdminSyncState = null; string[] adminSyncPerimeterSettingsAttributes = EhfCompanySynchronizer.AdminSyncPerimeterSettingsAttributes; ExSearchResultEntry exSearchResultEntry; if (!EhfCompanySynchronizer.TryGetPerimeterConfigEntry(configUnitDN, adAdapter, targetConnection.DiagSession, missingIdAction, adminSyncPerimeterSettingsAttributes, out exSearchResultEntry)) { return(false); } EhfCompanyIdentity ehfCompanyIdentity = EhfCompanySynchronizer.GetEhfCompanyIdentity(configUnitDN, targetConnection.DiagSession, missingIdAction, exSearchResultEntry); ehfAdminSyncState = EhfAdminSyncState.Create(ehfCompanyIdentity, exSearchResultEntry, targetConnection); return(true); }
private static bool TryGetEhfCompanyIdentity(string configUnitDN, EhfADAdapter adAdapter, EhfTargetConnection targetConnection, string missingIdAction, out EhfCompanyIdentity ehfCompanyIdentity) { ehfCompanyIdentity = null; string[] perimeterSettingsCompanyIdentityAttributes = EhfCompanySynchronizer.PerimeterSettingsCompanyIdentityAttributes; ExSearchResultEntry perimeterSettingsEntry; if (!EhfCompanySynchronizer.TryGetPerimeterConfigEntry(configUnitDN, adAdapter, targetConnection.DiagSession, missingIdAction, perimeterSettingsCompanyIdentityAttributes, out perimeterSettingsEntry)) { return(false); } ehfCompanyIdentity = EhfCompanySynchronizer.GetEhfCompanyIdentity(configUnitDN, targetConnection.DiagSession, missingIdAction, perimeterSettingsEntry); return(true); }
public EhfCompanySynchronizer(EhfTargetConnection ehfConnection) : base(ehfConnection) { }