Esempio n. 1
0
        internal static void CreateOmaVDir(string metabasePath, VirtualDirectoryRole role)
        {
            MetabasePropertyTypes.AppPoolIdentityType appPoolIdentityType = MetabasePropertyTypes.AppPoolIdentityType.LocalSystem;
            if (IisUtility.WebDirObjectExists(metabasePath, "oma"))
            {
                string hostName        = IisUtility.GetHostName(metabasePath);
                string appPoolRootPath = IisUtility.GetAppPoolRootPath(hostName);
                using (DirectoryEntry directoryEntry = IisUtility.FindWebObject(appPoolRootPath, "MSExchangeOWAAppPool", "IIsApplicationPool"))
                {
                    IisUtility.SetProperty(directoryEntry, "AppPoolIdentityType", appPoolIdentityType, true);
                    directoryEntry.CommitChanges();
                }
                return;
            }
            CreateVirtualDirectory createVirtualDirectory = new CreateVirtualDirectory();

            createVirtualDirectory.Name      = "oma";
            createVirtualDirectory.Parent    = metabasePath;
            createVirtualDirectory.LocalPath = OwaVirtualDirectoryHelper.OwaCafePath;
            createVirtualDirectory.CustomizedVDirProperties   = OwaVirtualDirectoryHelper.GetOmaVDirProperties(role);
            createVirtualDirectory.ApplicationPool            = "MSExchangeOWAAppPool";
            createVirtualDirectory.AppPoolIdentityType        = appPoolIdentityType;
            createVirtualDirectory.AppPoolManagedPipelineMode = MetabasePropertyTypes.ManagedPipelineMode.Integrated;
            createVirtualDirectory.AppPoolQueueLength         = 10;
            createVirtualDirectory.Initialize();
            createVirtualDirectory.Execute();
        }
Esempio n. 2
0
 protected override void InternalBeginProcessing()
 {
     TaskLogger.LogEnter();
     base.InternalBeginProcessing();
     this.owaVersion       = OwaVirtualDirectoryHelper.GetOwaAssemblyVersion();
     this.owaCurrentFolder = Path.Combine(OwaVirtualDirectoryHelper.OwaPath, "Current");
     this.owaVersionFolder = Path.Combine(OwaVirtualDirectoryHelper.OwaPath, this.owaVersion);
     try
     {
         UpdateOwaVirtualDirectory.XCopyEntireFoldersWithOverwrite(this.owaCurrentFolder, this.owaVersionFolder, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
     }
     catch (UnauthorizedAccessException ex)
     {
         throw new CopyDirectoriesException(this.owaCurrentFolder, this.owaVersionFolder, ex.Message, ex);
     }
     catch (IOException ex2)
     {
         throw new CopyDirectoriesException(this.owaCurrentFolder, this.owaVersionFolder, ex2.Message, ex2);
     }
     catch (NotSupportedException ex3)
     {
         throw new CopyDirectoriesException(this.owaCurrentFolder, this.owaVersionFolder, ex3.Message, ex3);
     }
     this.configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(this.DomainController, false, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromRootOrgScopeSet(), 131, "InternalBeginProcessing", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\VirtualDirectoryTasks\\UpdateOWAVirtualDirectory.cs");
     TaskLogger.LogExit();
 }
Esempio n. 3
0
        internal static void CreateLegacyVDirs(string metabasePath, bool deleteObjectIfExists)
        {
            string webSiteRoot = IisUtility.GetWebSiteRoot(metabasePath);
            IList  legacyVirtualDirectories = OwaVirtualDirectoryHelper.GetLegacyVirtualDirectories();

            if (legacyVirtualDirectories != null)
            {
                ArrayList arrayList = new ArrayList();
                arrayList.Add(new MetabaseProperty("HttpRedirect", "/owa"));
                string localPath = Path.Combine(ConfigurationContext.Setup.InstallPath, "ClientAccess\\owa");
                OwaVirtualDirectoryHelper.CreatedLegacyVDirs.Clear();
                foreach (object obj in legacyVirtualDirectories)
                {
                    string text = (string)obj;
                    if (deleteObjectIfExists && IisUtility.WebDirObjectExists(webSiteRoot, text))
                    {
                        IisUtility.DeleteWebDirObject(webSiteRoot, text);
                    }
                    CreateVirtualDirectory createVirtualDirectory = new CreateVirtualDirectory();
                    createVirtualDirectory.Name      = text;
                    createVirtualDirectory.Parent    = webSiteRoot;
                    createVirtualDirectory.LocalPath = localPath;
                    createVirtualDirectory.CustomizedVDirProperties = arrayList;
                    createVirtualDirectory.Initialize();
                    createVirtualDirectory.Execute();
                    OwaVirtualDirectoryHelper.CreatedLegacyVDirs.Add(text);
                }
            }
        }
Esempio n. 4
0
        internal static void AddVersionVDir(ListDictionary childVDirs)
        {
            ArrayList versionVDirProperties = OwaVirtualDirectoryHelper.GetVersionVDirProperties();
            string    owaAssemblyVersion    = OwaVirtualDirectoryHelper.GetOwaAssemblyVersion();

            childVDirs.Add(owaAssemblyVersion, versionVDirProperties);
        }
Esempio n. 5
0
        private static List <MetabaseProperty> GetOmaVDirProperties(VirtualDirectoryRole role)
        {
            List <MetabaseProperty> list = new List <MetabaseProperty>();

            list.Add(new MetabaseProperty("Path", OwaVirtualDirectoryHelper.OwaCafePath));
            list.Add(new MetabaseProperty("AuthFlags", MetabasePropertyTypes.AuthFlags.Basic));
            list.Add(new MetabaseProperty("AccessFlags", MetabasePropertyTypes.AccessFlags.Read | MetabasePropertyTypes.AccessFlags.Script));
            list.Add(new MetabaseProperty("AppIsolated", MetabasePropertyTypes.AppIsolated.Pooled));
            if (!OwaVirtualDirectoryHelper.IsDataCenterCafe(role))
            {
                list.Add(new MetabaseProperty("AccessSSLFlags", MetabasePropertyTypes.AccessSSLFlags.AccessSSL | MetabasePropertyTypes.AccessSSLFlags.AccessSSL128));
            }
            return(list);
        }
Esempio n. 6
0
        private static List <MetabaseProperty> GetOwaCalendarVDirProperties(VirtualDirectoryRole role)
        {
            List <MetabaseProperty> list = new List <MetabaseProperty>();

            list.Add(new MetabaseProperty("Path", (role == VirtualDirectoryRole.Mailbox) ? OwaVirtualDirectoryHelper.OwaPath : OwaVirtualDirectoryHelper.OwaCafePath));
            list.Add(new MetabaseProperty("AuthFlags", MetabasePropertyTypes.AuthFlags.Anonymous));
            list.Add(new MetabaseProperty("AccessFlags", MetabasePropertyTypes.AccessFlags.Read | MetabasePropertyTypes.AccessFlags.Script));
            list.Add(new MetabaseProperty("AppIsolated", MetabasePropertyTypes.AppIsolated.Pooled));
            if (!OwaVirtualDirectoryHelper.IsDataCenterCafe(role))
            {
                list.Add(new MetabaseProperty("AccessSSLFlags", MetabasePropertyTypes.AccessSSLFlags.None));
            }
            return(list);
        }
        protected override void DeleteFromMetabase()
        {
            string webSiteRoot = IisUtility.GetWebSiteRoot(base.DataObject.MetabasePath);
            IList  legacyVirtualDirectories = OwaVirtualDirectoryHelper.GetLegacyVirtualDirectories();

            if (legacyVirtualDirectories != null)
            {
                foreach (object obj in legacyVirtualDirectories)
                {
                    string name = (string)obj;
                    if (IisUtility.WebDirObjectExists(webSiteRoot, name))
                    {
                        IisUtility.DeleteWebDirObject(webSiteRoot, name);
                    }
                }
            }
            base.DeleteFromMetabase();
        }
 protected override void PreDeleteFromMetabase()
 {
     if (!DirectoryEntry.Exists(base.DataObject.MetabasePath))
     {
         return;
     }
     using (DirectoryEntry directoryEntry = IisUtility.CreateIISDirectoryEntry(base.DataObject.MetabasePath, new Task.TaskErrorLoggingReThrowDelegate(this.WriteError), this.Identity))
     {
         PropertyValueCollection propertyValueCollection = directoryEntry.Properties["ScriptMaps"];
         foreach (object obj in propertyValueCollection)
         {
             string   text  = (string)obj;
             string[] array = text.Split(new char[]
             {
                 ','
             });
             if (array.Length >= 2)
             {
                 string fileName = Path.GetFileName(array[1]);
                 if (string.Compare(fileName, "davex.dll", true, CultureInfo.InvariantCulture) == 0 || string.Compare(fileName, "exprox.dll", true, CultureInfo.InvariantCulture) == 0)
                 {
                     this.scriptMapPhysicalPath = array[1];
                     break;
                 }
             }
         }
         try
         {
             string parent = null;
             string text2  = null;
             string name   = null;
             IisUtility.ParseApplicationRootPath(directoryEntry.Path, ref parent, ref text2, ref name);
             if (IisUtility.Exists(parent, name, "IIsWebVirtualDir"))
             {
                 OwaVirtualDirectoryHelper.DisableIsapiFilter(base.DataObject);
             }
         }
         catch (Exception)
         {
             this.WriteWarning(Strings.OwaMetabaseIsapiUninstallFailure);
             throw;
         }
     }
 }
Esempio n. 9
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.InternalProcessRecord();
            ServerIdParameter serverIdParameter = new ServerIdParameter();
            Server            server            = (Server)base.GetDataObject <Server>(serverIdParameter, base.DataSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));

            if (!server.IsClientAccessServer && !server.IsCafeServer)
            {
                base.ThrowTerminatingError(server.GetServerRoleError(ServerRole.ClientAccess), ErrorCategory.InvalidOperation, server);
            }
            using (ServerManager serverManager = new ServerManager())
            {
                ApplicationPool applicationPool = serverManager.ApplicationPools["MSExchangeOWAAppPool"];
                if (applicationPool == null)
                {
                    base.ThrowTerminatingError(new ADNoSuchObjectException(Strings.ErrorOWAVdirAppPoolNotExist), ErrorCategory.ObjectNotFound, serverManager.ApplicationPools);
                }
                applicationPool.ManagedPipelineMode = 0;
                serverManager.CommitChanges();
            }
            QueryFilter filter = new ComparisonFilter(ComparisonOperator.NotEqual, ADOwaVirtualDirectorySchema.OwaVersion, OwaVersions.Exchange2003or2000);

            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADOwaVirtualDirectory), filter, server.Identity, true));
            IConfigDataProvider dataSession = base.DataSession;
            IEnumerable <ADOwaVirtualDirectory> enumerable = dataSession.FindPaged <ADOwaVirtualDirectory>(filter, server.Identity, true, null, 0);

            foreach (ADOwaVirtualDirectory adowaVirtualDirectory in enumerable)
            {
                if (adowaVirtualDirectory.WebSite.Equals("Exchange Back End", StringComparison.OrdinalIgnoreCase))
                {
                    string metabasePath = adowaVirtualDirectory.MetabasePath;
                    try
                    {
                        base.WriteVerbose(Strings.VerboseConnectingIISVDir(metabasePath));
                        using (IisUtility.CreateIISDirectoryEntry(metabasePath))
                        {
                            if (!DirectoryEntry.Exists(metabasePath))
                            {
                                this.WriteWarning(Strings.OwaAdOrphanFound(adowaVirtualDirectory.Identity.ToString()));
                                continue;
                            }
                            if (!IisUtility.WebDirObjectExists(metabasePath, this.owaVersion))
                            {
                                base.WriteVerbose(Strings.VerboseCreatingChildVDir(this.owaVersion, metabasePath));
                                CreateVirtualDirectory createVirtualDirectory = new CreateVirtualDirectory();
                                createVirtualDirectory.Name   = this.owaVersion;
                                createVirtualDirectory.Parent = metabasePath;
                                createVirtualDirectory.CustomizedVDirProperties = OwaVirtualDirectoryHelper.GetVersionVDirProperties();
                                createVirtualDirectory.LocalPath = (string)IisUtility.GetIisPropertyValue("Path", createVirtualDirectory.CustomizedVDirProperties);
                                createVirtualDirectory.Initialize();
                                createVirtualDirectory.Execute();
                            }
                        }
                        OwaVirtualDirectoryHelper.CreateLegacyVDirs(metabasePath, true);
                        OwaVirtualDirectoryHelper.CreateOwaCalendarVDir(metabasePath, VirtualDirectoryRole.Mailbox);
                        if (ExchangeServiceVDirHelper.IsBackEndVirtualDirectory(adowaVirtualDirectory))
                        {
                            WebAppVirtualDirectoryHelper.UpdateMetabase(adowaVirtualDirectory, metabasePath, true);
                        }
                    }
                    catch (COMException ex)
                    {
                        base.WriteError(new IISGeneralCOMException(ex.Message, ex.ErrorCode, ex), ErrorCategory.InvalidOperation, null);
                    }
                    if (adowaVirtualDirectory.ExchangeVersion.IsOlderThan(adowaVirtualDirectory.MaximumSupportedExchangeObjectVersion))
                    {
                        try
                        {
                            adowaVirtualDirectory.SetExchangeVersion(adowaVirtualDirectory.MaximumSupportedExchangeObjectVersion);
                            base.DataSession.Save(adowaVirtualDirectory);
                        }
                        catch (DataSourceTransientException exception)
                        {
                            base.WriteError(exception, ErrorCategory.WriteError, null);
                        }
                    }
                }
            }
            TaskLogger.LogExit();
        }
Esempio n. 10
0
        public static void CopyDavVdirsToMetabase(string domainController, string exchangeServerName, string metabaseServerName)
        {
            ADSessionSettings             sessionSettings = ADSessionSettings.FromRootOrgScopeSet();
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, null, sessionSettings, 154, "CopyDavVdirsToMetabase", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\VirtualDirectoryTasks\\OWAVirtualDirectoryHelper.cs");
            Server server = topologyConfigurationSession.FindServerByName(exchangeServerName);
            IConfigDataProvider configDataProvider         = topologyConfigurationSession;
            IEnumerable <ADOwaVirtualDirectory> enumerable = configDataProvider.FindPaged <ADOwaVirtualDirectory>(null, server.Id, true, null, 0);

            OwaVirtualDirectoryHelper.SetWebSvcExtRestrictionList(metabaseServerName);
            foreach (ADOwaVirtualDirectory adowaVirtualDirectory in enumerable)
            {
                if (!adowaVirtualDirectory.IsExchange2007OrLater)
                {
                    string[] array = adowaVirtualDirectory.MetabasePath.Split(new char[]
                    {
                        '/'
                    });
                    if (array.Length == 7)
                    {
                        array[2] = metabaseServerName;
                        MultiValuedProperty <AuthenticationMethod> internalAuthenticationMethods = adowaVirtualDirectory.InternalAuthenticationMethods;
                        adowaVirtualDirectory.WindowsAuthentication = true;
                        string appPoolRootPath = IisUtility.GetAppPoolRootPath(metabaseServerName);
                        string text            = "MSExchangeOWAAppPool";
                        if (!IisUtility.Exists(appPoolRootPath, text, "IIsApplicationPool"))
                        {
                            using (DirectoryEntry directoryEntry = IisUtility.CreateApplicationPool(metabaseServerName, text))
                            {
                                IisUtility.SetProperty(directoryEntry, "AppPoolIdentityType", 0, true);
                                directoryEntry.CommitChanges();
                            }
                        }
                        if (!IisUtility.Exists(string.Join("/", array)))
                        {
                            DirectoryEntry directoryEntry2 = IisUtility.CreateWebDirObject(string.Join("/", array, 0, 6), adowaVirtualDirectory.FolderPathname, array[6]);
                            ArrayList      arrayList       = new ArrayList();
                            arrayList.Add(new MetabaseProperty("LogonMethod", MetabasePropertyTypes.LogonMethod.ClearTextLogon));
                            arrayList.Add(new MetabaseProperty("AccessFlags", MetabasePropertyTypes.AccessFlags.Read | MetabasePropertyTypes.AccessFlags.Write | MetabasePropertyTypes.AccessFlags.Source | MetabasePropertyTypes.AccessFlags.Script));
                            arrayList.Add(new MetabaseProperty("DirBrowseFlags", (MetabasePropertyTypes.DirBrowseFlags) 3221225534U));
                            arrayList.Add(new MetabaseProperty("ScriptMaps", OwaVirtualDirectoryHelper.GetDavScriptMaps(), true));
                            if (adowaVirtualDirectory.VirtualDirectoryType == VirtualDirectoryTypes.Exchweb)
                            {
                                arrayList.Add(new MetabaseProperty("HttpExpires", "D, 0x278d00"));
                            }
                            if (adowaVirtualDirectory.DefaultDomain.Length > 0)
                            {
                                arrayList.Add(new MetabaseProperty("DefaultLogonDomain", adowaVirtualDirectory.DefaultDomain, true));
                            }
                            OwaIsapiFilter.DisableFba(directoryEntry2);
                            uint num = 0U;
                            using (MultiValuedProperty <AuthenticationMethod> .Enumerator enumerator2 = adowaVirtualDirectory.InternalAuthenticationMethods.GetEnumerator())
                            {
                                while (enumerator2.MoveNext())
                                {
                                    switch (enumerator2.Current)
                                    {
                                    case AuthenticationMethod.Basic:
                                        num |= 2U;
                                        break;

                                    case AuthenticationMethod.Digest:
                                        num |= 16U;
                                        break;

                                    case AuthenticationMethod.Ntlm:
                                        num |= 4U;
                                        break;

                                    case AuthenticationMethod.Fba:
                                        OwaIsapiFilter.EnableFba(directoryEntry2);
                                        break;
                                    }
                                }
                            }
                            arrayList.Add(new MetabaseProperty("AuthFlags", num, true));
                            IisUtility.SetProperties(directoryEntry2, arrayList);
                            IisUtility.AssignApplicationPool(directoryEntry2, text);
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        protected override void InternalProcessMetabase()
        {
            OwaVirtualDirectoryHelper.CreateOwaCalendarVDir(this.DataObject.MetabasePath, base.Role);
            if (base.Role == VirtualDirectoryRole.Mailbox)
            {
                OwaVirtualDirectoryHelper.CreateLegacyVDirs(this.DataObject.MetabasePath, false);
                try
                {
                    OwaVirtualDirectoryHelper.EnableIsapiFilter(this.DataObject, false);
                    goto IL_EB;
                }
                catch (Exception ex)
                {
                    TaskLogger.Trace("Exception occurred in EnableIsapiFilter(): {0}", new object[]
                    {
                        ex.Message
                    });
                    this.WriteWarning(Strings.OwaMetabaseIsapiInstallFailure);
                    throw;
                }
            }
            if (!Datacenter.IsMultiTenancyEnabled())
            {
                OwaVirtualDirectoryHelper.CreateOwaIntegratedVDir(this.DataObject.MetabasePath, base.Role);
                this.DataObject.IntegratedFeaturesEnabled = new bool?(true);
            }
            OwaVirtualDirectoryHelper.CreateOmaVDir(this.DataObject.MetabasePath, base.Role);
            try
            {
                OwaVirtualDirectoryHelper.EnableIsapiFilter(this.DataObject, true);
            }
            catch (Exception ex2)
            {
                TaskLogger.Trace("Exception occurred in EnableIsapiFilterForCafe(): {0}", new object[]
                {
                    ex2.Message
                });
                this.WriteWarning(Strings.OwaMetabaseIsapiInstallFailure);
                throw;
            }
            try
            {
IL_EB:
                WebAppVirtualDirectoryHelper.UpdateMetabase(this.DataObject, this.DataObject.MetabasePath, base.Role == VirtualDirectoryRole.Mailbox);
            }
            catch (Exception ex3)
            {
                TaskLogger.Trace("Exception occurred in UpdateMetabase(): {0}", new object[]
                {
                    ex3.Message
                });
                this.WriteWarning(Strings.OwaMetabaseGetPropertiesFailure);
                throw;
            }
            if (base.Role == VirtualDirectoryRole.Mailbox && Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
            {
                try
                {
                    Gzip.SetIisGzipMimeTypes();
                }
                catch (Exception ex4)
                {
                    TaskLogger.Trace("Exception occurred in SetIisGzipMimeTypes(): {0}", new object[]
                    {
                        ex4.Message
                    });
                    this.WriteWarning(Strings.SetIISGzipMimeTypesFailure);
                    throw;
                }
            }
        }