private static bool IsUserProxyAddress(ADUser user, string email) { ProxyAddress proxyAddress = ProxyAddress.Parse(email); foreach (ProxyAddress other in user.EmailAddresses) { if (proxyAddress.Equals(other)) { return(true); } } return(false); }
public void UpdateSecondaryExtensions(UMMailbox mailbox) { ProxyAddressCollection emailAddresses = mailbox.EmailAddresses; EumProxyAddress other = null; for (int i = emailAddresses.Count - 1; i >= 0; i--) { if (emailAddresses[i] is EumProxyAddress) { if (((EumProxyAddress)emailAddresses[i]).IsPrimaryAddress) { other = (EumProxyAddress)emailAddresses[i]; } else { emailAddresses.RemoveAt(i); } } } if (this.SecondaryExtensions != null) { foreach (UMExtension umextension in this.SecondaryExtensions) { if (string.IsNullOrEmpty(umextension.PhoneContext) || string.IsNullOrEmpty(umextension.Extension)) { throw new FaultException(Strings.InvalidSecondaryExtensionError); } ProxyAddress proxyAddress = UMMailbox.BuildProxyAddressFromExtensionAndPhoneContext(umextension.Extension, ProxyAddressPrefix.UM.SecondaryPrefix, umextension.PhoneContext); if (emailAddresses.Contains(proxyAddress)) { if (proxyAddress.Equals(other)) { throw new ProxyAddressExistsException(new LocalizedString(string.Format(Strings.DuplicateExtensionError, proxyAddress))); } throw new FaultException(string.Format(Strings.DuplicateSecondaryExtensionError, proxyAddress)); } else { emailAddresses.Add(proxyAddress); } } } base[MailEnabledRecipientSchema.EmailAddresses] = emailAddresses; }
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); }