internal SharingProvider GetTargetSharingProvider(ADRecipient mailboxOwner) { Util.ThrowOnNullArgument(mailboxOwner, "mailboxOwner"); if (this.AvailableSharingProviders.Keys.Count == 1) { using (Dictionary <SharingProvider, CheckRecipientsResults> .KeyCollection.Enumerator enumerator = this.AvailableSharingProviders.Keys.GetEnumerator()) { if (enumerator.MoveNext()) { SharingProvider sharingProvider = enumerator.Current; ExTraceGlobals.SharingTracer.TraceDebug <ADRecipient, SharingProvider>((long)this.GetHashCode(), "{0}: Found target provider {1} for current user.", mailboxOwner, sharingProvider); return(sharingProvider); } } } foreach (KeyValuePair <SharingProvider, CheckRecipientsResults> keyValuePair in this.AvailableSharingProviders) { SharingProvider key = keyValuePair.Key; CheckRecipientsResults value = keyValuePair.Value; if (value != null && mailboxOwner.IsAnyAddressMatched(ValidRecipient.ConvertToStringArray(value.ValidRecipients))) { ExTraceGlobals.SharingTracer.TraceDebug <ADRecipient, SharingProvider>((long)this.GetHashCode(), "{0}: Found target provider {1} for current user.", mailboxOwner, key); return(key); } } ExTraceGlobals.SharingTracer.TraceError <ADRecipient>((long)this.GetHashCode(), "{0}: No available provider is found for this user.", mailboxOwner); return(null); }
private static SharedFolderDataRecipient TryFindMatchingRecipient(SharedFolderData sharedFolderData, ADRecipient mailboxOwner) { foreach (SharedFolderDataRecipient sharedFolderDataRecipient in sharedFolderData.Recipients) { if (mailboxOwner.IsAnyAddressMatched(new string[] { sharedFolderDataRecipient.SmtpAddress })) { return(sharedFolderDataRecipient); } } return(null); }