Ejemplo n.º 1
0
        // Token: 0x06000B54 RID: 2900 RVA: 0x0002DE60 File Offset: 0x0002C060
        private static ExchangeService CreateExchangeService(string domain, OrgExtensionTable.RequestData requestData)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            ADUser orgMailbox = OrgExtensionTable.GetOrgMailbox(domain);

            requestData.OrgMailboxAdUserLookupTime = stopwatch.ElapsedMilliseconds;
            if (orgMailbox == null)
            {
                return(null);
            }
            ExchangePrincipal exchangePrincipal;

            try
            {
                exchangePrincipal = ExchangePrincipal.FromADUser(orgMailbox, null);
            }
            catch (ObjectNotFoundException exception)
            {
                ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrganizationMailboxWebServiceUrlRetrievalFailed, domain, new object[]
                {
                    "ProcessOrgExtensions",
                    ExtensionDiagnostics.GetLoggedExceptionString(exception)
                });
                return(null);
            }
            Uri backEndWebServicesUrl;

            try
            {
                backEndWebServicesUrl = BackEndLocator.GetBackEndWebServicesUrl(exchangePrincipal.MailboxInfo);
                stopwatch.Stop();
                requestData.WebServiceUrlLookupTime = stopwatch.ElapsedMilliseconds - requestData.OrgMailboxAdUserLookupTime;
            }
            catch (BackEndLocatorException exception2)
            {
                ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrganizationMailboxWebServiceUrlRetrievalFailed, domain, new object[]
                {
                    "ProcessOrgExtensions",
                    ExtensionDiagnostics.GetLoggedExceptionString(exception2)
                });
                return(null);
            }
            ExchangeService exchangeService = new ExchangeService(4);

            exchangeService.Url = backEndWebServicesUrl;
            exchangeService.PrivilegedUserId            = new PrivilegedUserId(0, 2, orgMailbox.PrimarySmtpAddress.ToString());
            exchangeService.PrivilegedUserId.BudgetType = new PrivilegedUserIdBudgetType?(2);
            RemoteCertificateValidationCallback callback = (object param0, X509Certificate param1, X509Chain param2, SslPolicyErrors param3) => true;

            CertificateValidationManager.RegisterCallback("Extension.OrgExtensionTable", callback);
            exchangeService.HttpHeaders.Add(CertificateValidationManager.ComponentIdHeaderName, "Extension.OrgExtensionTable");
            return(exchangeService);
        }
Ejemplo n.º 2
0
 // Token: 0x06000B57 RID: 2903 RVA: 0x0002E140 File Offset: 0x0002C340
 private static bool GetClientExtensionTimeoutIsAllowed()
 {
     if (OrgExtensionTable.registryChangeListener == null)
     {
         OrgExtensionTable.Tracer.TraceDebug(0L, "Setting Registry Change Listener for UseGetClientExtensionTimeout Key.");
         OrgExtensionTable.registryChangeListener = new RegistryChangeListener(OwaConstants.OwaSetupInstallKey, new EventArrivedEventHandler(OrgExtensionTable.UseGetClientExtensionTimeoutRegistryKeyChangeHandler));
     }
     if (OrgExtensionTable.UseGetClientExtensionTimeout == null)
     {
         OrgExtensionTable.UseGetClientExtensionTimeout = new bool?(OrgExtensionTable.UseGetClientExtensionTimeoutValueFromRegistry());
     }
     return(OrgExtensionTable.UseGetClientExtensionTimeout.Value);
 }
Ejemplo n.º 3
0
 // Token: 0x06000B53 RID: 2899 RVA: 0x0002DE04 File Offset: 0x0002C004
 internal static void ConfigureOrgExtension(string domain, string extensionId, bool isEnabled, bool isMandatory, bool isEnabledByDefault, ClientExtensionProvidedTo providedTo, string[] specificUsers)
 {
     OrgExtensionTable.ExecuteWebServicesAction(delegate
     {
         OrgExtensionTable.RequestData arg = new OrgExtensionTable.RequestData();
         ExchangeService exchangeService   = OrgExtensionTable.CreateExchangeServiceDelegate(domain, arg);
         if (exchangeService == null)
         {
             return;
         }
         ClientExtension clientExtension = new ClientExtension(0, 0, null, null, null, isEnabled, isMandatory, isEnabledByDefault, providedTo, (specificUsers == null) ? null : new StringList(specificUsers), string.Empty, string.Empty);
         exchangeService.SetClientExtension(new List <SetClientExtensionAction>
         {
             new SetClientExtensionAction(2, extensionId, clientExtension)
         });
     });
 }
Ejemplo n.º 4
0
 // Token: 0x06000B52 RID: 2898 RVA: 0x0002DD30 File Offset: 0x0002BF30
 internal static void SetOrgExtension(string domain, SetClientExtensionActionId actionId, string extensionId, ExtensionData extensionData)
 {
     OrgExtensionTable.ExecuteWebServicesAction(delegate
     {
         OrgExtensionTable.RequestData arg = new OrgExtensionTable.RequestData();
         ExchangeService exchangeService   = OrgExtensionTable.CreateExchangeServiceDelegate(domain, arg);
         if (exchangeService == null)
         {
             return;
         }
         MemoryStream memoryStream = null;
         XmlWriter xmlWriter       = null;
         try
         {
             ClientExtension clientExtension = null;
             if (extensionData != null)
             {
                 memoryStream = new MemoryStream();
                 xmlWriter    = new XmlTextWriter(memoryStream, Encoding.UTF8);
                 extensionData.Manifest.WriteTo(xmlWriter);
                 xmlWriter.Flush();
                 memoryStream.Position = 0L;
                 clientExtension       = new ClientExtension(extensionData.Type.Value, extensionData.Scope.Value, memoryStream, extensionData.MarketplaceAssetID, extensionData.MarketplaceContentMarket, extensionData.IsAvailable, extensionData.IsMandatory, extensionData.IsEnabledByDefault, extensionData.ProvidedTo, (extensionData.SpecificUsers == null) ? null : new StringList(extensionData.SpecificUsers), extensionData.AppStatus, extensionData.Etoken);
             }
             exchangeService.SetClientExtension(new List <SetClientExtensionAction>
             {
                 new SetClientExtensionAction(actionId, extensionId, clientExtension)
             });
         }
         finally
         {
             if (xmlWriter != null)
             {
                 xmlWriter.Close();
             }
             if (memoryStream != null)
             {
                 memoryStream.Close();
             }
         }
     });
 }
Ejemplo n.º 5
0
        // Token: 0x06000AFA RID: 2810 RVA: 0x0002C438 File Offset: 0x0002A638
        internal override MailAppsResult GetExchangeDiagnosticsInfoData(DiagnosableParameters argument)
        {
            MailAppsResult mailAppsResult = new MailAppsResult();
            string         text           = argument.Argument;

            if (!string.IsNullOrEmpty(text))
            {
                string value = null;
                string text2 = ",val=";
                int    num   = text.IndexOf(text2);
                if (num != -1)
                {
                    value = text.Substring(num + text2.Length);
                    text  = argument.Argument.Substring(0, num);
                }
                MailAppsArgument mailAppsArgument = new MailAppsArgument(text);
                if (mailAppsArgument.HasArgument("org") && mailAppsArgument.HasArgument("cmd"))
                {
                    bool              flag      = false;
                    string            argument2 = mailAppsArgument.GetArgument <string>("org");
                    ExchangePrincipal exchangePrincipal;
                    if (mailAppsArgument.HasArgument("usr"))
                    {
                        string            argument3  = mailAppsArgument.GetArgument <string>("usr");
                        ADSessionSettings adSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(argument2);
                        exchangePrincipal = ExchangePrincipal.FromProxyAddress(adSettings, argument3 + "@" + argument2, RemotingOptions.AllowCrossSite);
                    }
                    else
                    {
                        ADUser orgMailbox = OrgExtensionTable.GetOrgMailbox(argument2);
                        exchangePrincipal = ExchangePrincipal.FromADUser(orgMailbox, null);
                        flag = true;
                    }
                    using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(exchangePrincipal, CultureInfo.CurrentCulture, "Client=WebServices"))
                    {
                        using (UserConfiguration folderConfiguration = UserConfigurationHelper.GetFolderConfiguration(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox), "ExtensionMasterTable", UserConfigurationTypes.XML, true, false))
                        {
                            using (Stream xmlStream = folderConfiguration.GetXmlStream())
                            {
                                if (string.Equals(mailAppsArgument.GetArgument <string>("cmd"), "set", StringComparison.OrdinalIgnoreCase) && num != -1)
                                {
                                    xmlStream.SetLength(0L);
                                    bool flag2 = string.IsNullOrEmpty(value);
                                    if (!flag2)
                                    {
                                        using (StreamWriter streamWriter = new StreamWriter(xmlStream, Encoding.UTF8))
                                        {
                                            streamWriter.Write(value);
                                        }
                                    }
                                    folderConfiguration.Save();
                                    if (flag)
                                    {
                                        OrgEmptyMasterTableCache.Singleton.Update(exchangePrincipal.MailboxInfo.OrganizationId, flag2);
                                    }
                                    mailAppsResult.Message = "Raw value saved.";
                                }
                                else
                                {
                                    using (StreamReader streamReader = new StreamReader(xmlStream, true))
                                    {
                                        mailAppsResult.RawMasterTable = streamReader.ReadToEnd();
                                        if (mailAppsArgument.HasArgument("len"))
                                        {
                                            int argument4 = mailAppsArgument.GetArgument <int>("len");
                                            if (argument4 > 0 && argument4 < mailAppsResult.RawMasterTable.Length)
                                            {
                                                mailAppsResult.RawMasterTable = mailAppsResult.RawMasterTable.Substring(0, argument4);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(mailAppsResult);
        }
Ejemplo n.º 6
0
        // Token: 0x06000B51 RID: 2897 RVA: 0x0002DA14 File Offset: 0x0002BC14
        internal static Dictionary <string, ExtensionData> GetOrgExtensions(StringList requestedExtensionIds, string domain, bool shouldReturnEnabledOnly, bool isUserScope, string userId, StringList userEnabledExtensionIds, StringList userDisabledExtensionIds, out OrgExtensionTable.RequestData requestData, bool isDebug, out string orgMasterTableRawXml, bool retrieveOnly1_0 = false)
        {
            Dictionary <string, ExtensionData> dictionary       = new Dictionary <string, ExtensionData>(StringComparer.OrdinalIgnoreCase);
            Collection <ClientExtension>       clientExtensions = null;
            string orgRawXml = null;

            OrgExtensionTable.RequestData requestDataSave = new OrgExtensionTable.RequestData();
            requestData = requestDataSave;
            OrgExtensionTable.ExecuteWebServicesAction(delegate
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                ExchangeService exchangeService = OrgExtensionTable.CreateExchangeServiceDelegate(domain, requestDataSave);
                if (exchangeService == null)
                {
                    return;
                }
                if (OrgExtensionTable.GetClientExtensionTimeoutIsAllowed())
                {
                    exchangeService.Timeout = 30000;
                }
                requestDataSave.CreateExchangeServiceTime   = stopwatch.ElapsedMilliseconds;
                GetClientExtensionResponse clientExtension2 = exchangeService.GetClientExtension(requestedExtensionIds, shouldReturnEnabledOnly, isUserScope, userId, userEnabledExtensionIds, userDisabledExtensionIds, isDebug);
                stopwatch.Stop();
                requestDataSave.GetClientExtensionTime = stopwatch.ElapsedMilliseconds - requestDataSave.CreateExchangeServiceTime;
                requestDataSave.ExchangeServiceUri     = exchangeService.Url;
                string text;
                if (exchangeService.HttpResponseHeaders.TryGetValue("request-id", out text))
                {
                    requestDataSave.EwsRequestId = text.Replace("-", string.Empty);
                }
                else
                {
                    requestDataSave.EwsRequestId = "NotFound";
                }
                clientExtensions = clientExtension2.ClientExtensions;
                if (isDebug && !string.IsNullOrWhiteSpace(clientExtension2.RawMasterTableXml))
                {
                    try
                    {
                        byte[] bytes = Convert.FromBase64String(clientExtension2.RawMasterTableXml);
                        orgRawXml    = Encoding.UTF8.GetString(bytes);
                    }
                    catch (FormatException innerException)
                    {
                        throw new OwaExtensionOperationException(innerException);
                    }
                    catch (ArgumentException innerException2)
                    {
                        throw new OwaExtensionOperationException(innerException2);
                    }
                }
            });
            if (clientExtensions != null)
            {
                foreach (ClientExtension clientExtension in clientExtensions)
                {
                    try
                    {
                        ExtensionData extensionData = ExtensionData.CreateFromClientExtension(clientExtension);
                        if (!retrieveOnly1_0 || !(extensionData.SchemaVersion != SchemaConstants.SchemaVersion1_0))
                        {
                            ExtensionData extensionData2;
                            if (!dictionary.TryGetValue(extensionData.ExtensionId, out extensionData2) || !(extensionData.SchemaVersion < extensionData2.SchemaVersion))
                            {
                                dictionary[ExtensionDataHelper.FormatExtensionId(extensionData.ExtensionId)] = extensionData;
                            }
                        }
                    }
                    catch (OwaExtensionOperationException ex)
                    {
                        OrgExtensionTable.Tracer.TraceError <OwaExtensionOperationException>(0L, "skipping an org extension because it cannot be parsed. Exception: {0}", ex);
                        ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrgExtensionParsingFailed, null, new object[]
                        {
                            "ProcessOrgExtensions",
                            ExtensionDiagnostics.GetLoggedExceptionString(ex)
                        });
                    }
                }
            }
            orgMasterTableRawXml = orgRawXml;
            return(dictionary);
        }
Ejemplo n.º 7
0
 // Token: 0x06000B59 RID: 2905 RVA: 0x0002E26C File Offset: 0x0002C46C
 private static void UseGetClientExtensionTimeoutRegistryKeyChangeHandler(object sender, EventArrivedEventArgs e)
 {
     OrgExtensionTable.Tracer.TraceDebug(0L, "Registry Change Event Occurred. Get UseGetClientExtensionTimeout Key.");
     OrgExtensionTable.UseGetClientExtensionTimeout = new bool?(OrgExtensionTable.UseGetClientExtensionTimeoutValueFromRegistry());
 }