private bool TryTranslateSid(SecurityIdentifier sid, out SecurityIdentifier mappedSID) { if (sid == null) { mappedSID = null; return(false); } mappedSID = null; MappedPrincipal mappedPrincipal = this.sourceMapper.BySid[sid]; if (mappedPrincipal == null) { MrsTracer.Service.Debug("{0} is not mappable on the source, ignoring", new object[] { sid }); return(false); } MappedPrincipal mappedPrincipal2 = null; if (mappedPrincipal.MailboxGuid != Guid.Empty) { mappedPrincipal2 = this.targetMapper.ByMailboxGuid[mappedPrincipal.MailboxGuid]; } if (mappedPrincipal2 == null && !string.IsNullOrEmpty(mappedPrincipal.LegacyDN)) { mappedPrincipal2 = this.targetMapper.ByX500Proxy[mappedPrincipal.LegacyDN]; } if (mappedPrincipal2 != null) { mappedSID = mappedPrincipal2.ObjectSid; } return(mappedSID != null); }
MappedPrincipal[] IMailbox.ResolvePrincipals(MappedPrincipal[] principals) { MrsTracer.ProxyClient.Function("RemoteMailbox.ResolvePrincipals", new object[0]); this.VerifyMailboxConnection(); if (!base.ServerVersion[8]) { Guid[] array = new Guid[principals.Length]; int i = 0; foreach (MappedPrincipal mappedPrincipal in principals) { if (!mappedPrincipal.HasField(MappedPrincipalFields.MailboxGuid)) { break; } array[i++] = mappedPrincipal.MailboxGuid; } if (i < principals.Length) { array = base.MrsProxy.IMailbox_GetMailboxGuidsFromPrincipals(base.Handle, principals); } List <Guid> list = new List <Guid>(); foreach (Guid guid in array) { if (guid != Guid.Empty) { list.Add(guid); } } MappedPrincipal[] array3 = base.MrsProxy.IMailbox_GetPrincipalsFromMailboxGuids(base.Handle, list.ToArray()); Dictionary <Guid, MappedPrincipal> dictionary = new Dictionary <Guid, MappedPrincipal>(); for (i = 0; i < array3.Length; i++) { if (array3[i] != null) { dictionary[list[i]] = array3[i]; } } MappedPrincipal[] array4 = new MappedPrincipal[array.Length]; for (i = 0; i < array.Length; i++) { array4[i] = null; MappedPrincipal mappedPrincipal2; if (array[i] != Guid.Empty && dictionary.TryGetValue(array[i], out mappedPrincipal2)) { array4[i] = mappedPrincipal2; } } return(array4); } return(base.MrsProxy.IMailbox_ResolvePrincipals(base.Handle, principals)); }
string[] IFilterBuilderHelper.MapRecipient(string recipientId) { MappedPrincipal mappedPrincipal = new MappedPrincipal(); mappedPrincipal.Alias = recipientId; MappedPrincipal[] array = this.Mailbox.ResolvePrincipals(new MappedPrincipal[] { mappedPrincipal }); if (array == null || array[0] == null) { return(null); } List <string> list = new List <string>(); for (mappedPrincipal = array[0]; mappedPrincipal != null; mappedPrincipal = mappedPrincipal.NextEntry) { if (!string.IsNullOrEmpty(mappedPrincipal.Alias)) { list.Add(mappedPrincipal.Alias); } if (!string.IsNullOrEmpty(mappedPrincipal.DisplayName)) { list.Add(mappedPrincipal.DisplayName); } if (!string.IsNullOrEmpty(mappedPrincipal.LegacyDN)) { list.Add(mappedPrincipal.LegacyDN); } ProxyAddressCollection proxyAddressCollection = new ProxyAddressCollection(mappedPrincipal.ProxyAddresses); ProxyAddress proxyAddress = proxyAddressCollection.FindPrimary(ProxyAddressPrefix.Smtp); if (proxyAddress != null && !string.IsNullOrEmpty(proxyAddress.AddressString)) { list.Add(proxyAddress.AddressString); } } return(list.ToArray()); }