예제 #1
0
        internal static bool TryGetBackEndWebServicesUrlFromSmtp(string smtpString, Func <SmtpAddress, IRecipientSession> createRecipientSession, out Uri ewsUri)
        {
            ewsUri = null;
            ProxyAddress proxyAddress;

            if (!ProxyAddress.TryParse(smtpString, out proxyAddress))
            {
                ExTraceGlobals.CafeTracer.TraceDebug <string>(0L, "[HttpProxyBackEndHelper.TryGetBackEndWebServicesUrlFromSmtp] The smtp address was invalid: {0}", smtpString);
                return(false);
            }
            if (proxyAddress.Prefix != ProxyAddressPrefix.Smtp)
            {
                ExTraceGlobals.CafeTracer.TraceDebug <string>(0L, "[HttpProxyBackEndHelper.TryGetBackEndWebServicesUrlFromSmtp] Non-SMTP address is not supported: {0}", smtpString);
                return(false);
            }
            SmtpAddress       arg     = new SmtpAddress(proxyAddress.AddressString);
            IRecipientSession session = createRecipientSession(arg);

            try
            {
                ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromProxyAddress(session, smtpString);
                ewsUri = BackEndLocator.GetBackEndWebServicesUrl(exchangePrincipal.MailboxInfo);
            }
            catch (ObjectNotFoundException ex)
            {
                ExTraceGlobals.CafeTracer.TraceDebug <string, string>(0L, "[HttpProxyBackEndHelper.TryGetBackEndWebServicesUrlFromSmtp] Couldn't find exchange principal for smtp address: {0}. Exception {1}", smtpString, ex.ToString());
                return(false);
            }
            catch (BackEndLocatorException ex2)
            {
                ExTraceGlobals.CafeTracer.TraceDebug <string, string>(0L, "[HttpProxyBackEndHelper.TryGetBackEndWebServicesUrlFromSmtp] Couldn't find exchange services url for smtp address: {0}. Exception: {1}", smtpString, ex2.ToString());
                return(false);
            }
            return(true);
        }
예제 #2
0
            private ADUser TryProxyAddress()
            {
                ProxyAddress proxyAddress;

                if (ProxyAddress.TryParse(this.userId, out proxyAddress))
                {
                    return(this.ConvertRecipientToUser(this.session.FindByProxyAddress(proxyAddress)));
                }
                return(null);
            }
        // Token: 0x0600189C RID: 6300 RVA: 0x00054C18 File Offset: 0x00052E18
        private GetPersonaOrganizationHierarchyResponse GetOrganizationHierarchy()
        {
            GetPersonaOrganizationHierarchyResponse getPersonaOrganizationHierarchyResponse = null;
            ADRecipient adrecipient = null;
            Guid        guid;

            if (Guid.TryParse(this.galObjectGuid, out guid))
            {
                ADObjectId adobjectId = new ADObjectId(guid);
                adrecipient = this.adRecipientSession.FindByObjectGuid(adobjectId.ObjectGuid);
            }
            else if (this.emailAddress != null && !string.IsNullOrEmpty(this.emailAddress.EmailAddress))
            {
                ProxyAddress proxyAddress = null;
                if (ProxyAddress.TryParse(this.emailAddress.EmailAddress, out proxyAddress))
                {
                    adrecipient = this.adRecipientSession.FindByProxyAddress(proxyAddress);
                }
                else
                {
                    this.WriteTrace("Invalid EmailAddress was specified. - {0}", new object[]
                    {
                        this.emailAddress.EmailAddress
                    });
                }
            }
            else
            {
                this.WriteTrace("Either GALGuid or EmailAddress must be specified.", new object[0]);
            }
            if (adrecipient != null)
            {
                IADOrgPerson iadorgPerson = adrecipient as IADOrgPerson;
                if (iadorgPerson != null)
                {
                    Persona[] managementChain = null;
                    Persona   manager         = null;
                    this.GetManagementChain(iadorgPerson, out managementChain, out manager);
                    Persona[] peers         = this.GetPeers(iadorgPerson);
                    Persona[] directReports = this.GetDirectReports(iadorgPerson);
                    getPersonaOrganizationHierarchyResponse = new GetPersonaOrganizationHierarchyResponse();
                    getPersonaOrganizationHierarchyResponse.ManagementChain = managementChain;
                    getPersonaOrganizationHierarchyResponse.Peers           = peers;
                    getPersonaOrganizationHierarchyResponse.DirectReports   = directReports;
                    getPersonaOrganizationHierarchyResponse.Manager         = manager;
                }
            }
            else
            {
                this.WriteTrace("GAL Recipient not found.", new object[0]);
            }
            return(getPersonaOrganizationHierarchyResponse);
        }
예제 #4
0
        private void InitializeIfNeeded()
        {
            if (this.smtpAddressToIdentity != null)
            {
                return;
            }
            this.smtpAddresses.Remove(null);
            List <ProxyAddress> list = new List <ProxyAddress>(this.smtpAddresses.Count);

            foreach (string text in this.smtpAddresses)
            {
                ProxyAddress item;
                if (ProxyAddress.TryParse(text, out item))
                {
                    list.Add(item);
                }
                else
                {
                    this.InvalidSmtpAddresses.Add(text);
                }
            }
            if (ObjectIdMapping.Tracer.IsTraceEnabled(TraceType.DebugTrace))
            {
                ObjectIdMapping.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "IdentityMapping.InitializeIfNeeded: performing lookup in AD. SMTP addresses={0}, LegacyDNs={1}", string.Join <ProxyAddress>(",", list), string.Join(",", this.InvalidSmtpAddresses));
            }
            this.smtpAddressToIdentity = new Dictionary <string, Guid>(StringComparer.OrdinalIgnoreCase);
            this.identityToSmtpAddress = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            if (list.Count > 0)
            {
                this.ResolveExternalIdForExchangeIdentity <ProxyAddress>(list.ToArray(), (ProxyAddress proxyAddress) => proxyAddress.AddressString, new Func <ProxyAddress[], PropertyDefinition[], Result <ADRawEntry>[]>(this.recipientSession.FindByProxyAddresses));
            }
            if (this.InvalidSmtpAddresses.Count > 0)
            {
                this.ResolveExternalIdForExchangeIdentity <string>(this.InvalidSmtpAddresses.ToArray(), (string legacyDn) => legacyDn, new Func <string[], PropertyDefinition[], Result <ADRawEntry>[]>(this.recipientSession.FindByLegacyExchangeDNs));
            }
            this.smtpAddresses.Clear();
        }
예제 #5
0
        private ProxyAddress[] GetProxyAddresses(IEnumerable <IStorePropertyBag> contacts)
        {
            HashSet <ProxyAddress> hashSet = new HashSet <ProxyAddress>();

            foreach (IStorePropertyBag storePropertyBag in contacts)
            {
                string valueOrDefault = storePropertyBag.GetValueOrDefault <string>(ContactSchema.Email1EmailAddress, null);
                if (!string.IsNullOrEmpty(valueOrDefault))
                {
                    ProxyAddress item;
                    if (ProxyAddress.TryParse(valueOrDefault, out item))
                    {
                        hashSet.Add(item);
                    }
                    else
                    {
                        this.Trace.TraceDebug <string>((long)this.tracingId, "RefreshGALContactsFolderCommand.GetProxyAddresses: emailAddress - {0} failed in ProxyAddress.TryParse method, ignoring this email address", valueOrDefault);
                    }
                }
            }
            ProxyAddress[] array = new ProxyAddress[hashSet.Count];
            hashSet.CopyTo(array);
            return(array);
        }
예제 #6
0
        // Token: 0x06001AB4 RID: 6836 RVA: 0x00064A9C File Offset: 0x00062C9C
        protected override GetPersonaNotesResponse InternalExecute()
        {
            GetPersonaNotesResponse getPersonaNotesResponse = new GetPersonaNotesResponse();
            ADObjectId adobjectId = null;
            PersonId   personId   = null;

            if (string.IsNullOrEmpty(this.personaId))
            {
                if (this.emailAddress == null || string.IsNullOrEmpty(this.emailAddress.EmailAddress))
                {
                    this.WriteTrace("Valid PersonaId or EmailAddress needs to be specified.", new object[0]);
                    return(getPersonaNotesResponse);
                }
                string text = this.emailAddress.EmailAddress;
                personId = Person.FindPersonIdByEmailAddress(base.CallContext.SessionCache.GetMailboxIdentityMailboxSession(), new XSOFactory(), text);
                if (personId == null)
                {
                    ProxyAddress proxyAddress = null;
                    if (!ProxyAddress.TryParse(text, out proxyAddress))
                    {
                        this.WriteTrace("EmailAddress is not valid - {0}", new object[]
                        {
                            text
                        });
                        return(getPersonaNotesResponse);
                    }
                    PropertyDefinition[] array = new PropertyDefinition[]
                    {
                        ADObjectSchema.Id
                    };
                    ADRawEntry adrawEntry = this.adRecipientSession.FindByProxyAddress(proxyAddress, array);
                    if (adrawEntry == null)
                    {
                        this.WriteTrace("Contact not found with specified EmailAddress - {0}", new object[]
                        {
                            text
                        });
                        return(getPersonaNotesResponse);
                    }
                    object[] properties = adrawEntry.GetProperties(array);
                    if (properties == null || properties.Length == 0)
                    {
                        this.WriteTrace("Contact not found with specified EmailAddress - {0}", new object[]
                        {
                            text
                        });
                        return(getPersonaNotesResponse);
                    }
                    adobjectId = (ADObjectId)properties[0];
                }
            }
            else if (IdConverter.EwsIdIsActiveDirectoryObject(this.personaId))
            {
                adobjectId = IdConverter.EwsIdToADObjectId(this.personaId);
            }
            else
            {
                personId = IdConverter.EwsIdToPersonId(this.personaId);
            }
            List <BodyContentAttributedValue> list = null;

            if (adobjectId != null)
            {
                list = this.GetNotesFromActiveDirectory(adobjectId);
            }
            else if (personId != null)
            {
                list = this.GetNotesFromStore(personId);
            }
            if (list != null && list.Count > 0)
            {
                getPersonaNotesResponse.PersonaWithNotes = new Persona
                {
                    PersonaId = new ItemId(),
                    PersonaId =
                    {
                        Id = this.personaId
                    },
                    Bodies = list.ToArray()
                };
            }
            return(getPersonaNotesResponse);
        }
        private static bool ProxyAddressValidator(object value)
        {
            ProxyAddress proxyAddress = null;

            return(ProxyAddress.TryParse(value as string, out proxyAddress));
        }