public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            EhfCompanyIdentity ehfCompanyIdentity = obj as EhfCompanyIdentity;

            return(ehfCompanyIdentity != null && this.ehfCompanyGuid.Equals(ehfCompanyIdentity.ehfCompanyGuid));
        }
 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")
     });
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        private void HandleFaultAsTransientFailure <TFault>(EhfCompanyIdentity companyIdentity, string operationName, string faultCode, FaultException <TFault> exception, bool isCriticalError) where TFault : AdminServiceFault
        {
            IFormatProvider invariantCulture = CultureInfo.InvariantCulture;
            string          format           = "{0}({1})";

            object[] array = new object[2];
            array[0] = faultCode;
            object[] array2 = array;
            int      num    = 1;
            TFault   detail = exception.Detail;

            array2[num] = detail.ErrorType;
            string exceptionReason = string.Format(invariantCulture, format, array);

            this.HandleFaultAsTransientFailure(companyIdentity, operationName, exception, isCriticalError, exceptionReason);
        }
Esempio n. 5
0
 private void CacheEhfCompanyIdentity(string configUnitDN, EhfCompanyIdentity identity)
 {
     if (identity.EhfCompanyId == 0)
     {
         throw new ArgumentOutOfRangeException("ehfCompanyId", identity.EhfCompanyId, "Company ID must be valid");
     }
     if (identity.EhfCompanyGuid == Guid.Empty)
     {
         throw new ArgumentException("ehfCompanyGuid cannot be empty", "ehfCompanyGuid");
     }
     if (this.configUnitsToCompanyIdentities == null)
     {
         this.configUnitsToCompanyIdentities = new Dictionary <string, EhfCompanyIdentity>();
     }
     this.configUnitsToCompanyIdentities[configUnitDN] = identity;
 }
        public void AddTransientFailure(EhfCompanyIdentity companyIdentity, Exception failureException, string operationName)
        {
            if (companyIdentity == null)
            {
                throw new ArgumentNullException("companyIdentity");
            }
            this.transientFailuresInCurrentCycle.Add(companyIdentity);
            EhfTransientFailureInfo        item = new EhfTransientFailureInfo(failureException, operationName);
            List <EhfTransientFailureInfo> list;

            if (!this.transientFailureDetails.TryGetValue(companyIdentity, out list))
            {
                list = new List <EhfTransientFailureInfo>();
                this.transientFailureDetails[companyIdentity] = list;
            }
            list.Add(item);
            this.transientFailureCount++;
        }
Esempio n. 7
0
 private void HandleFaultAsTransientFailure(EhfCompanyIdentity companyIdentity, string operationName, Exception exception, bool isCriticalError, string exceptionReason)
 {
     ExEventLog.EventTuple tuple_EhfAdminSyncTransientFailure = EdgeSyncEventLogConstants.Tuple_EhfAdminSyncTransientFailure;
     if (!this.errorTracker.HasTransientFailure)
     {
         base.EventLogAndTraceException(operationName, tuple_EhfAdminSyncTransientFailure, exception, exceptionReason);
     }
     else
     {
         base.LogAndTraceException(operationName, exception, exceptionReason);
     }
     if (isCriticalError || companyIdentity == null)
     {
         this.errorTracker.AddCriticalFailure();
     }
     else
     {
         this.errorTracker.AddTransientFailure(companyIdentity, exception, operationName);
     }
     base.EhfConnection.PerfCounterHandler.OnOperationTransientFailure(operationName);
 }
Esempio n. 8
0
 private void HandleOperationFailureCounts(EhfCompanyIdentity companyIdentity, string operationName, int operationTransientFailuresCount, int operationPermanentFailuresCount, string failureDetails, bool hasCriticalError)
 {
     if (operationTransientFailuresCount != 0 || operationPermanentFailuresCount != 0)
     {
         base.EhfConnection.PerfCounterHandler.OnPerEntryFailures(operationName, operationTransientFailuresCount, operationPermanentFailuresCount);
     }
     if (operationTransientFailuresCount > 0)
     {
         if (hasCriticalError || companyIdentity == null)
         {
             this.errorTracker.AddCriticalFailure();
         }
         else
         {
             this.errorTracker.AddTransientFailure(companyIdentity, new EhfAdminAccountSynchronizer.EhfAdminSyncTransientException(failureDetails), operationName);
         }
     }
     if (operationPermanentFailuresCount > 0)
     {
         this.errorTracker.AddPermanentFailure();
     }
 }
 public bool TryGetEhfCompanyIdentity(string configUnitDN, string missingIdAction, out EhfCompanyIdentity companyIdentity)
 {
     return(this.companySync.TryGetEhfCompanyIdentity(configUnitDN, missingIdAction, out companyIdentity));
 }
Esempio n. 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);
        }
Esempio n. 11
0
        private void HandleOperationLevelException(FaultException adminSyncException, string operationName, EhfCompanyIdentity companyIdentity)
        {
            FaultException <InvalidCompanyFault> faultException  = adminSyncException as FaultException <InvalidCompanyFault>;
            FaultException <InternalFault>       faultException2 = adminSyncException as FaultException <InternalFault>;

            if (faultException != null)
            {
                if (faultException.Detail.Code == InvalidCompanyCode.CompanyDoesNotExist || faultException.Detail.ErrorType == ErrorType.Transient)
                {
                    this.HandleFaultAsTransientFailure <InvalidCompanyFault>(companyIdentity, operationName, faultException.Detail.Code.ToString(), faultException, false);
                    return;
                }
                this.HandleFaultAsPermanentFailure <InvalidCompanyFault>(operationName, faultException.Detail.Code.ToString(), faultException);
                return;
            }
            else
            {
                if (faultException2 != null)
                {
                    this.HandleFaultAsTransientFailure <InternalFault>(companyIdentity, operationName, faultException2.Detail.Code.ToString(), faultException2, true);
                    return;
                }
                throw new InvalidOperationException("Encountered unexpected fault exception.", adminSyncException);
            }
        }
Esempio n. 12
0
 private EhfAdminSyncState(EhfCompanyIdentity companyIdentity, EhfTargetConnection targetConnection)
 {
     this.ehfTargetConnection = targetConnection;
     this.ehfCompanyIdentity  = companyIdentity;
 }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
 public bool TryGetEhfCompanyIdentity(string configUnitDN, string missingIdAction, out EhfCompanyIdentity companyIdentity)
 {
     companyIdentity = null;
     if (this.configUnitsToCompanyIdentities != null && this.configUnitsToCompanyIdentities.TryGetValue(configUnitDN, out companyIdentity))
     {
         base.DiagSession.Tracer.TraceDebug <int, Guid, string>((long)base.DiagSession.GetHashCode(), "Successully retrieved cached EHF company ID {0} and company Guid {1} for ConfigUnit root DN <{2}>", companyIdentity.EhfCompanyId, companyIdentity.EhfCompanyGuid, configUnitDN);
         return(true);
     }
     if (EhfCompanySynchronizer.TryGetEhfCompanyIdentity(configUnitDN, base.ADAdapter, base.EhfConnection, missingIdAction, out companyIdentity) && companyIdentity.EhfCompanyId != 0)
     {
         this.CacheEhfCompanyIdentity(configUnitDN, companyIdentity);
         base.DiagSession.Tracer.TraceDebug <int, Guid, string>((long)base.DiagSession.GetHashCode(), "Successully retrieved EHF company ID {0} and companyGuid {1} for ConfigUnit root DN <{2}>", companyIdentity.EhfCompanyId, companyIdentity.EhfCompanyGuid, configUnitDN);
         return(true);
     }
     return(false);
 }