private static EhfCompanyIdentity GetEhfCompanyIdentity(string configUnitDN, EdgeSyncDiag diagSession, string missingIdAction, ExSearchResultEntry perimeterSettingsEntry) { int companyId; string text; if (!EhfCompanyItem.TryGetEhfCompanyId(perimeterSettingsEntry, diagSession, out companyId, out text)) { if (string.IsNullOrEmpty(text)) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "EHF company ID is not set for tenant organization with ConfigUnit root DN <{0}>; {1}", new object[] { configUnitDN, missingIdAction }); } else { diagSession.LogAndTraceError("Failure occurred while retrieving EHF company ID for tenant organization with ConfigUnit root DN <{0}>; {1}; failure details: {2}", new object[] { configUnitDN, missingIdAction, text }); } } Guid objectGuid = perimeterSettingsEntry.GetObjectGuid(); return(new EhfCompanyIdentity(companyId, objectGuid)); }
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); }
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); }
protected void HandleFailedDomain(string operationName, EhfDomainItem domain, DomainResponseInfo response, ref int transientFailureCount, ref int permanentFailureCount) { if (response.Status == ResponseStatus.TransientFailure) { transientFailureCount++; } else { permanentFailureCount++; } string responseTargetValuesString = EhfProvisioningService.GetResponseTargetValuesString(response); EdgeSyncDiag diagSession = base.DiagSession; string messageFormat = "Failed to {0}: FaultId={1}; FaultType={2}; FaultDetail={3}; Target={4}; TargetValues=({5}); DN=({6}); Name={7}; AD-GUID=({8}); EHF-GUID=({9}); EHF-Company-ID={10}"; object[] array = new object[11]; array[0] = operationName; array[1] = response.Fault.Id; array[2] = response.Status; array[3] = (response.Fault.Detail ?? "null"); array[4] = response.Target; array[5] = responseTargetValuesString; array[6] = domain.DistinguishedName; array[7] = domain.Name; array[8] = domain.GetDomainGuid(); object[] array2 = array; int num = 9; Guid? domainGuid = response.DomainGuid; array2[num] = ((domainGuid != null) ? domainGuid.GetValueOrDefault() : "null"); array[10] = domain.Domain.CompanyId; domain.AddSyncError(diagSession.LogAndTraceError(messageFormat, array)); }
private void HandleFailedCompany(string operationName, EhfCompanyItem company, CompanyResponseInfo response, ref int transientFailureCount, ref int permanentFailureCount) { if (response.Status == ResponseStatus.TransientFailure) { transientFailureCount++; } else { permanentFailureCount++; } string text = (company.Company != null) ? company.Company.Name : "not available"; string responseTargetValuesString = EhfProvisioningService.GetResponseTargetValuesString(response); EdgeSyncDiag diagSession = base.DiagSession; string messageFormat = "Failed to {0}: FaultId={1}; FaultType={2}; FaultDetail={3}; Target={4}; TargetValues=({5}); DN=({6}); AD-Name={7}; EHF-Name={8}; AD-GUID=({9}); EHF-GUID=({10}); EHF-ID={11}"; object[] array = new object[12]; array[0] = operationName; array[1] = response.Fault.Id; array[2] = response.Status; array[3] = (response.Fault.Detail ?? "null"); array[4] = response.Target; array[5] = responseTargetValuesString; array[6] = company.DistinguishedName; array[7] = text; array[8] = (response.CompanyName ?? "null"); array[9] = company.GetCompanyGuid(); object[] array2 = array; int num = 10; Guid? companyGuid = response.CompanyGuid; array2[num] = ((companyGuid != null) ? companyGuid.GetValueOrDefault() : "null"); array[11] = response.CompanyId; company.AddSyncError(diagSession.LogAndTraceError(messageFormat, array)); }
public string[] GetWlidsOfGroupMembers(int maxAdmins, EdgeSyncDiag diagSession) { List <string> list = new List <string>(this.groupMembers.Count); foreach (MailboxAdminSyncUser mailboxAdminSyncUser in this.groupMembers.Values) { if (!string.IsNullOrEmpty(mailboxAdminSyncUser.WindowsLiveId)) { if (!EhfWellKnownGroup.ValidateWindowsLiveId(mailboxAdminSyncUser)) { diagSession.LogAndTraceError("WLID <{0}> for user <{1}>:<{2}> is not valid. The admin will be ignored from group <{3}>.", new object[] { mailboxAdminSyncUser.WindowsLiveId, mailboxAdminSyncUser.DistinguishedName, mailboxAdminSyncUser.UserGuid, this.wellknownGroupName }); } else { list.Add(mailboxAdminSyncUser.WindowsLiveId); } if (list.Count == maxAdmins) { diagSession.LogAndTraceError("The group <{0}> has more than the maximum allowed number ({1}) of members. Only the first <{1}> will be taken.", new object[] { this.wellknownGroupName, maxAdmins }); break; } } } return(list.ToArray()); }
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); }
protected EhfSyncItem(ExSearchResultEntry entry, EdgeSyncDiag diagSession) { if (entry == null) { throw new ArgumentNullException("entry"); } if (diagSession == null) { throw new ArgumentNullException("diagSession"); } this.entry = entry; this.diagSession = diagSession; }
public CompanyAdministrators GetLocalAdminsToSync(EdgeSyncDiag diagSession) { string[] array = null; Guid[] array2 = null; if (this.organizationManagement != null) { array = this.organizationManagement.GetWlidsOfGroupMembers(1000, diagSession); array2 = this.organizationManagement.GetLinkedPartnerGroupGuidsOfLinkedRoleGroups(1000, diagSession); } string[] array3 = null; Guid[] array4 = null; if (this.viewOnlyOrganizationManagement != null) { array3 = this.viewOnlyOrganizationManagement.GetWlidsOfGroupMembers(1000, diagSession); array4 = this.viewOnlyOrganizationManagement.GetLinkedPartnerGroupGuidsOfLinkedRoleGroups(1000, diagSession); } Dictionary <Role, string[]> dictionary = new Dictionary <Role, string[]>(); if (array != null) { dictionary[Role.Administrator] = array; } if (array3 != null) { dictionary[Role.ReadOnlyAdministrator] = array3; } Dictionary <Role, Guid[]> dictionary2 = new Dictionary <Role, Guid[]>(); if (array2 != null) { dictionary2[Role.Administrator] = array2; } if (array4 != null) { dictionary2[Role.ReadOnlyAdministrator] = array4; } CompanyAdministrators companyAdministrators = new CompanyAdministrators(); companyAdministrators.CompanyId = this.CompanyId; if (dictionary.Count != 0) { companyAdministrators.AdminUsers = dictionary; } if (dictionary2.Count != 0) { companyAdministrators.AdminGroups = dictionary2; } return(companyAdministrators); }
private static bool TryGetOrganizationUnit(ExSearchResultEntry entry, EdgeSyncDiag diagSession, out string exchOURoot) { exchOURoot = string.Empty; DirectoryAttribute directoryAttribute; if (entry.Attributes.TryGetValue("msExchOURoot", out directoryAttribute) && directoryAttribute != null) { exchOURoot = (string)directoryAttribute[0]; return(true); } diagSession.LogAndTraceError("Could not find ExchOURoot for {0}. Every object is expected to contain this attribute.", new object[] { entry.DistinguishedName }); return(false); }
protected EhfDomainItem(ExSearchResultEntry entry, int ehfCompanyId, EdgeSyncDiag diagSession) : base(entry, diagSession) { if (!entry.Attributes.ContainsKey("msEdgeSyncEhfCompanyGuid")) { throw new InvalidOperationException(string.Format("DomainItem <{0}> does not contain the companyGuid", entry.DistinguishedName)); } if (!entry.IsDeleted) { this.InitializeDomainType(); } this.domain = new Domain(); this.domain.CompanyId = ehfCompanyId; this.domain.DomainGuid = new Guid?(base.GetObjectGuid()); this.domain.Name = this.GetDomainName(); this.domain.InheritFromCompany = (InheritanceSettings.InheritRecipientLevelRoutingConfig | InheritanceSettings.InheritSkipListConfig | InheritanceSettings.InheritDirectoryEdgeBlockModeConfig); this.domain.IsEnabled = true; this.domain.IsValid = true; this.domain.MailServerType = MailServerType.Exchange2007; this.domain.SmtpProfileName = "InboundSmtpProfile"; }
public virtual EhfADAdapter GetConfigADAdapter(EdgeSyncDiag diagSession, out Exception exception) { exception = null; IConfigurationSession configSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(this.connection.Fqdn, true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 339, "GetConfigADAdapter", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\EHF\\EhfADAdapter.cs"); ADObjectId rootId = null; PooledLdapConnection pooledLdapConnection = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { pooledLdapConnection = configSession.GetReadConnection(configSession.DomainController, ref rootId); }, 3); if (adoperationResult.Succeeded) { EhfADAdapter ehfADAdapter = new EhfADAdapter(); ehfADAdapter.SetConnection(new Connection(pooledLdapConnection)); return(ehfADAdapter); } exception = adoperationResult.Exception; return(null); }
public Guid[] GetLinkedPartnerGroupGuidsOfLinkedRoleGroups(int maxMembers, EdgeSyncDiag diagSession) { if (this.linkedRoleGroups == null) { return(null); } Guid[] array = new Guid[Math.Min(this.linkedRoleGroups.Count, maxMembers)]; int num = 0; foreach (PartnerGroupAdminSyncUser partnerGroupAdminSyncUser in this.linkedRoleGroups.Values) { array[num++] = partnerGroupAdminSyncUser.PartnerGroupGuid; if (num == maxMembers) { diagSession.LogAndTraceError("The group <{0}> has more than the maximum allowed number ({1}) of partner linked role groups. Only the first <{1}> will be taken.", new object[] { this.wellknownGroupName, maxMembers }); break; } } return(array); }
public static EhfDomainItemVersion2 CreateEhfDomainItem(ExSearchResultEntry entry, int ehfCompanyId, int[] connectorIds, EdgeSyncDiag diagSession) { return(new EhfDomainItemVersion2(entry, ehfCompanyId, connectorIds, diagSession)); }
private static bool IsEventForDeletedOrganization(ExSearchResultEntry entry, EdgeSyncDiag diagSession) { string distinguishedName; return(EhfAdminAccountSynchronizer.TryGetOrganizationUnit(entry, diagSession, out distinguishedName) && ExSearchResultEntry.IsDeletedDN(distinguishedName)); }
protected override void HandleCreateDomainResponse(DomainResponseInfoSet responseSet, List <EhfDomainItem> domainsTriedToCreate) { int num = 0; int permanentFailureCount = 0; List <EhfDomainItemVersion2> list = new List <EhfDomainItemVersion2>(); List <EhfDomainItemVersion2> list2 = new List <EhfDomainItemVersion2>(); for (int i = 0; i < responseSet.ResponseInfo.Length; i++) { DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i]; EhfDomainItemVersion2 ehfDomainItemVersion = domainsTriedToCreate[i] as EhfDomainItemVersion2; if (ehfDomainItemVersion == null) { throw new InvalidOperationException("Version 2 of EhfConnector should be using version 2 of EhfDomainItem"); } if (domainResponseInfo.Status == ResponseStatus.Success) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully created EHF domain: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Domain.Name, domainResponseInfo.DomainGuid.Value, ehfDomainItemVersion.Domain.CompanyId }); if (ehfDomainItemVersion.TryClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter) == EhfADResultCode.Failure) { num++; } if (!this.UpdateDuplicateDetectedFlag(ehfDomainItemVersion)) { num++; } } else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany || domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany) { Guid domainGuid = ehfDomainItemVersion.GetDomainGuid(); if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.DomainGuid.Value.Equals(domainGuid)) { if (ehfDomainItemVersion.TriedToUpdateDomain && !ehfDomainItemVersion.DomainCreatedWithGuid) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists. Treating this as error since update is already called: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Domain.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); base.HandleFailedDomain("Create Domain", ehfDomainItemVersion, domainResponseInfo, ref num, ref permanentFailureCount); } else { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists. Trying to update the domain. DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Domain.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); list.Add(ehfDomainItemVersion); } } else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.SourceId == ProvisioningSource.Other && !ehfDomainItemVersion.DomainCreatedWithGuid) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "A domain collision is detected for domain: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-Company-ID=<{3}>. Trying to create the domain as OutboundOnly domain.", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); list2.Add(ehfDomainItemVersion); } else if (!base.HandledAllDeletedDomains) { base.AddDomainToCreateLastList(ehfDomainItemVersion); EdgeSyncDiag diagSession = base.DiagSession; EdgeSyncLoggingLevel level = EdgeSyncLoggingLevel.Low; string messageFormat = "Attempted to create a domain with the name that already exists but a different GUID: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-GUID=<{3}>; EHF-Company-ID=<{4}>"; object[] array = new object[5]; array[0] = ehfDomainItemVersion.DistinguishedName; array[1] = ehfDomainItemVersion.Name; array[2] = domainGuid; object[] array2 = array; int num2 = 3; Guid? domainGuid2 = domainResponseInfo.DomainGuid; array2[num2] = ((domainGuid2 != null) ? domainGuid2.GetValueOrDefault() : "null"); array[4] = ehfDomainItemVersion.Domain.CompanyId; diagSession.LogAndTraceInfo(level, messageFormat, array); } else if (!ehfDomainItemVersion.DomainCreatedWithGuid && domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "A domain collision is detected for domain: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-Company-ID=<{3}>. Trying to create the domain as OutboundOnly domain.", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); list2.Add(ehfDomainItemVersion); } else { base.HandleFailedDomain("Create Domain", ehfDomainItemVersion, domainResponseInfo, ref num, ref permanentFailureCount); } } else if (domainResponseInfo.Fault.Id == FaultId.DomainGuidIsNotUnique && !ehfDomainItemVersion.TriedToUpdateDomain) { list.Add(ehfDomainItemVersion); } else { base.HandleFailedDomain("Create Domain", ehfDomainItemVersion, domainResponseInfo, ref num, ref permanentFailureCount); } if (!ehfDomainItemVersion.EventLogAndTryStoreSyncErrors(base.ADAdapter)) { num++; } } base.HandlePerEntryFailureCounts("Create Domain", domainsTriedToCreate.Count, num, permanentFailureCount, false); foreach (EhfDomainItemVersion2 domain in list) { this.AddDomainToUpdateBatch(domain); } foreach (EhfDomainItemVersion2 domain2 in list2) { this.AddDomainToCreateWithGuidBatch(domain2); } }
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); }
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 AbortSyncCycleIfRequired(EhfAdminAccountSynchronizer ehfAdminAccountSynchronizer, EdgeSyncDiag diagSession) { if (this.criticalTransientFailureCount != 0) { ehfAdminAccountSynchronizer.LogAndAbortSyncCycle(); } foreach (EhfCompanyIdentity ehfCompanyIdentity in this.transientFailuresInCurrentCycle) { int num; if (!this.transientFailuresHistory.TryGetValue(ehfCompanyIdentity.EhfCompanyGuid, out num)) { num = 0; } int num2 = num + 1; if (num2 < this.ehfSyncAppConfig.EhfAdminSyncTransientFailureRetryThreshold) { ehfAdminAccountSynchronizer.LogAndAbortSyncCycle(); } } foreach (KeyValuePair <EhfCompanyIdentity, List <EhfTransientFailureInfo> > keyValuePair in this.transientFailureDetails) { StringBuilder stringBuilder = new StringBuilder(); foreach (EhfTransientFailureInfo ehfTransientFailureInfo in keyValuePair.Value) { stringBuilder.AppendLine(ehfTransientFailureInfo.OperationName); stringBuilder.AppendLine(ehfTransientFailureInfo.FailureException.ToString()); stringBuilder.AppendLine(); } diagSession.EventLog.LogEvent(EdgeSyncEventLogConstants.Tuple_EhfAdminSyncTransientFailureRetryThresholdReached, null, new object[] { keyValuePair.Key.EhfCompanyId, keyValuePair.Key.EhfCompanyGuid, stringBuilder.ToString() }); } }
private static bool IsPartnerManagedLinkedRoleGroup(ExSearchResultEntry searchEntry, EdgeSyncDiag diagSession, out Guid groupGuid) { groupGuid = Guid.Empty; if (!EhfCompanyAdmins.IsPartnerManagedGroup(searchEntry, diagSession)) { return(false); } DirectoryAttribute directoryAttribute; if (!searchEntry.Attributes.TryGetValue("msExchPartnerGroupID", out directoryAttribute)) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute is not present in the partner managed group '{0}'", new object[] { searchEntry.DistinguishedName }); return(false); } if (directoryAttribute == null || directoryAttribute.Count == 0) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute is not set on the partner managed group '{0}'", new object[] { searchEntry.DistinguishedName }); return(false); } string text = directoryAttribute[0] as string; if (string.IsNullOrEmpty(text)) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute is empty for the partner managed group '{0}'", new object[] { searchEntry.DistinguishedName }); return(false); } LinkedPartnerGroupInformation linkedPartnerGroupInformation; try { linkedPartnerGroupInformation = LinkedPartnerGroupInformation.Parse(text); } catch (ArgumentException) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute value '{0}' is not in the expected format for '{1}'", new object[] { text, searchEntry.DistinguishedName }); return(false); } if (string.IsNullOrEmpty(linkedPartnerGroupInformation.LinkedPartnerGroupId)) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute value '{0}' has an empty LinkdedPartnetGroupId: '{1}'", new object[] { text, searchEntry.DistinguishedName }); return(false); } if (GuidHelper.TryParseGuid(linkedPartnerGroupInformation.LinkedPartnerGroupId, out groupGuid)) { return(true); } diagSession.LogAndTraceError("msExchPartnerGroupID attribute value '{0}' is not a valid Guid: '{1}'", new object[] { text, searchEntry.DistinguishedName }); return(false); }
protected EhfDomainItem(ExSearchResultEntry entry, EdgeSyncDiag diagSession) : this(entry, 0, diagSession) { this.domain.CompanyId = this.GetEntryCompanyId(); }
public void AddSyncError(string messageFormat, params object[] args) { string diagString = EdgeSyncDiag.GetDiagString(messageFormat, args); this.AddSyncError(diagString); }
public static EhfDomainItem CreateForTombstone(ExSearchResultEntry entry, EdgeSyncDiag diagSession) { return(new EhfDomainItem(entry, diagSession)); }
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); } }
private EhfWellKnownGroup GetMembersOfGroupFromDN(string groupDistinguishedName, bool isPartnerAdminGroup, EdgeSyncDiag diagSession) { EhfWellKnownGroup ehfWellKnownGroup; if (isPartnerAdminGroup) { ExSearchResultEntry exSearchResultEntry = this.ehfTargetConnection.ADAdapter.ReadObjectEntry(groupDistinguishedName, false, EhfCompanyAdmins.AttributesToFetchFromMembers); if (exSearchResultEntry == null) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Could not find wellknown partner admin group {0}", new object[] { groupDistinguishedName }); return(null); } if (!EhfCompanyAdmins.IsPartnerManagedGroup(exSearchResultEntry, diagSession)) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Found the partner group {0}, but it is no partner Managed", new object[] { groupDistinguishedName }); return(null); } Guid externalDirectoryObjectId; if (!EhfCompanyAdmins.TryGetExternalDirectoryObjectId(exSearchResultEntry, diagSession, out externalDirectoryObjectId)) { return(null); } ehfWellKnownGroup = new EhfWellKnownGroup(groupDistinguishedName, externalDirectoryObjectId); } else { ehfWellKnownGroup = new EhfWellKnownGroup(groupDistinguishedName); } Stack <string> stack = new Stack <string>(); stack.Push(groupDistinguishedName); while (stack.Count != 0) { string text = stack.Pop(); string query = string.Format("(memberOf={0})", text); diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.High, "Expanding group {0}", new object[] { text }); IEnumerable <ExSearchResultEntry> enumerable = this.ehfTargetConnection.ADAdapter.PagedScan(this.tenantOU, query, EhfCompanyAdmins.AttributesToFetchFromMembers); int num = 0; foreach (ExSearchResultEntry exSearchResultEntry2 in enumerable) { num++; if (!exSearchResultEntry2.IsDeleted) { Guid objectGuid = exSearchResultEntry2.GetObjectGuid(); if (EhfCompanyAdmins.IsGroup(exSearchResultEntry2)) { Guid partnerGroupGuid; if (ehfWellKnownGroup.SubGroups.ContainsKey(objectGuid) || ehfWellKnownGroup.LinkedRoleGroups.ContainsKey(objectGuid)) { this.ehfTargetConnection.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Group {0} is already processed. Ignoring it.", new object[] { exSearchResultEntry2.DistinguishedName }); } else if (EhfCompanyAdmins.IsPartnerManagedLinkedRoleGroup(exSearchResultEntry2, diagSession, out partnerGroupGuid)) { ehfWellKnownGroup.LinkedRoleGroups.Add(objectGuid, new PartnerGroupAdminSyncUser(exSearchResultEntry2.DistinguishedName, objectGuid, partnerGroupGuid)); } else { ehfWellKnownGroup.SubGroups.Add(objectGuid, new AdminSyncUser(exSearchResultEntry2.DistinguishedName, objectGuid)); stack.Push(exSearchResultEntry2.DistinguishedName); } } else { string text2 = string.Empty; if (exSearchResultEntry2.Attributes.ContainsKey("msExchWindowsLiveID") && exSearchResultEntry2.Attributes["msExchWindowsLiveID"].Count != 0) { text2 = (string)exSearchResultEntry2.Attributes["msExchWindowsLiveID"][0]; if (text2 != null) { text2 = text2.Trim(); } } else { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "WindowsLiveID is not set for {0}", new object[] { exSearchResultEntry2.DistinguishedName }); } if (!ehfWellKnownGroup.GroupMembers.ContainsKey(objectGuid)) { ehfWellKnownGroup.GroupMembers.Add(objectGuid, new MailboxAdminSyncUser(text2, objectGuid, exSearchResultEntry2.DistinguishedName)); } } } else { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "{0} is deleted, ignoring...", new object[] { exSearchResultEntry2.DistinguishedName }); } } diagSession.Tracer.TraceDebug <string, int>((long)this.GetHashCode(), "Expanded group {0}. Found {1} children", text, num); } return(ehfWellKnownGroup); }
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); }
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); }
protected virtual void HandleCreateDomainResponse(DomainResponseInfoSet responseSet, List <EhfDomainItem> domainsTriedToCreate) { int num = 0; int permanentFailureCount = 0; for (int i = 0; i < responseSet.ResponseInfo.Length; i++) { DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i]; EhfDomainItem ehfDomainItem = domainsTriedToCreate[i]; bool flag = false; if (domainResponseInfo.Status == ResponseStatus.Success) { flag = true; base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully created EHF domain: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItem.DistinguishedName, ehfDomainItem.Domain.Name, domainResponseInfo.DomainGuid.Value, ehfDomainItem.Domain.CompanyId }); } else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany || domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany) { Guid domainGuid = ehfDomainItem.GetDomainGuid(); if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.DomainGuid.Value.Equals(domainGuid)) { flag = true; base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItem.DistinguishedName, ehfDomainItem.Domain.Name, domainGuid, ehfDomainItem.Domain.CompanyId }); } else if (!this.handledAllDeletedDomains) { base.AddItemToLazyList <EhfDomainItem>(ehfDomainItem, ref this.domainsToCreateLast); EdgeSyncDiag diagSession = base.DiagSession; EdgeSyncLoggingLevel level = EdgeSyncLoggingLevel.Low; string messageFormat = "Attempted to create a domain with the name that already exists but a different GUID: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-GUID=<{3}>; EHF-Company-ID=<{4}>"; object[] array = new object[5]; array[0] = ehfDomainItem.DistinguishedName; array[1] = ehfDomainItem.Name; array[2] = domainGuid; object[] array2 = array; int num2 = 3; Guid? domainGuid2 = domainResponseInfo.DomainGuid; array2[num2] = ((domainGuid2 != null) ? domainGuid2.GetValueOrDefault() : "null"); array[4] = ehfDomainItem.Domain.CompanyId; diagSession.LogAndTraceInfo(level, messageFormat, array); } else { this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount); } } else { this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount); } if (flag && ehfDomainItem.TryClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter) == EhfADResultCode.Failure) { num++; } if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter)) { num++; } } base.HandlePerEntryFailureCounts("Create Domain", domainsTriedToCreate.Count, num, permanentFailureCount, false); }
private EhfWellKnownGroup GetMembersOfWellKnownGroup(string groupWellKnownName, bool isPartnerAdminGroup, EdgeSyncDiag diagSession) { string groupDistinguishedName = string.Format("CN={0},{1}", groupWellKnownName, this.tenantOU); return(this.GetMembersOfGroupFromDN(groupDistinguishedName, isPartnerAdminGroup, diagSession)); }
private static bool RelevantChangePresent <TUser>(List <ExSearchResultEntry> changedEntries, Dictionary <Guid, TUser> relevantEntries, EdgeSyncDiag diagSession) where TUser : AdminSyncUser { if (relevantEntries.Count == 0) { return(false); } foreach (ExSearchResultEntry exSearchResultEntry in changedEntries) { if (relevantEntries.ContainsKey(exSearchResultEntry.GetObjectGuid())) { return(true); } } return(false); }