private static string[] GetSmtpAddressCache(ADRawEntry person)
		{
			List<string> list = new List<string>(1);
			object obj;
			if (person.TryGetValueWithoutDefault(ADRecipientSchema.EmailAddresses, out obj))
			{
				ProxyAddressCollection proxyAddressCollection = obj as ProxyAddressCollection;
				if (proxyAddressCollection != null)
				{
					foreach (ProxyAddress proxyAddress in proxyAddressCollection)
					{
						SmtpProxyAddress smtpProxyAddress = proxyAddress as SmtpProxyAddress;
						if (smtpProxyAddress != null)
						{
							string text = smtpProxyAddress.ToString();
							if (!string.IsNullOrEmpty(text))
							{
								list.Add(text);
							}
						}
					}
				}
			}
			return list.ToArray();
		}
		private static HashSet<string> GetEmailAddresses(ADRawEntry person)
		{
			HashSet<string> hashSet = new HashSet<string>();
			object obj;
			if (person.TryGetValueWithoutDefault(ADRecipientSchema.EmailAddresses, out obj))
			{
				ProxyAddressCollection proxyAddressCollection = obj as ProxyAddressCollection;
				if (proxyAddressCollection != null)
				{
					foreach (ProxyAddress proxyAddress in proxyAddressCollection)
					{
						SmtpProxyAddress smtpProxyAddress = proxyAddress as SmtpProxyAddress;
						if (smtpProxyAddress != null)
						{
							string text = ContactInfoForLinking.CanonicalizeEmailAddress(smtpProxyAddress.SmtpAddress);
							if (!string.IsNullOrEmpty(text))
							{
								hashSet.Add(text);
							}
						}
					}
				}
			}
			return hashSet;
		}
Example #3
0
        public static ProxyAddressCollection MergeAddresses(ProxyAddressCollection smtpAndX500Addresses, ProxyAddressCollection sipAddresses)
        {
            ProxyAddressCollection proxyAddressCollection = new ProxyAddressCollection();

            if (smtpAndX500Addresses != null)
            {
                foreach (ProxyAddress item in smtpAndX500Addresses)
                {
                    if (!proxyAddressCollection.Contains(item))
                    {
                        proxyAddressCollection.Add(item);
                    }
                }
            }
            if (sipAddresses != null)
            {
                foreach (ProxyAddress item2 in sipAddresses)
                {
                    if (!proxyAddressCollection.Contains(item2))
                    {
                        proxyAddressCollection.Add(item2);
                    }
                }
            }
            return(proxyAddressCollection);
        }
Example #4
0
        // Token: 0x06001FFA RID: 8186 RVA: 0x000B9298 File Offset: 0x000B7498
        protected bool RenderADEmailAddress(IListViewDataSource dataSource, TextWriter writer)
        {
            string text = dataSource.GetItemProperty <SmtpAddress>(ADRecipientSchema.PrimarySmtpAddress, SmtpAddress.Empty).ToString();

            if (text.Length == 0)
            {
                return(false);
            }
            RecipientAddress.RecipientAddressFlags recipientAddressFlags = RecipientAddress.RecipientAddressFlags.None;
            RecipientDisplayType?itemProperty = dataSource.GetItemProperty <RecipientDisplayType?>(ADRecipientSchema.RecipientDisplayType, null);

            if (itemProperty == RecipientDisplayType.ConferenceRoomMailbox || itemProperty == RecipientDisplayType.SyncedConferenceRoomMailbox)
            {
                recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.Room;
            }
            RecipientType itemProperty2 = dataSource.GetItemProperty <RecipientType>(ADRecipientSchema.RecipientType, RecipientType.Invalid);

            if (Utilities.IsADDistributionList(itemProperty2))
            {
                recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.DistributionList;
            }
            string itemProperty3 = dataSource.GetItemProperty <string>(ADRecipientSchema.LegacyExchangeDN, string.Empty);
            ProxyAddressCollection itemProperty4 = dataSource.GetItemProperty <ProxyAddressCollection>(ADRecipientSchema.EmailAddresses, null);
            string sipUri            = InstantMessageUtilities.GetSipUri(itemProperty4);
            string mobilePhoneNumber = Utilities.NormalizePhoneNumber(dataSource.GetItemProperty <string>(ADOrgPersonSchema.MobilePhone, string.Empty));

            this.RenderSingleEmailAddress(writer, dataSource.GetItemProperty <string>(ADRecipientSchema.DisplayName, string.Empty), text, text, itemProperty3, EmailAddressIndex.None, recipientAddressFlags, null, sipUri, mobilePhoneNumber);
            return(true);
        }
        public string GetSenderEmailAddress()
        {
            if (this.senderAdEntry == null)
            {
                return(string.Empty);
            }
            SmtpAddress primarySmtpAddress = this.senderAdEntry.PrimarySmtpAddress;

            if (primarySmtpAddress.IsValidAddress)
            {
                return(primarySmtpAddress.ToString());
            }
            ProxyAddressCollection emailAddresses = this.senderAdEntry.EmailAddresses;

            if (emailAddresses == null || 0 >= emailAddresses.Count)
            {
                return(string.Empty);
            }
            ProxyAddress proxyAddress = emailAddresses.Find(new Predicate <ProxyAddress>(this.IsSmtpAddress));

            if (null != proxyAddress)
            {
                return(proxyAddress.ToString());
            }
            return(emailAddresses[0].ToString());
        }
Example #6
0
		public void UpdateEmailAddresses(Mailbox mailbox)
		{
			ProxyAddressCollection emailAddresses = mailbox.EmailAddresses;
			for (int i = emailAddresses.Count - 1; i >= 0; i--)
			{
				if (emailAddresses[i] is SmtpProxyAddress && !((SmtpProxyAddress)emailAddresses[i]).IsPrimaryAddress)
				{
					emailAddresses.RemoveAt(i);
				}
			}
			if (this.EmailAddresses != null)
			{
				foreach (string text in this.EmailAddresses)
				{
					ProxyAddress proxyAddress = ProxyAddress.Parse(text);
					if (proxyAddress is InvalidProxyAddress)
					{
						InvalidProxyAddress invalidProxyAddress = proxyAddress as InvalidProxyAddress;
						throw new FaultException(invalidProxyAddress.ParseException.Message);
					}
					if (emailAddresses.Contains(proxyAddress))
					{
						throw new FaultException(string.Format(OwaOptionStrings.DuplicateProxyAddressError, text));
					}
					emailAddresses.Add(proxyAddress);
				}
			}
			base[MailEnabledRecipientSchema.EmailAddresses] = emailAddresses;
		}
 private MailboxInfo FindMailboxInfo(string legacyDn, bool?isArchive = null)
 {
     foreach (MailboxInfo mailboxInfo in base.Mailboxes)
     {
         if (isArchive == null || mailboxInfo.IsArchive == isArchive)
         {
             MailboxInfo result;
             if (string.Equals(mailboxInfo.LegacyExchangeDN, legacyDn, StringComparison.OrdinalIgnoreCase))
             {
                 result = mailboxInfo;
             }
             else
             {
                 ProxyAddressCollection emailAddresses = mailboxInfo.EmailAddresses;
                 if (emailAddresses != null)
                 {
                     foreach (ProxyAddress proxyAddress in emailAddresses)
                     {
                         if (proxyAddress.Prefix == ProxyAddressPrefix.X500 && string.Equals(proxyAddress.AddressString, legacyDn, StringComparison.OrdinalIgnoreCase))
                         {
                             return(mailboxInfo);
                         }
                     }
                     goto IL_AE;
                 }
                 goto IL_AE;
             }
             return(result);
         }
         IL_AE :;
     }
     return(null);
 }
Example #8
0
 public static void SetProperty(PswsCmdlet cmdlet, string propertyName, ProxyAddressCollection propertyValue)
 {
     ArgumentValidator.ThrowIfNull("cmdlet", cmdlet);
     if (propertyValue != null)
     {
         cmdlet.Parameters[propertyName] = propertyValue.ToStringArray();
     }
 }
Example #9
0
 // Token: 0x06001D78 RID: 7544 RVA: 0x000AA76C File Offset: 0x000A896C
 private string GetSipUri()
 {
     if (!this.IsContactView)
     {
         ProxyAddressCollection itemProperty = this.DataSource.GetItemProperty <ProxyAddressCollection>(ADRecipientSchema.EmailAddresses, null);
         return(InstantMessageUtilities.GetSipUri(itemProperty));
     }
     return(string.Empty);
 }
Example #10
0
 // Token: 0x06000B27 RID: 2855 RVA: 0x0004EF50 File Offset: 0x0004D150
 internal static string GetSipUri(ProxyAddressCollection proxyAddresses)
 {
     foreach (ProxyAddress proxyAddress in proxyAddresses)
     {
         if (proxyAddress.ProxyAddressString.StartsWith("sip:", StringComparison.OrdinalIgnoreCase))
         {
             return(proxyAddress.ProxyAddressString.ToLowerInvariant());
         }
     }
     return(null);
 }
Example #11
0
        internal static void RemoveProxy(ADRecipient recipient, ProxyAddressCollection collection, ProxyAddressPrefix prefix, ArrayList phoneNumbers, UMDialPlan dialPlan)
        {
            Hashtable hashtable = new Hashtable();

            foreach (object obj in phoneNumbers)
            {
                string extension = (string)obj;
                hashtable.Add(UMMailbox.BuildAddressStringFromExtensionAndPhoneContext(extension, dialPlan.PhoneContext), true);
            }
            UMMailbox.RemoveProxy(recipient, collection, prefix, hashtable);
        }
        protected static object GetPropertyBasedOnDefinition(PropertyDefinition definition, object propertyValue)
        {
            if (!(propertyValue is PSObject) || !(((PSObject)propertyValue).BaseObject is IList))
            {
                return(MockObjectCreator.GetSingleProperty(propertyValue, definition.Type));
            }
            IList list = ((PSObject)propertyValue).BaseObject as IList;

            if (definition.Type == typeof(ScheduleInterval[]))
            {
                List <ScheduleInterval> list2 = new List <ScheduleInterval>();
                foreach (object prop in list)
                {
                    list2.Add((ScheduleInterval)MockObjectCreator.GetSingleProperty(prop, typeof(ScheduleInterval)));
                }
                return(list2.ToArray());
            }
            MultiValuedPropertyBase multiValuedPropertyBase = null;

            if (definition.Type == typeof(ProxyAddress))
            {
                multiValuedPropertyBase = new ProxyAddressCollection();
            }
            else if (definition.Type == typeof(ApprovedApplicationCollection))
            {
                multiValuedPropertyBase = new ApprovedApplicationCollection();
            }
            else
            {
                if (definition.Type.FullName == "Microsoft.Exchange.Management.RecipientTasks.MailboxRights[]")
                {
                    if (MockObjectCreator.mailboxRightsEnum == null)
                    {
                        string assemblyFile = Path.Combine(ConfigurationContext.Setup.BinPath, "Microsoft.Exchange.Management.Recipient.dll");
                        MockObjectCreator.mailboxRightsEnum = Assembly.LoadFrom(assemblyFile).GetType("Microsoft.Exchange.Management.RecipientTasks.MailboxRights");
                    }
                    Array array = Array.CreateInstance(MockObjectCreator.mailboxRightsEnum, list.Count);
                    int   num   = 0;
                    foreach (object prop2 in list)
                    {
                        array.SetValue(MockObjectCreator.GetSingleProperty(prop2, MockObjectCreator.mailboxRightsEnum), num);
                        num++;
                    }
                    return(array);
                }
                multiValuedPropertyBase = new MultiValuedProperty <object>();
            }
            foreach (object prop3 in list)
            {
                multiValuedPropertyBase.Add(MockObjectCreator.GetSingleProperty(prop3, definition.Type));
            }
            return(multiValuedPropertyBase);
        }
Example #13
0
        private static object GetSipUri(IReadOnlyPropertyBag propertyBag)
        {
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)propertyBag[ADRecipientSchema.EmailAddresses];

            foreach (ProxyAddress proxyAddress in proxyAddressCollection)
            {
                if (proxyAddress.PrefixString.Equals("sip", StringComparison.OrdinalIgnoreCase))
                {
                    return(proxyAddress.ProxyAddressString.ToLower());
                }
            }
            return(" ");
        }
Example #14
0
        internal static bool CheckLegacyDnExistInProxyAddresses(string legacyDn, ADRawEntry adRawEntry)
        {
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adRawEntry[ADRecipientSchema.EmailAddresses];

            foreach (ProxyAddress proxyAddress in proxyAddressCollection)
            {
                if (proxyAddress.Prefix == ProxyAddressPrefix.X500 && string.Compare(proxyAddress.AddressString, legacyDn, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #15
0
        internal static int ProxyAddressCount(ProxyAddressCollection collection, ProxyAddressPrefix prefix)
        {
            int num = 0;

            foreach (ProxyAddress proxyAddress in collection)
            {
                if (proxyAddress.Prefix == prefix)
                {
                    num++;
                }
            }
            return(num);
        }
Example #16
0
        internal static void ClearProxy(ADRecipient recipient, ProxyAddressCollection targetAddresses, ProxyAddressPrefix targetPrefix, Hashtable safeTable)
        {
            Hashtable hashtable = new Hashtable();

            foreach (ProxyAddress proxyAddress in targetAddresses)
            {
                if (proxyAddress.Prefix == targetPrefix && (safeTable == null || !safeTable.ContainsKey(proxyAddress.AddressString)))
                {
                    hashtable.Add(proxyAddress.AddressString, true);
                }
            }
            UMMailbox.RemoveProxy(recipient, targetAddresses, targetPrefix, hashtable);
        }
Example #17
0
        internal static Hashtable GetAirSyncSafeTable(ProxyAddressCollection collection, ProxyAddressPrefix prefix, UMDialPlan dialPlan)
        {
            Hashtable hashtable = new Hashtable();

            foreach (ProxyAddress proxyAddress in collection)
            {
                if (proxyAddress.Prefix == prefix)
                {
                    hashtable.Add(proxyAddress.AddressString, true);
                    hashtable.Add(proxyAddress.AddressString.Substring(dialPlan.CountryOrRegionCode.Length + 1), true);
                }
            }
            return(hashtable);
        }
Example #18
0
        // Token: 0x06001D65 RID: 7525 RVA: 0x0007A88C File Offset: 0x00078A8C
        private static NetID GetNetIDWithPrefix(string netIdPrefix, IPropertyBag propertyBag)
        {
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)propertyBag[ADRecipientSchema.EmailAddresses];

            if (proxyAddressCollection != null)
            {
                ProxyAddress proxyAddress = proxyAddressCollection.FindPrimary(ProxyAddressPrefix.GetPrefix(netIdPrefix));
                if (null != proxyAddress)
                {
                    return(NetID.Parse(proxyAddress.ValueString));
                }
            }
            return(null);
        }
Example #19
0
        public static ProxyAddressCollection UpdateSipNameEumProxyAddress(ProxyAddressCollection emailAddresses)
        {
            if (emailAddresses == null)
            {
                throw new ArgumentNullException("emailAddresses");
            }
            string text = null;

            foreach (ProxyAddress proxyAddress in emailAddresses)
            {
                if (proxyAddress.Prefix == ProxyAddressPrefix.SIP)
                {
                    if (text != null)
                    {
                        text = null;
                        break;
                    }
                    text = proxyAddress.ValueString;
                }
            }
            EumProxyAddress eumProxyAddress = null;

            if (!string.IsNullOrEmpty(text))
            {
                foreach (ProxyAddress proxyAddress2 in emailAddresses)
                {
                    if (proxyAddress2.Prefix == ProxyAddressPrefix.UM && proxyAddress2.IsPrimaryAddress)
                    {
                        EumProxyAddress eumProxyAddress2 = proxyAddress2 as EumProxyAddress;
                        EumAddress      eumAddress       = (EumAddress)eumProxyAddress2;
                        if (eumAddress.IsSipExtension && !string.Equals(eumAddress.Extension, text, StringComparison.OrdinalIgnoreCase))
                        {
                            eumProxyAddress = eumProxyAddress2;
                            break;
                        }
                    }
                }
            }
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)emailAddresses.Clone();

            if (eumProxyAddress != null)
            {
                string          phoneContext = ((EumAddress)eumProxyAddress).PhoneContext;
                EumAddress      eumAddress2  = new EumAddress(text, phoneContext);
                EumProxyAddress item         = new EumProxyAddress(eumAddress2.ToString(), true);
                proxyAddressCollection.Remove(eumProxyAddress);
                proxyAddressCollection.Add(item);
            }
            return(proxyAddressCollection);
        }
Example #20
0
        public static bool IsMemberOf(RmsClientManagerContext clientContext, string recipientAddress, string groupAddress)
        {
            ArgumentValidator.ThrowIfNull("recipientAddress", recipientAddress);
            ArgumentValidator.ThrowIfNullOrEmpty("groupAddress", groupAddress);
            if (!ServerManager.instance.isHostingInstance)
            {
                throw new InvalidOperationException("Can't call IsMemberOf directly as ServerManager is NOT allowed to host in current calling process");
            }
            if (!SmtpAddress.IsValidSmtpAddress(recipientAddress))
            {
                ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Error, clientContext, string.Format("recipientAddress {0} is invalid SMTP Address", recipientAddress));
                return(false);
            }
            if (!RoutingAddress.IsValidAddress(groupAddress))
            {
                ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Error, clientContext, string.Format("groupAddress {0} is invalid SMTP Address", groupAddress));
                return(false);
            }
            ServerManager.InitializeIfNeeded();
            bool result;

            if (ServerManager.CheckForSpecialRmsOnlineTenantMembershipQuery(recipientAddress, groupAddress, out result))
            {
                return(result);
            }
            ADRawEntry adrawEntry = clientContext.ResolveRecipient(recipientAddress);

            if (adrawEntry == null)
            {
                ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Verbose, clientContext, string.Format("Failed to resolve recipientAddress {0} in Active Directory. Treat IsMemberOf for {1} against {2} as false", recipientAddress, recipientAddress, groupAddress));
                return(false);
            }
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses];
            SmtpProxyAddress       other = new SmtpProxyAddress(groupAddress, true);

            foreach (ProxyAddress proxyAddress in proxyAddressCollection)
            {
                if (proxyAddress.Equals(other))
                {
                    ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Success, clientContext, string.Format("IsMemberOf return true as proxyAddress {0} is the same is groupAddress {1}", recipientAddress, groupAddress));
                    return(true);
                }
            }
            RoutingAddress groupKey = new RoutingAddress(groupAddress);
            bool           result2  = ServerManager.instance.isMemberOfResolver.IsMemberOf(clientContext.RecipientSession, adrawEntry.Id, groupKey);

            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Success, clientContext, string.Format("IsMemberOf return {0} for proxyAddress {1} against groupAddress {2}", result2.ToString(CultureInfo.InvariantCulture), recipientAddress, groupAddress));
            return(result2);
        }
 public static LicenseeIdentity[] ConvertToLicenseeIdentities(RmsClientManagerContext context, string[] identities)
 {
     ArgumentValidator.ThrowIfNull("context", context);
     RmsClientManagerUtils.ThrowOnNullOrEmptyArrayArgument("identities", identities);
     LicenseeIdentity[] array = new LicenseeIdentity[identities.Length];
     for (int i = 0; i < identities.Length; i++)
     {
         if (!SmtpAddress.IsValidSmtpAddress(identities[i]))
         {
             throw new RightsManagementException(RightsManagementFailureCode.InvalidRecipient, ServerStrings.RecipientAddressInvalid(identities[i]));
         }
         ADRawEntry adrawEntry;
         try
         {
             adrawEntry = context.ResolveRecipient(identities[i]);
         }
         catch (ADTransientException innerException)
         {
             throw new ExchangeConfigurationException(ServerStrings.FailedToReadUserConfig(identities[i]), innerException);
         }
         catch (ADOperationException innerException2)
         {
             throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFound, ServerStrings.FailedToReadUserConfig(identities[i]), innerException2);
         }
         IList <string> list = RmsClientManagerUtils.EmptyProxyList;
         string         text = null;
         bool           flag = false;
         if (adrawEntry != null)
         {
             ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses];
             if (proxyAddressCollection != null && proxyAddressCollection.Count != 0)
             {
                 list = new List <string>(proxyAddressCollection.Count);
                 foreach (ProxyAddress proxyAddress in proxyAddressCollection)
                 {
                     list.Add(proxyAddress.ValueString);
                 }
             }
             SmtpAddress smtpAddress = (SmtpAddress)adrawEntry[ADRecipientSchema.PrimarySmtpAddress];
             if (smtpAddress.IsValidAddress)
             {
                 text = smtpAddress.ToString();
             }
             flag = RmsClientManagerUtils.TreatRecipientAsRMSSuperuser(context.OrgId, (RecipientTypeDetails)adrawEntry[ADRecipientSchema.RecipientTypeDetails]);
         }
         array[i] = new LicenseeIdentity(string.IsNullOrEmpty(text) ? identities[i] : text, list, flag);
     }
     return(array);
 }
        // Token: 0x06000960 RID: 2400 RVA: 0x00029ECC File Offset: 0x000280CC
        private static List <Tuple <string, KeyType> > GetExchangeEmailAddressesKeys(ADObject adObject)
        {
            ArgumentValidator.ThrowIfNull("adObject", adObject);
            List <Tuple <string, KeyType> > list = new List <Tuple <string, KeyType> >();
            ProxyAddressCollection          proxyAddressCollection = (ProxyAddressCollection)adObject[ADRecipientSchema.EmailAddresses];

            if (proxyAddressCollection != null && proxyAddressCollection.Count > 0)
            {
                foreach (ProxyAddress proxyAddress in proxyAddressCollection)
                {
                    list.Add(new Tuple <string, KeyType>(proxyAddress.AddressString, KeyType.EmailAddresses));
                }
            }
            return(list);
        }
Example #23
0
 internal static bool PhoneNumberExists(ProxyAddressCollection addresses, ProxyAddressPrefix prefix, string phoneNumber)
 {
     foreach (ProxyAddress proxyAddress in addresses)
     {
         if (proxyAddress.Prefix == prefix)
         {
             string extensionFromProxyAddress = UMMailbox.GetExtensionFromProxyAddress(proxyAddress);
             if (extensionFromProxyAddress.Equals(phoneNumber))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #24
0
 internal static string GetPrimaryExtension(ProxyAddressCollection emailAddresses, ProxyAddressPrefix prefix)
 {
     foreach (ProxyAddress proxyAddress in emailAddresses)
     {
         if (proxyAddress.IsPrimaryAddress && proxyAddress.Prefix == prefix)
         {
             string extensionFromProxyAddress = UMMailbox.GetExtensionFromProxyAddress(proxyAddress);
             if (extensionFromProxyAddress != null)
             {
                 return(extensionFromProxyAddress);
             }
         }
     }
     return(null);
 }
Example #25
0
        internal static void RemoveProxy(ADRecipient recipient, ProxyAddressCollection collection, ProxyAddressPrefix prefix, Hashtable addressStringTable)
        {
            List <ProxyAddress> list = new List <ProxyAddress>();

            foreach (ProxyAddress proxyAddress in collection)
            {
                if (proxyAddress.Prefix == prefix && addressStringTable.ContainsKey(proxyAddress.AddressString))
                {
                    list.Add(proxyAddress);
                }
            }
            foreach (ProxyAddress item in list)
            {
                collection.Remove(item);
            }
        }
Example #26
0
        public static ProxyAddressCollection ReplaceSipAddresses(ProxyAddressCollection sipAddresses, ProxyAddressCollection originalAddresses)
        {
            ProxyAddressCollection proxyAddressCollection = (sipAddresses != null) ? ((ProxyAddressCollection)sipAddresses.Clone()) : new ProxyAddressCollection();

            if (originalAddresses != null)
            {
                foreach (ProxyAddress proxyAddress in originalAddresses)
                {
                    if (proxyAddress.Prefix != ProxyAddressPrefix.SIP && !proxyAddressCollection.Contains(proxyAddress))
                    {
                        proxyAddressCollection.Add(proxyAddress);
                    }
                }
            }
            return(proxyAddressCollection);
        }
Example #27
0
        public static ProxyAddressCollection ReplaceSmtpAndX500Addresses(ProxyAddressCollection smtpAndX500Addresses, ProxyAddressCollection originalAddresses)
        {
            if (smtpAndX500Addresses == null)
            {
                throw new ArgumentNullException("smtpAndX500Addresses");
            }
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)smtpAndX500Addresses.Clone();
            ProxyAddress           proxyAddress           = null;
            int i = 0;

            while (i < proxyAddressCollection.Count)
            {
                if (proxyAddressCollection[i].Prefix == ProxyAddressPrefix.JRNL)
                {
                    if (proxyAddress == null)
                    {
                        proxyAddress = proxyAddressCollection[i];
                    }
                    proxyAddressCollection.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
            bool flag = false;

            if (originalAddresses != null)
            {
                foreach (ProxyAddress proxyAddress2 in originalAddresses)
                {
                    if (proxyAddress2.Prefix == ProxyAddressPrefix.JRNL)
                    {
                        flag = true;
                    }
                    if (proxyAddress2.Prefix != ProxyAddressPrefix.Smtp && proxyAddress2.Prefix != ProxyAddressPrefix.X500 && !proxyAddressCollection.Contains(proxyAddress2))
                    {
                        proxyAddressCollection.Add(proxyAddress2);
                    }
                }
            }
            if (proxyAddress != null && !flag)
            {
                proxyAddressCollection.Add(proxyAddress);
            }
            return(proxyAddressCollection);
        }
Example #28
0
        internal static MultiValuedProperty <string> GetExtensionsFromCollection(ProxyAddressCollection addresses, ProxyAddressPrefix prefix, string phoneContext)
        {
            MultiValuedProperty <string> multiValuedProperty = new MultiValuedProperty <string>();

            foreach (ProxyAddress proxyAddress in addresses)
            {
                if (proxyAddress.Prefix == prefix && (phoneContext == null || proxyAddress.AddressString.EndsWith(phoneContext)))
                {
                    string extensionFromProxyAddress = UMMailbox.GetExtensionFromProxyAddress(proxyAddress);
                    if (extensionFromProxyAddress != null)
                    {
                        multiValuedProperty.Add(extensionFromProxyAddress);
                    }
                }
            }
            return(multiValuedProperty);
        }
Example #29
0
 private static bool AtLeastOneAddressFoundInProxy(string[] addresses, ProxyAddressCollection proxyCollection)
 {
     foreach (ProxyAddress proxyAddress in proxyCollection)
     {
         if (!(proxyAddress.Prefix != ProxyAddressPrefix.Smtp))
         {
             foreach (string b in addresses)
             {
                 if (string.Equals(proxyAddress.AddressString, b, StringComparison.OrdinalIgnoreCase))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Example #30
0
        private TrackedUser(ADRecipient mailbox)
        {
            if (mailbox.ExternalEmailAddress != null && mailbox.ExternalEmailAddress is SmtpProxyAddress)
            {
                this.smtpAddress = new SmtpAddress(mailbox.ExternalEmailAddress.AddressString);
            }
            else
            {
                SmtpAddress primarySmtpAddress = mailbox.PrimarySmtpAddress;
                if (!mailbox.PrimarySmtpAddress.IsValidAddress)
                {
                    throw new TrackedUserCreationException("PrimarySmtpAddress is invalid: {0}", new object[]
                    {
                        mailbox.PrimarySmtpAddress
                    });
                }
                this.smtpAddress = mailbox.PrimarySmtpAddress;
            }
            if (mailbox.EmailAddresses == null || mailbox.EmailAddresses.Count == 0)
            {
                throw new TrackedUserCreationException("No EmailAddresses", new object[0]);
            }
            ProxyAddressCollection proxyAddressCollection = mailbox.EmailAddresses;

            foreach (ProxyAddress proxyAddress in mailbox.EmailAddresses)
            {
                if (proxyAddress is InvalidProxyAddress)
                {
                    TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Invalid proxies found, will use only valid ones", new object[0]);
                    IEnumerable <ProxyAddress> source = from proxy in mailbox.EmailAddresses
                                                        where !(proxy is InvalidProxyAddress)
                                                        select proxy;
                    proxyAddressCollection = new ProxyAddressCollection(source.ToArray <ProxyAddress>());
                    break;
                }
            }
            if (proxyAddressCollection.Count == 0)
            {
                throw new TrackedUserCreationException("All EmailAddresses discarded as invalid", new object[0]);
            }
            this.proxyAddresses            = proxyAddressCollection;
            this.adRecipient               = mailbox;
            this.readStatusTrackingEnabled = !(bool)mailbox[ADRecipientSchema.MessageTrackingReadStatusDisabled];
            this.PopulateProxyHashSet();
        }