Example #1
0
        internal static bool TryGetRoutingAddressFromAD(IADRecipientCache recipientCache, string address, string type, out RoutingAddress result)
        {
            ProxyAddress proxyAddress = ProxyAddress.Parse(type, address);

            if (proxyAddress is InvalidProxyAddress)
            {
                TraceHelper.StoreDriverTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "Proxy address is invalid");
                return(false);
            }
            Result <ADRawEntry> result2 = recipientCache.FindAndCacheRecipient(proxyAddress);

            if (result2.Data != null)
            {
                string primarySmtpAddress = SubmissionItemUtils.GetPrimarySmtpAddress(result2.Data);
                if (string.IsNullOrEmpty(primarySmtpAddress))
                {
                    TraceHelper.StoreDriverTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, 0L, "Primary SMTP address for \"{0}:{1}\" is invalid or missing", address, type);
                    return(false);
                }
                TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Use primary smtp address {0}", primarySmtpAddress);
                result = new RoutingAddress(primarySmtpAddress);
                return(true);
            }
            else
            {
                if (result2.Error != null && result2.Error != ProviderError.NotFound)
                {
                    TraceHelper.StoreDriverTracer.TracePass <ProviderError>(TraceHelper.MessageProbeActivityId, 0L, "Failed to look up due to error :{0}", result2.Error);
                    return(false);
                }
                TraceHelper.StoreDriverTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "The address doesn't exist in AD");
                return(false);
            }
        }
Example #2
0
        private static bool IsRententionPolicyEnabled(IADRecipientCache cache, ProxyAddress address)
        {
            ADRawEntry data = cache.FindAndCacheRecipient(address).Data;

            if (data == null)
            {
                return(false);
            }
            ElcMailboxFlags elcMailboxFlags = (ElcMailboxFlags)data[ADUserSchema.ElcMailboxFlags];
            ADObjectId      adobjectId      = (ADObjectId)data[ADUserSchema.ElcPolicyTemplate];

            return(((elcMailboxFlags & ElcMailboxFlags.ElcV2) != ElcMailboxFlags.None && adobjectId != null) || ((elcMailboxFlags & ElcMailboxFlags.ShouldUseDefaultRetentionPolicy) != ElcMailboxFlags.None && adobjectId == null));
        }
Example #3
0
        internal static bool IsSameUser(IRuleEvaluationContext context, IADRecipientCache recipientCache, ProxyAddress addressToResolve, ProxyAddress addressToCompare)
        {
            if (addressToResolve == null || addressToResolve is InvalidProxyAddress)
            {
                return(false);
            }
            if (addressToCompare == null || addressToCompare is InvalidProxyAddress)
            {
                return(false);
            }
            if (addressToResolve.Equals(addressToCompare))
            {
                return(true);
            }
            ADRawEntry data = recipientCache.FindAndCacheRecipient(addressToResolve).Data;

            if (data == null)
            {
                context.TraceDebug <string>("Message recipient {0} did not resolve, IsSameUser returning false.", addressToResolve.ToString());
                return(false);
            }
            string text = (string)data[ADRecipientSchema.LegacyExchangeDN];

            if (text != null && addressToCompare.ValueString.Equals(text, StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)data[ADRecipientSchema.EmailAddresses];

            if (proxyAddressCollection == null)
            {
                return(false);
            }
            foreach (ProxyAddress proxyAddress in proxyAddressCollection)
            {
                if (addressToCompare.ValueString.Equals(proxyAddress.ValueString, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }
            return(false);
        }