예제 #1
0
        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);
        }
예제 #2
0
        private void ProcessSyncAdminAccountsResponse(FailedAdminAccounts syncAdminAccountsResponse, EhfCompanyAdmins requestAdmins, string operationName)
        {
            if (syncAdminAccountsResponse == null)
            {
                base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully completed SyncAdminAccounts operation. Sync details: <{0}>", new object[]
                {
                    requestAdmins
                });
                return;
            }
            int           num              = 0;
            int           num2             = 0;
            bool          hasCriticalError = false;
            StringBuilder stringBuilder    = new StringBuilder();

            stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "Tenant: <{0}> ", new object[]
            {
                requestAdmins.TenantOU
            });
            stringBuilder.Append("SyncAdminAccountUserErrors: ");
            if (syncAdminAccountsResponse.FailedUsers != null)
            {
                EhfAdminAccountSynchronizer.ClassifyFailedResponse <string>(syncAdminAccountsResponse.FailedUsers, ref num, ref num2, ref hasCriticalError, stringBuilder);
            }
            stringBuilder.Append(" SyncAdminAccountGroupErrors: ");
            if (syncAdminAccountsResponse.FailedGroups != null)
            {
                EhfAdminAccountSynchronizer.ClassifyFailedResponse <Guid>(syncAdminAccountsResponse.FailedGroups, ref num, ref num2, ref hasCriticalError, stringBuilder);
            }
            string text = stringBuilder.ToString();

            this.HandleOperationFailureCounts(requestAdmins.EhfCompanyIdentity, operationName, (num > 0) ? 1 : 0, (num2 > 0) ? 1 : 0, text, hasCriticalError);
            this.LogAdminSyncOperationFailure(operationName, num, num2, text);
        }
예제 #3
0
 private static void ClassifyFailedResponse <T>(Dictionary <T, ErrorInfo> response, ref int transientFailureCount, ref int permanentFailureCount, ref bool hasCriticalError, StringBuilder logBuilder)
 {
     logBuilder.Append("[");
     foreach (KeyValuePair <T, ErrorInfo> keyValuePair in response)
     {
         logBuilder.AppendFormat(CultureInfo.InstalledUICulture, "<{0}: {1} {2} {3}>", new object[]
         {
             keyValuePair.Key,
             keyValuePair.Value.Code,
             keyValuePair.Value.ErrorType,
             EhfAdminAccountSynchronizer.FormatAdditionalData(keyValuePair.Value.Data)
         });
         if (keyValuePair.Value.ErrorType == ErrorType.Transient)
         {
             transientFailureCount++;
             if (keyValuePair.Value.Code != ErrorCode.InvalidFormat)
             {
                 hasCriticalError = true;
             }
         }
         else
         {
             permanentFailureCount++;
         }
     }
     logBuilder.Append("]");
 }
예제 #4
0
        private static bool TryGetOURootFromDN(string dn, out string tenantOU, out bool isOrgChange)
        {
            tenantOU    = string.Empty;
            isOrgChange = false;
            ADObjectId adobjectId = new ADObjectId(dn);
            int        num        = adobjectId.Depth - adobjectId.DomainId.Depth;

            if (num < EhfAdminAccountSynchronizer.OrganizationUnitDepth)
            {
                return(false);
            }
            ADObjectId adobjectId2;

            if (num == EhfAdminAccountSynchronizer.OrganizationUnitDepth)
            {
                adobjectId2 = adobjectId;
                isOrgChange = true;
            }
            else
            {
                adobjectId2 = adobjectId.AncestorDN(num - EhfAdminAccountSynchronizer.OrganizationUnitDepth);
            }
            if (!EhfAdminAccountSynchronizer.IsOrganizationUnitDN(adobjectId2))
            {
                return(false);
            }
            tenantOU = adobjectId2.DistinguishedName;
            return(true);
        }
예제 #5
0
        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
            });
        }
예제 #6
0
        private OrganizationProvisioningFlags GetProvisioningFlags(ExSearchResultEntry entry)
        {
            int result;

            if (EhfAdminAccountSynchronizer.TryGetFlagsValue("msExchProvisioningFlags", entry, out result))
            {
                return((OrganizationProvisioningFlags)result);
            }
            return(OrganizationProvisioningFlags.None);
        }
예제 #7
0
 public void HandleWlidDeletedEvent(ExSearchResultEntry entry)
 {
     if (!EhfAdminAccountSynchronizer.IsEventForDeletedOrganization(entry, base.DiagSession))
     {
         EhfAdminSyncChangeBuilder adminBuilderForChange = this.GetAdminBuilderForChange(entry);
         base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Encountered a DELETE mailbox event. ObjectGuid: <{0}>; Company: <{1}>", new object[]
         {
             entry.GetObjectGuid(),
             adminBuilderForChange.TenantOU
         });
         if (adminBuilderForChange != null)
         {
             adminBuilderForChange.HandleWlidDeletedEvent(entry);
             return;
         }
     }
     else
     {
         base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Ignoring the WLID delete event '{0}' for a deleted organization", new object[]
         {
             entry.DistinguishedName
         });
     }
 }
예제 #8
0
 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()
         });
     }
 }
예제 #9
0
        public override List <TypeSynchronizer> CreateTypeSynchronizer(SyncTreeType type)
        {
            List <TypeSynchronizer> list = new List <TypeSynchronizer>();

            if (this.ehfWebServiceVersion != EhfWebServiceVersion.Version1 && this.ehfWebServiceVersion != EhfWebServiceVersion.Version2)
            {
                EdgeSyncEvents.Log.LogEvent(EdgeSyncEventLogConstants.Tuple_EhfWebServiceVersionIsNotSupported, null, new object[]
                {
                    this.ehfWebServiceVersion,
                    this.identity
                });
                return(list);
            }
            if (type == SyncTreeType.Configuration)
            {
                list.Add(EhfCompanySynchronizer.CreateTypeSynchronizer());
                list.Add(EhfDomainSynchronizer.CreateTypeSynchronizer());
            }
            else if (type == SyncTreeType.Recipients)
            {
                list.Add(EhfAdminAccountSynchronizer.CreateTypeSynchronizer());
            }
            return(list);
        }
예제 #10
0
        private bool InvokeSyncGroupUsers(EhfCompanyIdentity companyIdentity, EhfWellKnownGroup partnerGroup, string tenantOU)
        {
            string syncPartnerAdminGroupOperation = EhfAdminAccountSynchronizer.SyncPartnerAdminGroupOperation;

            if (partnerGroup == null)
            {
                return(true);
            }
            base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Syncing partner admin group {0} for tenant {1}", new object[]
            {
                partnerGroup.ExternalDirectoryObjectId,
                tenantOU
            });
            string[] members = partnerGroup.GetWlidsOfGroupMembers(2000, base.DiagSession);
            Dictionary <string, ErrorInfo> syncGroupUsersResponse = null;
            FaultException syncGroupsException = null;

            base.InvokeProvisioningService(syncPartnerAdminGroupOperation, delegate
            {
                syncGroupUsersResponse = this.ProvisioningService.SyncGroupUsers(companyIdentity.EhfCompanyId, partnerGroup.ExternalDirectoryObjectId, members, out syncGroupsException);
            }, 1);
            if (syncGroupsException != null)
            {
                FaultException <InvalidGroupFault> faultException = syncGroupsException as FaultException <InvalidGroupFault>;
                if (faultException != null)
                {
                    if (faultException.Detail.Code == InvalidGroupCode.GroupDoesNotExist)
                    {
                        base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "SyncGroupUsers returned GroupDoesNotExist fault while trying to sync an empty group <{0}> in company <{1}>.", new object[]
                        {
                            partnerGroup.WellKnownGroupName,
                            tenantOU
                        });
                    }
                    else if (faultException.Detail.Code == InvalidGroupCode.GroupBelongsToDifferentCompany || faultException.Detail.ErrorType == ErrorType.Transient)
                    {
                        this.HandleFaultAsTransientFailure <InvalidGroupFault>(companyIdentity, syncPartnerAdminGroupOperation, faultException.Detail.Code.ToString(), faultException, faultException.Detail.Code != InvalidGroupCode.GroupBelongsToDifferentCompany);
                    }
                    else
                    {
                        this.HandleFaultAsPermanentFailure <InvalidGroupFault>(syncPartnerAdminGroupOperation, faultException.Detail.Code.ToString(), faultException);
                    }
                }
                else
                {
                    this.HandleOperationLevelException(syncGroupsException, syncPartnerAdminGroupOperation, companyIdentity);
                }
                return(false);
            }
            if (syncGroupUsersResponse == null)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (string value in members)
                {
                    if (stringBuilder.Length != 0)
                    {
                        stringBuilder.Append(", ");
                    }
                    stringBuilder.Append(value);
                }
                base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully completed SyncGroupUsers operation for partnerGroup <{0} : {1}>. Details: <{2}>; Members={3}", new object[]
                {
                    partnerGroup.WellKnownGroupName,
                    tenantOU,
                    partnerGroup,
                    stringBuilder.ToString()
                });
            }
            else
            {
                StringBuilder stringBuilder2 = new StringBuilder();
                stringBuilder2.Append("SyncGroupUsers: ");
                int  num              = 0;
                int  num2             = 0;
                bool hasCriticalError = false;
                EhfAdminAccountSynchronizer.ClassifyFailedResponse <string>(syncGroupUsersResponse, ref num, ref num2, ref hasCriticalError, stringBuilder2);
                string text = stringBuilder2.ToString();
                this.HandleOperationFailureCounts(companyIdentity, syncPartnerAdminGroupOperation, (num > 0) ? 1 : 0, (num2 > 0) ? 1 : 0, text, hasCriticalError);
                this.LogAdminSyncOperationFailure(syncPartnerAdminGroupOperation, num, num2, text);
            }
            return(true);
        }
예제 #11
0
 private bool TryGetTenantOrgUnitDNForChange(ExSearchResultEntry entry, out string tenantOU, out bool isOrgChange, ref bool fullLoadComplete)
 {
     tenantOU    = null;
     isOrgChange = false;
     if (entry.IsDeleted)
     {
         if (!entry.Attributes.ContainsKey("msExchOURoot"))
         {
             if (!EhfSynchronizer.LoadFullEntry(entry, EhfAdminAccountSynchronizer.AdminSyncAllAttributes, base.EhfConnection))
             {
                 return(false);
             }
             fullLoadComplete = true;
         }
         else
         {
             base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Delete change <{0}> already contains OURoot. Using that.", new object[]
             {
                 entry.DistinguishedName
             });
         }
         if (!EhfAdminAccountSynchronizer.TryGetOrganizationUnit(entry, base.DiagSession, out tenantOU))
         {
             base.DiagSession.LogAndTraceError("Could not extract OURoot attribute from deleted change entry <{0}>. Ignoring the change.", new object[]
             {
                 entry.DistinguishedName
             });
             return(false);
         }
         base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Extracted the OURoot <{0}> for the deleted change from the change entry <{1}>", new object[]
         {
             tenantOU,
             entry.DistinguishedName
         });
     }
     else if (!EhfAdminAccountSynchronizer.TryGetOURootFromDN(entry.DistinguishedName, out tenantOU, out isOrgChange))
     {
         base.DiagSession.LogAndTraceError("Failed to get the OrganizationUnit Root from the DN of <{0}>. Ignoring the item.", new object[]
         {
             entry.DistinguishedName
         });
         return(false);
     }
     if (string.IsNullOrEmpty(tenantOU))
     {
         base.DiagSession.LogAndTraceError("OrganizationUnit DN for <{0}> is null or emtpy. Ignoring the item.", new object[]
         {
             entry.DistinguishedName
         });
         return(false);
     }
     if (ExSearchResultEntry.IsDeletedDN(tenantOU))
     {
         base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Change <{0}> is for a deleted organization <{1}>. Ignoring the item", new object[]
         {
             entry.DistinguishedName,
             tenantOU
         });
         return(false);
     }
     return(true);
 }
예제 #12
0
        private static bool IsEventForDeletedOrganization(ExSearchResultEntry entry, EdgeSyncDiag diagSession)
        {
            string distinguishedName;

            return(EhfAdminAccountSynchronizer.TryGetOrganizationUnit(entry, diagSession, out distinguishedName) && ExSearchResultEntry.IsDeletedDN(distinguishedName));
        }