예제 #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();
        }
예제 #2
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);
                }
            }
        }
 public static void DeleteFromMetabase(string webSiteRoot, string virtualDirectoryName, ICollection childVirtualDirectoryNames)
 {
     if (childVirtualDirectoryNames != null)
     {
         string text = string.Format("{0}/{1}", webSiteRoot, virtualDirectoryName);
         foreach (object obj in childVirtualDirectoryNames)
         {
             string text2 = (string)obj;
             if (IisUtility.WebDirObjectExists(text, text2))
             {
                 DeleteVirtualDirectory deleteVirtualDirectory = new DeleteVirtualDirectory();
                 deleteVirtualDirectory.Name   = text2;
                 deleteVirtualDirectory.Parent = text;
                 deleteVirtualDirectory.Initialize();
                 deleteVirtualDirectory.Execute();
             }
         }
     }
     if (IisUtility.Exists(webSiteRoot, virtualDirectoryName, "IIsWebVirtualDir"))
     {
         DeleteVirtualDirectory deleteVirtualDirectory2 = new DeleteVirtualDirectory();
         deleteVirtualDirectory2.Name   = virtualDirectoryName;
         deleteVirtualDirectory2.Parent = webSiteRoot;
         deleteVirtualDirectory2.Initialize();
         deleteVirtualDirectory2.Execute();
     }
 }
        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();
        }
예제 #5
0
        protected override void DeleteFromMetabase()
        {
            base.DeleteFromMetabase();
            string webSiteRoot        = IisUtility.GetWebSiteRoot(this.DataObject.MetabasePath);
            IList  createdLegacyVDirs = OwaVirtualDirectoryHelper.CreatedLegacyVDirs;

            if (createdLegacyVDirs != null)
            {
                foreach (object obj in createdLegacyVDirs)
                {
                    string name = (string)obj;
                    if (IisUtility.WebDirObjectExists(webSiteRoot, name))
                    {
                        IisUtility.DeleteWebDirObject(webSiteRoot, name);
                    }
                }
                OwaVirtualDirectoryHelper.CreatedLegacyVDirs.Clear();
            }
        }
예제 #6
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();
        }