Ejemplo n.º 1
0
        public override EdgeConfigStatus Validate(EdgeConnectionInfo subscription)
        {
            EdgeConfigStatus edgeConfigStatus = base.Validate(subscription);

            this.ValidateExchangeServerRecipient(edgeConfigStatus);
            return(edgeConfigStatus);
        }
Ejemplo n.º 2
0
        private void SaveEdgeConnection(EdgeConnectionInfo subscription)
        {
            this.currentEdgeConnection = subscription;
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 751, "SaveEdgeConnection", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\Common\\Validation\\ConfigValidator.cs");
            EdgeSyncServiceConfig         edgeSyncServiceConfig        = topologyConfigurationSession.Read <EdgeSyncServiceConfig>(topologyConfigurationSession.GetLocalSite().Id.GetChildId("EdgeSyncService"));

            this.syncInScheduleWindow = (edgeSyncServiceConfig.ConfigurationSyncInterval > DateTime.UtcNow.Subtract(subscription.LastSynchronizedDate));
        }
Ejemplo n.º 3
0
 public abstract EdgeConfigStatus Validate(EdgeConnectionInfo subscription);
Ejemplo n.º 4
0
        public override EdgeConfigStatus Validate(EdgeConnectionInfo subscription)
        {
            this.SaveEdgeConnection(subscription);
            EdgeConfigStatus edgeConfigStatus = new EdgeConfigStatus();

            try
            {
                List <string> list = ConfigValidator.CombineAttributes(this.PayloadAttributes, this.ReadAttributes);
                Dictionary <string, ExSearchResultEntry> adentries = this.GetADEntries();
                bool flag = true;
                int  num  = 0;
                uint num2 = 0U;
                this.adamRootPath = DistinguishedName.Concatinate(new string[]
                {
                    "CN=First Organization,CN=Microsoft Exchange,CN=Services",
                    subscription.EdgeConnection.AdamConfigurationNamingContext
                });
                if (base.ProgressMethod != null)
                {
                    base.ProgressMethod(Strings.LoadingADAMComparisonList(this.configObjectName, subscription.EdgeServer.Name), Strings.LoadedADAMObjectCount(num));
                }
                foreach (ExSearchResultEntry exSearchResultEntry in subscription.EdgeConnection.PagedScan(this.ADAMSearchPath, this.ADAMLdapQuery, this.searchScope, list.ToArray()))
                {
                    string adamRelativePath = this.GetAdamRelativePath(exSearchResultEntry);
                    if (adentries.ContainsKey(adamRelativePath))
                    {
                        if (this.Filter(adentries[adamRelativePath]))
                        {
                            if (!this.CompareAttributes(exSearchResultEntry, adentries[adamRelativePath], this.PayloadAttributes) && !this.IsInChangeWindow(adentries[adamRelativePath]))
                            {
                                if (base.MaxReportedLength.IsUnlimited || (ulong)base.MaxReportedLength.Value > (ulong)((long)edgeConfigStatus.ConflictObjects.Count))
                                {
                                    edgeConfigStatus.ConflictObjects.Add(new ADObjectId(adentries[adamRelativePath].DistinguishedName));
                                }
                                flag = false;
                            }
                            else
                            {
                                num2 += 1U;
                            }
                        }
                        else if (this.FilterEdge(exSearchResultEntry))
                        {
                            if (base.MaxReportedLength.IsUnlimited || (ulong)base.MaxReportedLength.Value > (ulong)((long)edgeConfigStatus.EdgeOnlyObjects.Count))
                            {
                                edgeConfigStatus.EdgeOnlyObjects.Add(new ADObjectId(exSearchResultEntry.DistinguishedName));
                            }
                            flag = false;
                        }
                        adentries.Remove(adamRelativePath);
                    }
                    else if (this.FilterEdge(exSearchResultEntry))
                    {
                        if (base.MaxReportedLength.IsUnlimited || (ulong)base.MaxReportedLength.Value > (ulong)((long)edgeConfigStatus.EdgeOnlyObjects.Count))
                        {
                            edgeConfigStatus.EdgeOnlyObjects.Add(new ADObjectId(exSearchResultEntry.DistinguishedName));
                        }
                        flag = false;
                    }
                    if (num % 500 == 0 && base.ProgressMethod != null)
                    {
                        base.ProgressMethod(Strings.LoadingADAMComparisonList(this.configObjectName, subscription.EdgeServer.Name), Strings.LoadedADAMObjectCount(num));
                    }
                    num++;
                }
                if (base.ProgressMethod != null)
                {
                    base.ProgressMethod(Strings.LoadingADAMComparisonList(this.configObjectName, subscription.EdgeServer.Name), Strings.LoadedADAMObjectCount(num));
                }
                foreach (ExSearchResultEntry exSearchResultEntry2 in adentries.Values)
                {
                    if (this.Filter(exSearchResultEntry2) && !this.IsInChangeWindow(exSearchResultEntry2))
                    {
                        if (base.MaxReportedLength.IsUnlimited || (ulong)base.MaxReportedLength.Value > (ulong)((long)edgeConfigStatus.OrgOnlyObjects.Count))
                        {
                            edgeConfigStatus.OrgOnlyObjects.Add(new ADObjectId(exSearchResultEntry2.DistinguishedName));
                        }
                        flag = false;
                    }
                }
                edgeConfigStatus.SyncStatus          = (flag ? SyncStatus.Synchronized : SyncStatus.NotSynchronized);
                edgeConfigStatus.SynchronizedObjects = num2;
            }
            catch (ExDirectoryException)
            {
                edgeConfigStatus.SyncStatus = SyncStatus.DirectoryError;
            }
            return(edgeConfigStatus);
        }
Ejemplo n.º 5
0
        public EdgeConfigStatus ValidateOneRecipient(EdgeConnectionInfo subscription, string proxyAddressToVerify)
        {
            ADObjectId adobjectId = null;

            string[] attributeNames = RecipientSchema.AttributeNames;
            string[] array          = RecipientValidator.readAttributes;
            int      num            = attributeNames.Length;
            int      num2           = array.Length;

            string[] array2 = new string[num + num2];
            attributeNames.CopyTo(array2, 0);
            array.CopyTo(array2, num);
            Connection       connection = null;
            EdgeConfigStatus result;

            try
            {
                connection = new Connection(this.DataSession.GetReadConnection(null, ref adobjectId));
                List <ExSearchResultEntry> list = new List <ExSearchResultEntry>();
                foreach (ExSearchResultEntry item in connection.PagedScan(null, "(proxyAddresses=" + proxyAddressToVerify + ")", SearchScope.Subtree, array2))
                {
                    list.Add(item);
                }
                if (list.Count == 0)
                {
                    result = new RecipientConfigStatus(SyncStatus.NotSynchronized, "Recipient doesn't exist in source Active Directory");
                }
                else if (list.Count > 1)
                {
                    RecipientConfigStatus recipientConfigStatus = new RecipientConfigStatus(SyncStatus.NotSynchronized, "More than one recipient found in source Active Directory and may cause NDR on Edge server. RecipientStatus.ConflictObjects contains relevant entries.");
                    foreach (ExSearchResultEntry exSearchResultEntry in list)
                    {
                        recipientConfigStatus.ConflictObjects.Add(new ADObjectId(exSearchResultEntry.DistinguishedName));
                    }
                    result = recipientConfigStatus;
                }
                else
                {
                    string hashedFormWithPrefix      = this.proxyAddressHasher.GetHashedFormWithPrefix(proxyAddressToVerify.Substring(5));
                    List <ExSearchResultEntry> list2 = new List <ExSearchResultEntry>();
                    foreach (ExSearchResultEntry item2 in subscription.EdgeConnection.PagedScan(this.ADAMSearchPath, "(proxyAddresses=" + hashedFormWithPrefix + ")", SearchScope.Subtree, array2))
                    {
                        list2.Add(item2);
                    }
                    if (list2.Count > 1)
                    {
                        RecipientConfigStatus recipientConfigStatus2 = new RecipientConfigStatus(SyncStatus.NotSynchronized, "More than one recipient found in target Edge Server and may cause NDR on Edge server. RecipientStatus.ConflictObjects contains relevant entries.");
                        foreach (ExSearchResultEntry exSearchResultEntry2 in list2)
                        {
                            recipientConfigStatus2.ConflictObjects.Add(new ADObjectId(exSearchResultEntry2.DistinguishedName));
                        }
                        result = recipientConfigStatus2;
                    }
                    else
                    {
                        ExSearchResultEntry exSearchResultEntry3 = list[0];
                        DirectoryAttribute  directoryAttribute   = exSearchResultEntry3.Attributes["objectGUID"];
                        Guid   guid         = new Guid((byte[])directoryAttribute.GetValues(typeof(byte[]))[0]);
                        string absolutePath = "cn=" + guid.ToString() + "," + this.ADAMSearchPath;
                        ExSearchResultEntry exSearchResultEntry4 = subscription.EdgeConnection.ReadObjectEntry(absolutePath, array2);
                        if (exSearchResultEntry4 == null)
                        {
                            result = new RecipientConfigStatus(SyncStatus.NotSynchronized, "Recipient doesn't exist in target Edge Server and may cause NDR on Edge server")
                            {
                                OrgOnlyObjects =
                                {
                                    new ADObjectId(exSearchResultEntry3.DistinguishedName)
                                }
                            };
                        }
                        else if (!this.CompareAttributes(exSearchResultEntry4, exSearchResultEntry3, attributeNames))
                        {
                            result = new RecipientConfigStatus(SyncStatus.NotSynchronized, "Recipient exists in target Edge Server but attributes are not synchronized")
                            {
                                ConflictObjects =
                                {
                                    new ADObjectId(exSearchResultEntry3.DistinguishedName)
                                }
                            };
                        }
                        else
                        {
                            DirectoryAttribute directoryAttribute2 = null;
                            bool flag = false;
                            if (exSearchResultEntry4.Attributes.TryGetValue("msExchRequireAuthToSendTo", out directoryAttribute2) && directoryAttribute2 != null && directoryAttribute2.Count > 0 && bool.TryParse((string)directoryAttribute2[0], out flag) && flag)
                            {
                                result = new RecipientConfigStatus(SyncStatus.Synchronized, "Recipient requires sender authentication and this may cause NDR on Edge server. RecipientStatus.ConflictObjects contains the recipient object in source Active Directory")
                                {
                                    ConflictObjects =
                                    {
                                        new ADObjectId(exSearchResultEntry3.DistinguishedName)
                                    }
                                };
                            }
                            else
                            {
                                result = new RecipientConfigStatus(SyncStatus.Synchronized, null);
                            }
                        }
                    }
                }
            }
            catch (ExDirectoryException ex)
            {
                result = new RecipientConfigStatus(SyncStatus.DirectoryError, ex.Message);
            }
            catch (ADTransientException ex2)
            {
                result = new RecipientConfigStatus(SyncStatus.DirectoryError, ex2.Message);
            }
            catch (ADOperationException ex3)
            {
                result = new RecipientConfigStatus(SyncStatus.DirectoryError, ex3.Message);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Dispose();
                    connection = null;
                }
            }
            return(result);
        }