private void Discover(ExchangePrincipal principal, ADUser executingUser, out string ewsEndpoint, out DelegationTokenRequest ewsTokenRequest)
        {
            SmtpAddress              value           = principal.MailboxInfo.RemoteIdentity.Value;
            ADSessionSettings        sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(OrganizationId.ForestWideOrgId);
            IRecipientSession        tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.FullyConsistent, null, sessionSettings, ConfigScopes.TenantSubTree, 168, "Discover", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Search\\MailboxSearch\\MailboxSearchEwsClient.cs");
            ADUser                   aduser = null;
            TransportConfigContainer transportConfigContainer = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 171, "Discover", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Search\\MailboxSearch\\MailboxSearchEwsClient.cs").FindSingletonConfigurationObject <TransportConfigContainer>();

            if (transportConfigContainer != null && transportConfigContainer.OrganizationFederatedMailbox != SmtpAddress.NullReversePath)
            {
                SmtpAddress  organizationFederatedMailbox = transportConfigContainer.OrganizationFederatedMailbox;
                ProxyAddress proxyAddress = null;
                try
                {
                    proxyAddress = ProxyAddress.Parse(organizationFederatedMailbox.ToString());
                }
                catch (ArgumentException ex)
                {
                    ExTraceGlobals.SessionTracer.TraceError <string>((long)this.GetHashCode(), "Proxy address of organization federated mailbox is invalid: {0}", ex.ToString());
                }
                if (proxyAddress != null && !(proxyAddress is InvalidProxyAddress))
                {
                    aduser = (tenantOrRootOrgRecipientSession.FindByProxyAddress(proxyAddress) as ADUser);
                }
            }
            OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(OrganizationId.ForestWideOrgId);
            OrganizationRelationship organizationRelationship = organizationIdCacheValue.GetOrganizationRelationship(value.Domain);

            if (aduser == null || organizationRelationship == null)
            {
                throw new OrganizationNotFederatedException();
            }
            DelegationTokenRequest request = new DelegationTokenRequest
            {
                FederatedIdentity = aduser.GetFederatedIdentity(),
                EmailAddress      = aduser.GetFederatedSmtpAddress().ToString(),
                Target            = organizationRelationship.GetTokenTarget(),
                Offer             = Offer.Autodiscover
            };
            FedOrgCredentials credentials = new FedOrgCredentials(request, this.GetSecurityTokenService(aduser.OrganizationId));
            Uri uri = null;

            using (AutoDiscoverUserSettingsClient autoDiscoverUserSettingsClient = AutoDiscoverUserSettingsClient.CreateInstance(DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 215, "Discover", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Search\\MailboxSearch\\MailboxSearchEwsClient.cs"), credentials, value, organizationRelationship.TargetAutodiscoverEpr, MailboxSearchEwsClient.AutoDiscoverRequestedSettings))
            {
                UserSettings  userSettings  = autoDiscoverUserSettingsClient.Discover();
                StringSetting stringSetting = userSettings.GetSetting("ExternalEwsUrl") as StringSetting;
                if (stringSetting == null || !Uri.TryCreate(stringSetting.Value, UriKind.Absolute, out uri))
                {
                    throw new AutoDAccessException(ServerStrings.AutoDRequestFailed);
                }
            }
            ewsEndpoint = EwsWsSecurityUrl.Fix(uri.ToString());
            string text = null;

            if (executingUser.EmailAddresses != null && executingUser.EmailAddresses.Count > 0)
            {
                List <string> federatedEmailAddresses = executingUser.GetFederatedEmailAddresses();
                if (federatedEmailAddresses != null && federatedEmailAddresses.Count > 0)
                {
                    text = federatedEmailAddresses[0];
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                ewsTokenRequest = new DelegationTokenRequest
                {
                    FederatedIdentity = aduser.GetFederatedIdentity(),
                    EmailAddress      = aduser.GetFederatedSmtpAddress().ToString(),
                    Target            = organizationRelationship.GetTokenTarget(),
                    Offer             = Offer.MailboxSearch
                };
                return;
            }
            ewsTokenRequest = new DelegationTokenRequest
            {
                FederatedIdentity = executingUser.GetFederatedIdentity(),
                EmailAddress      = text.ToString(),
                Target            = organizationRelationship.GetTokenTarget(),
                Offer             = Offer.MailboxSearch
            };
        }
 public SenderFactory(IClient client, ProxyAddress address = ProxyAddress.SmsApiPl)
     : base(client, address)
 {
 }
Beispiel #3
0
        protected void ResolveRequestedADRecipient()
        {
            string resolveMethod = "Unknown";

            try
            {
                if (this.Caller != null)
                {
                    if (!string.IsNullOrEmpty(this.RequestData.LegacyDN) && string.Equals(this.Caller.LegacyExchangeDN, this.RequestData.LegacyDN, StringComparison.OrdinalIgnoreCase))
                    {
                        this.RequestedRecipient = this.Caller;
                        resolveMethod           = "CallerByLegacyDN";
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.RequestData.LegacyDN) && this.Caller.EmailAddresses != null)
                    {
                        string       x500 = "x500:" + this.RequestData.LegacyDN;
                        ProxyAddress a    = this.Caller.EmailAddresses.Find((ProxyAddress x) => string.Equals(x.ToString(), x500, StringComparison.OrdinalIgnoreCase));
                        if (a != null)
                        {
                            this.RequestedRecipient = this.Caller;
                            resolveMethod           = "CallerByX500";
                            return;
                        }
                    }
                    if (!string.IsNullOrEmpty(this.RequestData.EMailAddress) && SmtpAddress.IsValidSmtpAddress(this.RequestData.EMailAddress))
                    {
                        SmtpProxyAddress smtpProxy = new SmtpProxyAddress(this.RequestData.EMailAddress, true);
                        ProxyAddress     a2        = this.Caller.EmailAddresses.Find((ProxyAddress x) => x.Equals(smtpProxy));
                        if (a2 != null)
                        {
                            this.RequestedRecipient = this.Caller;
                            resolveMethod           = "CallerByProxy";
                            return;
                        }
                    }
                    if (AutodiscoverCommonUserSettings.HasLocalArchive(this.Caller) && AutodiscoverCommonUserSettings.IsEmailAddressTargetingArchive(this.Caller as ADUser, this.RequestData.EMailAddress))
                    {
                        this.RequestedRecipient = this.Caller;
                        resolveMethod           = "CallerByArchive";
                        return;
                    }
                }
                if (this.Caller == null)
                {
                    if (VariantConfiguration.InvariantNoFlightingSnapshot.Autodiscover.NoADLookupForUser.Enabled)
                    {
                        goto IL_285;
                    }
                }
                try
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .Current.TrackLatency(ServiceLatencyMetadata.RequestedUserADLatency, delegate()
                    {
                        IRecipientSession callerScopedRecipientSession = this.GetCallerScopedRecipientSession();
                        if (!string.IsNullOrEmpty(this.RequestData.LegacyDN))
                        {
                            this.RequestedRecipient = callerScopedRecipientSession.FindByLegacyExchangeDN(this.RequestData.LegacyDN);
                            if (this.RequestedRecipient != null)
                            {
                                resolveMethod = "FoundByLegacyDN";
                            }
                        }
                        if (this.RequestedRecipient == null && this.RequestData.EMailAddress != null && SmtpAddress.IsValidSmtpAddress(this.RequestData.EMailAddress))
                        {
                            Guid guid;
                            if (AutodiscoverCommonUserSettings.TryGetExchangeGuidFromEmailAddress(this.RequestData.EMailAddress, out guid))
                            {
                                this.RequestedRecipient = callerScopedRecipientSession.FindByExchangeGuidIncludingArchive(guid);
                                ADUser aduser           = this.RequestedRecipient as ADUser;
                                if (aduser != null && aduser.ArchiveGuid.Equals(guid) && RemoteMailbox.IsRemoteMailbox(aduser.RecipientTypeDetails) && aduser.ArchiveDatabase == null)
                                {
                                    this.RequestedRecipient = null;
                                }
                                if (this.RequestedRecipient != null)
                                {
                                    resolveMethod = "FoundByGUID";
                                }
                            }
                            if (this.RequestedRecipient == null)
                            {
                                SmtpProxyAddress proxyAddress = new SmtpProxyAddress(this.RequestData.EMailAddress, true);
                                this.RequestedRecipient       = callerScopedRecipientSession.FindByProxyAddress(proxyAddress);
                                if (this.RequestedRecipient != null)
                                {
                                    resolveMethod = "FoundBySMTP";
                                }
                            }
                        }
                    });
                }
                catch (LocalizedException ex)
                {
                    ExTraceGlobals.FrameworkTracer.TraceError <string, string>(0L, "[UpdateCacheCallback()] 'LocalizedException' Message=\"{0}\";StackTrace=\"{1}\"", ex.Message, ex.StackTrace);
                    Common.EventLog.LogEvent(AutodiscoverEventLogConstants.Tuple_ErrWebException, Common.PeriodicKey, new object[]
                    {
                        ex.Message,
                        ex.StackTrace
                    });
                    resolveMethod = "Exception";
                }
                IL_285 :;
            }
            finally
            {
                RequestDetailsLoggerBase <RequestDetailsLogger> .Current.AppendGenericInfo("ResolveMethod", resolveMethod);
            }
        }
Beispiel #4
0
        private void LoadProxySetting()
        {
            string proxyConfigFile = HostContext.GetConfigFile(WellKnownConfigFile.Proxy);

            if (File.Exists(proxyConfigFile))
            {
                // we expect the first line of the file is the proxy url
                Trace.Verbose($"Try read proxy setting from file: {proxyConfigFile}.");
                ProxyAddress = File.ReadLines(proxyConfigFile).FirstOrDefault() ?? string.Empty;
                ProxyAddress = ProxyAddress.Trim();
                Trace.Verbose($"{ProxyAddress}");
            }

            if (string.IsNullOrEmpty(ProxyAddress))
            {
                Trace.Verbose("Try read proxy setting from environment variable: 'VSTS_HTTP_PROXY'.");
                ProxyAddress = Environment.GetEnvironmentVariable("VSTS_HTTP_PROXY") ?? string.Empty;
                ProxyAddress = ProxyAddress.Trim();
                Trace.Verbose($"{ProxyAddress}");
            }

            if (!string.IsNullOrEmpty(ProxyAddress) && !Uri.IsWellFormedUriString(ProxyAddress, UriKind.Absolute))
            {
                Trace.Error($"The proxy url is not a well formed absolute uri string: {ProxyAddress}.");
                ProxyAddress = string.Empty;
            }

            if (!string.IsNullOrEmpty(ProxyAddress))
            {
                Trace.Info($"Config proxy at: {ProxyAddress}.");

                string proxyCredFile = HostContext.GetConfigFile(WellKnownConfigFile.ProxyCredentials);
                if (File.Exists(proxyCredFile))
                {
                    string lookupKey = File.ReadAllLines(proxyCredFile).FirstOrDefault();
                    if (!string.IsNullOrEmpty(lookupKey))
                    {
                        var credStore = HostContext.GetService <IAgentCredentialStore>();
                        var proxyCred = credStore.Read($"VSTS_AGENT_PROXY_{lookupKey}");
                        ProxyUsername = proxyCred.UserName;
                        ProxyPassword = proxyCred.Password;
                    }
                }

                if (string.IsNullOrEmpty(ProxyUsername))
                {
                    ProxyUsername = Environment.GetEnvironmentVariable("VSTS_HTTP_PROXY_USERNAME");
                }

                if (string.IsNullOrEmpty(ProxyPassword))
                {
                    ProxyPassword = Environment.GetEnvironmentVariable("VSTS_HTTP_PROXY_PASSWORD");
                }

                if (!string.IsNullOrEmpty(ProxyPassword))
                {
                    HostContext.SecretMasker.AddValue(ProxyPassword);
                }

                if (string.IsNullOrEmpty(ProxyUsername) || string.IsNullOrEmpty(ProxyPassword))
                {
                    Trace.Info($"Config proxy use DefaultNetworkCredentials.");
                }
                else
                {
                    Trace.Info($"Config authentication proxy as: {ProxyUsername}.");
                }

                string proxyBypassFile = HostContext.GetConfigFile(WellKnownConfigFile.ProxyBypass);
                if (File.Exists(proxyBypassFile))
                {
                    Trace.Verbose($"Try read proxy bypass list from file: {proxyBypassFile}.");
                    foreach (string bypass in File.ReadAllLines(proxyBypassFile))
                    {
                        if (string.IsNullOrWhiteSpace(bypass))
                        {
                            continue;
                        }
                        else
                        {
                            Trace.Info($"Bypass proxy for: {bypass}.");
                            ProxyBypassList.Add(bypass.Trim());
                        }
                    }
                }

                _agentWebProxy.Update(ProxyAddress, ProxyUsername, ProxyPassword, ProxyBypassList);
            }
            else
            {
                Trace.Info($"No proxy setting found.");
            }
        }
        private void ProcessGet()
        {
            using (this.user.Context.Tracker.Start(TimeId.UserInformationSettingsProcessGet))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing UserInformationSetting - Get");
                XmlNode xmlNode  = base.Response.OwnerDocument.CreateElement("Get", "Settings:");
                bool    flag     = this.version > 140;
                XmlNode xmlNode2 = null;
                XmlNode xmlNode3 = null;
                if (flag)
                {
                    xmlNode2 = base.Response.OwnerDocument.CreateElement("Accounts", "Settings:");
                    xmlNode3 = base.Response.OwnerDocument.CreateElement("Account", "Settings:");
                }
                XmlNode           xmlNode4 = base.Response.OwnerDocument.CreateElement("EmailAddresses", "Settings:");
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.user.OrganizationId), 203, "ProcessGet", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\UserInformationSetting.cs");
                ADRecipient       adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuid(this.user.ADUser.ExchangeGuid);
                base.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, tenantOrRootOrgRecipientSession.LastUsedDc);
                if (adrecipient != null && adrecipient.EmailAddresses != null)
                {
                    using (MultiValuedProperty <ProxyAddress> .Enumerator enumerator = adrecipient.EmailAddresses.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ProxyAddress proxyAddress = enumerator.Current;
                            AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found proxy address {0}!", proxyAddress.AddressString);
                            if (SmtpAddress.IsValidSmtpAddress(proxyAddress.AddressString))
                            {
                                if (this.version > 140 && proxyAddress.IsPrimaryAddress && proxyAddress.Prefix.DisplayName == "SMTP")
                                {
                                    AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found valid Primary Smtp proxy address {0}!", proxyAddress.AddressString);
                                    XmlNode xmlNode5 = base.Response.OwnerDocument.CreateElement("PrimarySmtpAddress", "Settings:");
                                    xmlNode5.InnerText = proxyAddress.AddressString;
                                    xmlNode4.AppendChild(xmlNode5);
                                }
                                else
                                {
                                    AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found valid Smtp proxy address {0}!", proxyAddress.AddressString);
                                    XmlNode xmlNode6 = base.Response.OwnerDocument.CreateElement("SmtpAddress", "Settings:");
                                    xmlNode6.InnerText = proxyAddress.AddressString;
                                    xmlNode4.AppendChild(xmlNode6);
                                }
                            }
                        }
                        goto IL_263;
                    }
                }
                AirSyncDiagnostics.TraceDebug <bool, bool>(ExTraceGlobals.RequestsTracer, this, "fullRecipient fullRecipient.EmailAddresses is null! fullRecipient == null: {0}, fullRecipient.EmailAddresses == null : {1}", adrecipient == null, adrecipient != null && adrecipient.EmailAddresses == null);
IL_263:
                if (flag)
                {
                    xmlNode3.AppendChild(xmlNode4);
                    xmlNode2.AppendChild(xmlNode3);
                }
                if (flag)
                {
                    List <AggregationSubscription> allSubscriptions = SubscriptionManager.GetAllSubscriptions(this.mailboxSession, AggregationSubscriptionType.AllEMail);
                    foreach (AggregationSubscription aggregationSubscription in allSubscriptions)
                    {
                        PimAggregationSubscription pimAggregationSubscription = aggregationSubscription as PimAggregationSubscription;
                        if (pimAggregationSubscription == null)
                        {
                            AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found AggregationSubscription that was not a PimAggregationSubscription {0}!", pimAggregationSubscription.SubscriptionGuid);
                        }
                        else
                        {
                            AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found valid subscription {0}!", pimAggregationSubscription.SubscriptionGuid);
                            XmlNode xmlNode7 = base.Response.OwnerDocument.CreateElement("Account", "Settings:");
                            XmlNode xmlNode8 = base.Response.OwnerDocument.CreateElement("AccountId", "Settings:");
                            xmlNode8.InnerText = pimAggregationSubscription.SubscriptionGuid.ToString();
                            xmlNode7.AppendChild(xmlNode8);
                            XmlNode xmlNode9 = base.Response.OwnerDocument.CreateElement("AccountName", "Settings:");
                            xmlNode9.InnerText = pimAggregationSubscription.Name;
                            xmlNode7.AppendChild(xmlNode9);
                            XmlNode xmlNode10 = base.Response.OwnerDocument.CreateElement("UserDisplayName", "Settings:");
                            xmlNode10.InnerText = pimAggregationSubscription.UserDisplayName;
                            xmlNode7.AppendChild(xmlNode10);
                            if (!pimAggregationSubscription.SendAsCapable || !SubscriptionManager.IsValidForSendAs(pimAggregationSubscription.SendAsState, pimAggregationSubscription.Status))
                            {
                                XmlNode newChild = base.Response.OwnerDocument.CreateElement("SendDisabled", "Settings:");
                                xmlNode7.AppendChild(newChild);
                            }
                            XmlNode xmlNode11 = base.Response.OwnerDocument.CreateElement("PrimarySmtpAddress", "Settings:");
                            xmlNode11.InnerText = pimAggregationSubscription.UserEmailAddress.ToString();
                            xmlNode4            = base.Response.OwnerDocument.CreateElement("EmailAddresses", "Settings:");
                            xmlNode4.AppendChild(xmlNode11);
                            xmlNode7.AppendChild(xmlNode4);
                            xmlNode2.AppendChild(xmlNode7);
                        }
                    }
                }
                XmlNode xmlNode12 = base.Response.OwnerDocument.CreateElement("Status", "Settings:");
                XmlNode xmlNode13 = xmlNode12;
                int     num       = (int)this.status;
                xmlNode13.InnerText = num.ToString(CultureInfo.InvariantCulture);
                base.Response.AppendChild(xmlNode12);
                if (flag)
                {
                    xmlNode.AppendChild(xmlNode2);
                }
                else
                {
                    xmlNode.AppendChild(xmlNode4);
                }
                base.Response.AppendChild(xmlNode);
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Done processing UserInformationSetting - Get.");
            }
        }
Beispiel #6
0
        // Token: 0x06005F71 RID: 24433 RVA: 0x00145E2C File Offset: 0x0014402C
        private static bool IsProxyAddressLocalExtension(ProxyAddress emailAddress)
        {
            string extensionFromProxyAddress = UMMailbox.GetExtensionFromProxyAddress(emailAddress);

            return(extensionFromProxyAddress != null && !Regex.IsMatch(extensionFromProxyAddress, "[^0-9]"));
        }
Beispiel #7
0
        internal static List <string> ValidateAddresses(IRecipientSession recipientSession, ADObjectId executingUserId, MultiValuedProperty <string> notificationEmailAddresses, out IList <LocalizedString> localizedWarnings)
        {
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            List <string> list = new List <string>(((notificationEmailAddresses != null) ? notificationEmailAddresses.Count : 0) + 1);

            localizedWarnings = new List <LocalizedString>(list.Count);
            if (executingUserId != null)
            {
                ADRecipient adrecipient = recipientSession.Read(executingUserId);
                if (adrecipient == null || !MobileDeviceTaskHelper.IsUserMailboxEnabled(adrecipient))
                {
                    localizedWarnings.Add(Strings.LogonUserIsNotAValidADRecipient(executingUserId.ToString()));
                }
                else
                {
                    list.Add(adrecipient.PrimarySmtpAddress.ToString());
                }
            }
            if (notificationEmailAddresses != null)
            {
                foreach (string text in notificationEmailAddresses)
                {
                    if (!SmtpAddress.IsValidSmtpAddress(text))
                    {
                        ADRecipient[] array = recipientSession.FindByANR(text, 2, null);
                        if (array == null || array.Length != 1 || !MobileDeviceTaskHelper.IsUserMailboxEnabled(array[0]))
                        {
                            localizedWarnings.Add(Strings.InvalidSmtpAddressOrAlias(text));
                        }
                        else
                        {
                            list.Add(array[0].PrimarySmtpAddress.ToString());
                        }
                    }
                    else
                    {
                        IRecipientSession recipientSession2 = recipientSession;
                        if (GlobalSettings.IsMultiTenancyEnabled)
                        {
                            try
                            {
                                ADSessionSettings sessionSettings = ADSessionSettings.FromTenantAcceptedDomain(SmtpAddress.Parse(text).Domain);
                                recipientSession2 = DirectorySessionFactory.Default.CreateTenantRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 240, "ValidateAddresses", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\AirSync\\MobileDeviceTaskHelper.cs");
                            }
                            catch (CannotResolveTenantNameException)
                            {
                                localizedWarnings.Add(Strings.InvalidSmtpAddressOrAlias(text));
                                recipientSession2 = null;
                            }
                        }
                        if (recipientSession2 != null)
                        {
                            ADRecipient adrecipient2 = recipientSession2.FindByProxyAddress(ProxyAddress.Parse(text));
                            if (adrecipient2 == null)
                            {
                                localizedWarnings.Add(Strings.InvalidSmtpAddressOrAlias(text));
                            }
                            else
                            {
                                list.Add(adrecipient2.PrimarySmtpAddress.ToString());
                            }
                        }
                    }
                }
            }
            return(list);
        }
 public PhonebookFactory(ProxyAddress address = ProxyAddress.SmsApiPl)
     : base(address)
 {
 }
 public PhonebookFactory(IClient client, ProxyAddress address = ProxyAddress.SmsApiPl)
     : base(client, address)
 {
 }
 bool IRecipientSession.IsRecipientInOrg(ProxyAddress proxyAddress)
 {
     return(base.InvokeWithAPILogging <bool>(() => this.GetSession().IsRecipientInOrg(proxyAddress), "IsRecipientInOrg"));
 }
        private static bool ProxyAddressValidator(object value)
        {
            ProxyAddress proxyAddress = null;

            return(ProxyAddress.TryParse(value as string, out proxyAddress));
        }
 TResult IRecipientSession.FindMiniRecipientByProxyAddress <TResult>(ProxyAddress proxyAddress, IEnumerable <PropertyDefinition> properties)
 {
     return(base.InvokeGetObjectWithAPILogging <TResult>(() => this.ExecuteSingleObjectQueryWithFallback <TResult>((IRecipientSession session) => session.FindMiniRecipientByProxyAddress <TResult>(proxyAddress, properties), null, properties), "FindMiniRecipientByProxyAddress"));
 }
 TEntry IRecipientSession.FindByProxyAddress <TEntry>(ProxyAddress proxyAddress)
 {
     return(base.InvokeGetObjectWithAPILogging <TEntry>(() => this.GetSession().FindByProxyAddress <TEntry>(proxyAddress), "FindByProxyAddress"));
 }
 ADRecipient IRecipientSession.FindByProxyAddress(ProxyAddress proxyAddress)
 {
     return(base.InvokeGetObjectWithAPILogging <ADRecipient>(() => this.ExecuteSingleObjectQueryWithFallback <ADRecipient>((IRecipientSession session) => session.FindByProxyAddress(proxyAddress), null, null), "FindByProxyAddress"));
 }
 public MMSFactory(ProxyAddress address = ProxyAddress.SmsApiPl)
     : base(address)
 {
 }
        private IEnumerable <MailTips> GetMailTipsInBatches(MailTipsState mailTipsState)
        {
            Exception ex = null;

            try
            {
                using (IStandardBudget standardBudget = StandardBudget.Acquire(mailTipsState.ClientSecurityContext.UserSid, BudgetType.Owa, ADSessionSettings.FromRootOrgScopeSet()))
                {
                    string callerInfo = "MailTipsNotificationHandler.GetMailTipsInBatches";
                    standardBudget.CheckOverBudget();
                    standardBudget.StartConnection(callerInfo);
                    standardBudget.StartLocal(callerInfo, default(TimeSpan));
                    mailTipsState.Budget = standardBudget;
                    ClientContext clientContext = ClientContext.Create(mailTipsState.ClientSecurityContext, mailTipsState.Budget, mailTipsState.LogonUserTimeZone, mailTipsState.LogonUserCulture);
                    ((InternalClientContext)clientContext).QueryBaseDN = mailTipsState.QueryBaseDn;
                    ExTraceGlobals.CoreCallTracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "QueryBaseDN set to {0}", mailTipsState.QueryBaseDn);
                    ProxyAddress sendingAsProxyAddress = this.GetSendingAsProxyAddress(mailTipsState);
                    mailTipsState.CachedOrganizationConfiguration = CachedOrganizationConfiguration.GetInstance(mailTipsState.LogonUserOrgId, CachedOrganizationConfiguration.ConfigurationTypes.All);
                    ExTraceGlobals.CoreCallTracer.TraceDebug <OrganizationId>((long)this.GetHashCode(), "Organization ID = {0}", mailTipsState.LogonUserOrgId);
                    try
                    {
                        int num = 0;
                        do
                        {
                            ProxyAddress[] nextBatch = MailTipsNotificationHandler.GetNextBatch(mailTipsState.RecipientsInfo, ref num);
                            mailTipsState.GetMailTipsQuery            = new GetMailTipsQuery(this.GetHashCode(), clientContext, sendingAsProxyAddress, mailTipsState.CachedOrganizationConfiguration, nextBatch, MailTipTypes.OutOfOfficeMessage | MailTipTypes.MailboxFullStatus | MailTipTypes.CustomMailTip | MailTipTypes.ExternalMemberCount | MailTipTypes.TotalMemberCount | MailTipTypes.DeliveryRestriction | MailTipTypes.ModerationStatus, mailTipsState.LogonUserCulture.LCID, mailTipsState.Budget, null);
                            mailTipsState.GetMailTipsQuery.ServerName = mailTipsState.ServerName;
                            mailTipsState.RequestLogger = mailTipsState.GetMailTipsQuery.RequestLogger;
                            IEnumerable <MailTips> collection = mailTipsState.GetMailTipsQuery.Execute();
                            mailTipsState.MailTipsResult.AddRange(collection);
                        }while (num < mailTipsState.RecipientsInfo.Length);
                    }
                    catch (UserWithoutFederatedProxyAddressException ex2)
                    {
                        ex = ex2;
                    }
                    catch (InvalidFederatedOrganizationIdException ex3)
                    {
                        ex = ex3;
                    }
                }
            }
            catch (OverBudgetException ex4)
            {
                ex = ex4;
            }
            catch (ObjectDisposedException ex5)
            {
                ex = ex5;
            }
            catch (OwaInvalidOperationException ex6)
            {
                ex = ex6;
            }
            finally
            {
                if (ex != null)
                {
                    MailTipsNotificationHandler.PopulateException(mailTipsState, ex, this.GetHashCode());
                }
            }
            return(mailTipsState.MailTipsResult);
        }
Beispiel #17
0
 // Token: 0x06005F6F RID: 24431 RVA: 0x00145DD5 File Offset: 0x00143FD5
 internal static ProxyAddress BuildProxyAddressFromExtensionAndPhoneContext(string extension, string prefixString, string phoneContext)
 {
     return(ProxyAddress.Parse(prefixString, UMMailbox.BuildAddressStringFromExtensionAndPhoneContext(extension, phoneContext)));
 }
Beispiel #18
0
 public Factory(ProxyAddress address = ProxyAddress.SmsApiPl)
 {
     Proxy(address);
 }
Beispiel #19
0
        internal static HashSet <string> GetAllSmtpProxiesForRecipientFilters(ICollection <string> filters, IRecipientSession session)
        {
            HashSet <string> hashSet = null;

            if (filters == null || filters.Count == 0)
            {
                return(null);
            }
            int num = Math.Min(filters.Count, 256);
            List <ProxyAddress> list = new List <ProxyAddress>(num);

            foreach (string text in filters)
            {
                if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text) && SmtpAddress.NullReversePath != (SmtpAddress)text)
                {
                    ExTraceGlobals.TaskTracer.TraceDebug <string>(0L, "Adding filter '{0}' for proxy lookup.", text);
                    list.Add(ProxyAddress.Parse(text));
                    if (list.Count > num)
                    {
                        ExTraceGlobals.TaskTracer.TraceDebug <int>(0L, "Not going to get proxy for all filters.  Total number of filters is {0}.", filters.Count);
                        break;
                    }
                }
            }
            if (list.Count == 0)
            {
                ExTraceGlobals.TaskTracer.TraceDebug(0L, "No filters need to be looked up, none are addresses.");
                return(null);
            }
            ProxyAddress[]        array  = list.ToArray();
            Result <ADRawEntry>[] array2 = session.FindByProxyAddresses(array, Utils.emailAddressesProperty);
            if (array2 == null)
            {
                return(null);
            }
            int i = 0;

            while (i < array2.Length)
            {
                Result <ADRawEntry> result = array2[i];
                if (result.Data == null)
                {
                    goto IL_1A5;
                }
                ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)result.Data[ADRecipientSchema.EmailAddresses];
                if (proxyAddressCollection != null)
                {
                    using (MultiValuedProperty <ProxyAddress> .Enumerator enumerator2 = proxyAddressCollection.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            ProxyAddress proxyAddress = enumerator2.Current;
                            if (ProxyAddressPrefix.Smtp.Equals(proxyAddress.Prefix) && !string.Equals(proxyAddress.AddressString, list[i].AddressString, StringComparison.OrdinalIgnoreCase))
                            {
                                if (hashSet == null)
                                {
                                    hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                                }
                                hashSet.Add(proxyAddress.AddressString);
                            }
                        }
                        goto IL_1C2;
                    }
                    goto IL_1A5;
                }
IL_1C2:
                i++;
                continue;
IL_1A5:
                ExTraceGlobals.TaskTracer.TraceDebug <ProxyAddress, ProviderError>(0L, "{0} cannot be found up due to {1}.", array[i], result.Error);
                goto IL_1C2;
            }
            return(hashSet);
        }
Beispiel #20
0
 public Factory(IClient client, ProxyAddress address = ProxyAddress.SmsApiPl)
     : this(address)
 {
     Client(client);
 }
        private void LoadProxySetting()
        {
            string proxyConfigFile = IOUtil.GetProxyConfigFilePath();

            if (File.Exists(proxyConfigFile))
            {
                // we expect the first line of the file is the proxy url
                Trace.Verbose($"Try read proxy setting from file: {proxyConfigFile}.");
                ProxyAddress = File.ReadLines(proxyConfigFile).FirstOrDefault() ?? string.Empty;
                ProxyAddress = ProxyAddress.Trim();
                Trace.Verbose($"{ProxyAddress}");
            }

            if (string.IsNullOrEmpty(ProxyAddress))
            {
                Trace.Verbose("Try read proxy setting from environment variable: 'VSTS_HTTP_PROXY'.");
                ProxyAddress = Environment.GetEnvironmentVariable("VSTS_HTTP_PROXY") ?? string.Empty;
                ProxyAddress = ProxyAddress.Trim();
                Trace.Verbose($"{ProxyAddress}");
            }

            if (!string.IsNullOrEmpty(ProxyAddress) && !Uri.IsWellFormedUriString(ProxyAddress, UriKind.Absolute))
            {
                Trace.Info($"The proxy url is not a well formed absolute uri string: {ProxyAddress}.");
                ProxyAddress = string.Empty;
            }

            if (!string.IsNullOrEmpty(ProxyAddress))
            {
                Trace.Info($"Config proxy at: {ProxyAddress}.");

                string proxyCredFile = IOUtil.GetProxyCredentialsFilePath();
                if (File.Exists(proxyCredFile))
                {
                    string lookupKey = File.ReadAllLines(proxyCredFile).FirstOrDefault();
                    if (!string.IsNullOrEmpty(lookupKey))
                    {
                        var credStore = HostContext.GetService <IAgentCredentialStore>();
                        var proxyCred = credStore.Read($"VSTS_AGENT_PROXY_{lookupKey}");
                        ProxyUsername = proxyCred.UserName;
                        ProxyPassword = proxyCred.Password;
                    }
                }

                if (string.IsNullOrEmpty(ProxyUsername))
                {
                    ProxyUsername = Environment.GetEnvironmentVariable("VSTS_HTTP_PROXY_USERNAME");
                }

                if (string.IsNullOrEmpty(ProxyPassword))
                {
                    ProxyPassword = Environment.GetEnvironmentVariable("VSTS_HTTP_PROXY_PASSWORD");
                }

                if (!string.IsNullOrEmpty(ProxyPassword))
                {
                    var secretMasker = HostContext.GetService <ISecretMasker>();
                    secretMasker.AddValue(ProxyPassword);
                }

                if (string.IsNullOrEmpty(ProxyUsername) || string.IsNullOrEmpty(ProxyPassword))
                {
                    Trace.Info($"Config proxy use DefaultNetworkCredentials.");
                    Credentials = CredentialCache.DefaultNetworkCredentials;
                }
                else
                {
                    Trace.Info($"Config authentication proxy as: {ProxyUsername}.");
                    Credentials = new NetworkCredential(ProxyUsername, ProxyPassword);
                }

                string proxyBypassFile = IOUtil.GetProxyBypassFilePath();
                if (File.Exists(proxyBypassFile))
                {
                    Trace.Verbose($"Try read proxy bypass list from file: {proxyBypassFile}.");
                    foreach (string bypass in File.ReadAllLines(proxyBypassFile))
                    {
                        if (string.IsNullOrWhiteSpace(bypass))
                        {
                            continue;
                        }
                        else
                        {
                            Trace.Info($"Bypass proxy for: {bypass}.");
                            try
                            {
                                Regex bypassRegex = new Regex(bypass.Trim(), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.ECMAScript);
                                _regExBypassList.Add(bypassRegex);
                                ProxyBypassList.Add(bypass.Trim());
                            }
                            catch (Exception ex)
                            {
                                Trace.Error($"{bypass} is not a valid Regex, won't bypass proxy for {bypass}.");
                                Trace.Error(ex);
                            }
                        }
                    }
                }
            }
            else
            {
                Trace.Info($"No proxy setting found.");
            }
        }
Beispiel #22
0
 public void Proxy(ProxyAddress address)
 {
     Proxy(new ProxyHTTP(_addresses[address]));
 }
Beispiel #23
0
        /// <summary>创建客户端会话</summary>
        /// <returns></returns>
        public virtual HttpClient EnsureCreate()
        {
            var http = _client;

            if (http == null)
            {
                var p = Proxy;
                if (p == null && !ProxyAddress.IsNullOrEmpty())
                {
                    Proxy = p = new WebProxy(ProxyAddress);
                }

                var handler = new HttpClientHandler();
                if (p != null)
                {
                    handler.UseProxy = true;
                    handler.Proxy    = p;
                }
                else
                {
                    handler.UseProxy = false;
                    handler.Proxy    = null;
                }
                if (AutomaticDecompression != DecompressionMethods.None)
                {
                    handler.AutomaticDecompression = AutomaticDecompression;
                }

                http = new HttpClient(handler);

                _client      = http;
                Request      = http.DefaultRequestHeaders;
                http.Timeout = new TimeSpan(0, 0, 0, 0, Timeout);
            }

            var req = http.DefaultRequestHeaders;

            if (!UserAgent.IsNullOrEmpty())
            {
                req.UserAgent.ParseAdd(UserAgent);
            }
            if (!Accept.IsNullOrEmpty())
            {
                req.Accept.ParseAdd(Accept);
            }
            if (!AcceptLanguage.IsNullOrEmpty())
            {
                req.AcceptLanguage.ParseAdd(AcceptLanguage);
            }
            if (AutomaticDecompression != DecompressionMethods.None)
            {
                req.AcceptEncoding.ParseAdd("gzip, deflate");
            }
            if (!Referer.IsNullOrEmpty())
            {
                req.Referrer = new Uri(Referer);
            }
            if (KeepAlive)
            {
                req.Connection.ParseAdd("keep-alive");
            }

            GetCookie(http);

            return(http);
        }
Beispiel #24
0
 private bool IsInternalToOrganization(string email)
 {
     return(this.Session.IsRecipientInOrg(ProxyAddress.Parse(email)));
 }
        protected static object GetSingleProperty(object prop, Type type)
        {
            if (prop == null)
            {
                return(null);
            }
            object obj = null;

            if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                obj = MockObjectCreator.GetSingleProperty(prop, type.GetGenericArguments()[0]);
            }
            else if (type == typeof(ADObjectId) && prop is PSObject)
            {
                obj = new ADObjectId(((PSObject)prop).Members["DistinguishedName"].Value.ToString(), new Guid(((PSObject)prop).Members["ObjectGuid"].Value.ToString()));
            }
            else if (type == typeof(EnhancedTimeSpan))
            {
                obj = EnhancedTimeSpan.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <EnhancedTimeSpan>))
            {
                obj = Unlimited <EnhancedTimeSpan> .Parse(prop.ToString());
            }
            else if (type == typeof(ByteQuantifiedSize))
            {
                obj = ByteQuantifiedSize.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <ByteQuantifiedSize>))
            {
                obj = Unlimited <ByteQuantifiedSize> .Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <int>))
            {
                obj = Unlimited <int> .Parse(prop.ToString());
            }
            else if (type == typeof(ProxyAddress))
            {
                obj = ProxyAddress.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpAddress))
            {
                obj = new SmtpAddress(prop.ToString());
            }
            else if (type == typeof(SmtpDomain))
            {
                obj = SmtpDomain.Parse(prop.ToString());
            }
            else if (type == typeof(CountryInfo))
            {
                obj = CountryInfo.Parse(prop.ToString());
            }
            else if (type == typeof(SharingPolicyDomain))
            {
                obj = SharingPolicyDomain.Parse(prop.ToString());
            }
            else if (type == typeof(ApprovedApplication))
            {
                obj = ApprovedApplication.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpDomainWithSubdomains))
            {
                obj = SmtpDomainWithSubdomains.Parse(prop.ToString());
            }
            else if (type == typeof(UMLanguage))
            {
                obj = UMLanguage.Parse(prop.ToString());
            }
            else if (type == typeof(UMSmartHost))
            {
                obj = UMSmartHost.Parse(prop.ToString());
            }
            else if (type == typeof(ScheduleInterval))
            {
                obj = ScheduleInterval.Parse(prop.ToString());
            }
            else if (type == typeof(NumberFormat))
            {
                obj = NumberFormat.Parse(prop.ToString());
            }
            else if (type == typeof(DialGroupEntry))
            {
                obj = DialGroupEntry.Parse(prop.ToString());
            }
            else if (type == typeof(CustomMenuKeyMapping))
            {
                obj = CustomMenuKeyMapping.Parse(prop.ToString());
            }
            else if (type == typeof(HolidaySchedule))
            {
                obj = HolidaySchedule.Parse(prop.ToString());
            }
            else if (type == typeof(UMTimeZone))
            {
                obj = UMTimeZone.Parse(prop.ToString());
            }
            else if (type == typeof(ServerVersion))
            {
                obj = ServerVersion.ParseFromSerialNumber(prop.ToString());
            }
            else if (type == typeof(X509Certificate2))
            {
                obj = new X509Certificate2(((PSObject)prop).Members["RawData"].Value as byte[]);
            }
            else if (type == typeof(LocalizedString))
            {
                obj = new LocalizedString(prop.ToString());
            }
            else if (type == typeof(ExchangeObjectVersion))
            {
                obj = ExchangeObjectVersion.Parse(prop.ToString());
            }
            else if (type == typeof(bool))
            {
                obj = bool.Parse(prop.ToString());
            }
            else if (type == typeof(SecurityPrincipalIdParameter))
            {
                obj = new SecurityPrincipalIdParameter(prop.ToString());
            }
            else if (type == typeof(ActiveDirectoryAccessRule))
            {
                obj = (prop as ActiveDirectoryAccessRule);
            }
            else if (type == typeof(ObjectId))
            {
                string text = prop.ToString();
                if (!ADObjectId.IsValidDistinguishedName(text) && text.Contains("/"))
                {
                    text = MockObjectCreator.ConvertDNFromTreeStructure(text);
                }
                obj = new ADObjectId(text);
            }
            else if (type.IsEnum)
            {
                try
                {
                    obj = Enum.Parse(type, prop.ToString());
                }
                catch (ArgumentException)
                {
                    obj = Enum.GetValues(type).GetValue(0);
                }
            }
            return(obj ?? prop);
        }
        public IGenericADUser FindMiniRecipientByProxyAddress(IRecipientSession recipientSession, ProxyAddress proxyAddress, PropertyDefinition[] miniRecipientProperties, out StorageMiniRecipient miniRecipient)
        {
            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            StorageMiniRecipient localMiniRecipient = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                localMiniRecipient = recipientSession.FindMiniRecipientByProxyAddress <StorageMiniRecipient>(proxyAddress, miniRecipientProperties);
            }, "DirectoryAccessor::FindMiniRecipientByProxyAddress");
            miniRecipient = localMiniRecipient;
            return(this.TranslateMiniRecipient(miniRecipient));
        }
 public SenderFactory(ProxyAddress address = ProxyAddress.SmsApiPl)
     : base(address)
 {
 }
 // Token: 0x060005AA RID: 1450 RVA: 0x0001F7D8 File Offset: 0x0001D9D8
 private void OnProxyLogonResponseReady(object extraData)
 {
     base.CallThreadEntranceMethod(delegate
     {
         IAsyncResult asyncResult = extraData as IAsyncResult;
         object lockObject        = this.LockObject;
         lock (lockObject)
         {
             try
             {
                 GuardedProxyExecution.Default.Decrement(this.AnchoredRoutingTarget.BackEndServer);
                 this.proxyLogonResponse = (HttpWebResponse)this.proxyLogonRequest.EndGetResponse(asyncResult);
                 this.PfdTracer.TraceResponse("ProxyLogonResponse", this.proxyLogonResponse);
                 this.proxyLogonResponseCookies = this.proxyLogonResponse.Cookies;
                 this.proxyLogonResponse.Close();
                 this.proxyLogonResponse             = null;
                 UserContextCookie userContextCookie = this.TryGetUserContextFromProxyLogonResponse();
                 if (userContextCookie != null && userContextCookie.MailboxUniqueKey != null)
                 {
                     string mailboxUniqueKey = userContextCookie.MailboxUniqueKey;
                     if (SmtpAddress.IsValidSmtpAddress(mailboxUniqueKey))
                     {
                         AnchorMailbox anchorMailbox = new SmtpAnchorMailbox(ProxyAddress.Parse("SMTP", mailboxUniqueKey).AddressString, this);
                         this.AnchoredRoutingTarget  = new AnchoredRoutingTarget(anchorMailbox, this.AnchoredRoutingTarget.BackEndServer);
                     }
                     else
                     {
                         try
                         {
                             AnchorMailbox anchorMailbox2 = new SidAnchorMailbox(new SecurityIdentifier(mailboxUniqueKey), this);
                             this.AnchoredRoutingTarget   = new AnchoredRoutingTarget(anchorMailbox2, this.AnchoredRoutingTarget.BackEndServer);
                         }
                         catch (ArgumentException)
                         {
                         }
                     }
                 }
                 ThreadPool.QueueUserWorkItem(new WaitCallback(this.BeginProxyRequest));
                 this.State = ProxyRequestHandler.ProxyState.PrepareServerRequest;
             }
             catch (WebException ex)
             {
                 if (ex.Status == WebExceptionStatus.ProtocolError && ((HttpWebResponse)ex.Response).StatusCode == (HttpStatusCode)442)
                 {
                     this.RedirectOn442Response();
                 }
                 else
                 {
                     this.CompleteWithError(ex, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
                 }
             }
             catch (HttpException ex2)
             {
                 this.CompleteWithError(ex2, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (IOException ex3)
             {
                 this.CompleteWithError(ex3, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (HttpProxyException ex4)
             {
                 this.CompleteWithError(ex4, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
         }
     });
 }
Beispiel #29
0
        public static string ConvertToString(object item, Type type)
        {
            if (item != null)
            {
                type = (type ?? item.GetType());
                if (type == typeof(ExchangeObjectVersion))
                {
                    return(((ExchangeObjectVersion)item).ToInt64().ToString());
                }
                if (typeof(Enum).IsAssignableFrom(type))
                {
                    return(item.ToString());
                }
                if (type == typeof(ProxyAddressCollection))
                {
                    ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)item;
                    if (proxyAddressCollection.Count <= 0)
                    {
                        goto IL_21C;
                    }
                    StringBuilder stringBuilder = new StringBuilder();
                    using (MultiValuedProperty <ProxyAddress> .Enumerator enumerator = proxyAddressCollection.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ProxyAddress item2 = enumerator.Current;
                            stringBuilder.Append(SearchHelper.ConvertToString(item2, typeof(ProxyAddress)));
                            stringBuilder.Append(',');
                        }
                        goto IL_21C;
                    }
                }
                if (type == typeof(ADObjectId))
                {
                    return(SearchHelper.ConvertToString(((ADObjectId)item).GetBytes(), typeof(byte[])));
                }
                if (type == typeof(OrganizationId))
                {
                    return(SearchHelper.ConvertToString(((OrganizationId)item).GetBytes(Encoding.Unicode), typeof(byte[])));
                }
                if (type == typeof(string))
                {
                    return((string)item);
                }
                if (type == typeof(ProxyAddress))
                {
                    return(((ProxyAddress)item).ProxyAddressString);
                }
                if (type == typeof(SmtpAddress))
                {
                    return(SearchHelper.ConvertToString(((SmtpAddress)item).GetBytes(), typeof(byte[])));
                }
                if (type == typeof(Guid))
                {
                    return(((Guid)item).ToString());
                }
                if (type == typeof(SmtpDomain))
                {
                    return(((SmtpDomain)item).ToString());
                }
                if (type == typeof(SecurityIdentifier))
                {
                    return(((SecurityIdentifier)item).ToString());
                }
                if (type == typeof(byte[]))
                {
                    return(Convert.ToBase64String((byte[])item));
                }
                return(ValueConvertor.ConvertValueToString(item, null));
            }
IL_21C:
            return(string.Empty);
        }
Beispiel #30
0
        private ADUser GetADUser(ulong puid, string emailAddress)
        {
            ADUser result;

            try
            {
                ADUser aduser = ((ADUser)this.tenantRecipientSession.FindByObjectGuid(ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid))) ?? this.tenantRecipientSession.FindByProxyAddress <ADUser>(ProxyAddress.Parse(emailAddress));
                FBLPerfCounters.NumberOfSuccessfulMSERVReadRequests.Increment();
                result = aduser;
            }
            catch (Exception ex)
            {
                FBLPerfCounters.NumberOfFailedMSERVReadRequests.Increment();
                LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_TransientFblErrorReadingMServ, new object[]
                {
                    ex.InnerException ?? ex
                });
                throw;
            }
            return(result);
        }