コード例 #1
0
        private void SetConstructor()
        {
            if (!this.CheckApplicationExists())
            {
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "SetConstructor on Component: {0}", this.ComponentName));
            COMAdminCatalogCollection appCollection = GetApplications();

            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    COMAdmin.ICatalogCollection componentCollection = (COMAdmin.ICatalogCollection)appCollection.GetCollection("Components", app.Key);
                    componentCollection.Populate();
                    foreach (COMAdmin.COMAdminCatalogObject component in componentCollection)
                    {
                        if (component.Name.ToString() == this.ComponentName)
                        {
                            component.set_Value("ConstructorString", this.ConstructorString ?? string.Empty);
                            component.set_Value("ConstructionEnabled", !string.IsNullOrEmpty(this.ConstructorString));
                            componentCollection.SaveChanges();
                            break;
                        }
                    }

                    break;
                }
            }

            appCollection.SaveChanges();
        }
コード例 #2
0
        private void UpdateApplication()
        {
            if (!this.CheckApplicationExists())
            {
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Updating: {0}", this.ApplicationName));
            COMAdminCatalogCollection appCollection = GetApplications();

            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    if (!string.IsNullOrEmpty(this.Identity))
                    {
                        app.set_Value("Identity", this.Identity);
                        app.set_Value("Password", this.UserPassword ?? string.Empty);
                    }

                    app.set_Value("Activation", this.activation.ToString());
                    appCollection.SaveChanges();
                    break;
                }
            }
        }
コード例 #3
0
        private void AddNativeComponent()
        {
            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Adding Native Component: {0} to Application: {1}", this.Path, this.ApplicationName));
            if (System.IO.File.Exists(this.Path) == false)
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Path not found: {0}", this.Path));
                return;
            }

            COMAdminCatalogCollection appCollection = GetApplications();
            bool appExists = false;

            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    appExists = true;
                    var cat = new COMAdminCatalog();
                    cat.InstallComponent(app.Key.ToString(), this.Path, string.Empty, string.Empty);
                    break;
                }
            }

            if (!appExists)
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Application not found: {0}", this.ApplicationName));
            }
        }
コード例 #4
0
        private void SetAccessIisIntrinsicProperties()
        {
            if (!this.CheckApplicationExists())
            {
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "SetAccessIisIntrinsicProperties on Component: {0}", this.ComponentName));
            COMAdminCatalogCollection appCollection = GetApplications();

            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    COMAdmin.ICatalogCollection componentCollection = (COMAdmin.ICatalogCollection)appCollection.GetCollection("Components", app.Key);
                    componentCollection.Populate();
                    foreach (COMAdmin.COMAdminCatalogObject component in componentCollection)
                    {
                        if (component.Name.ToString() == this.ComponentName)
                        {
                            component.set_Value("IISIntrinsics", this.AllowIntrinsicIisProperties);
                            componentCollection.SaveChanges();
                            break;
                        }
                    }

                    break;
                }
            }

            appCollection.SaveChanges();
        }
コード例 #5
0
        private void CreateApplication()
        {
            if (this.CheckApplicationExists())
            {
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Creating Application: {0}", this.ApplicationName));

            COMAdminCatalogCollection appCollection = GetApplications();
            COMAdminCatalogObject     app           = (COMAdminCatalogObject)appCollection.Add();

            app.set_Value("Name", this.ApplicationName);

            if (!string.IsNullOrEmpty(this.Identity))
            {
                app.set_Value("Identity", this.Identity);
                app.set_Value("Password", this.UserPassword ?? string.Empty);
            }

            app.set_Value("Activation", this.activation.ToString());
            app.set_Value("ApplicationAccessChecksEnabled", this.EnforceAccessChecks);

            appCollection.SaveChanges();
        }
コード例 #6
0
 public COMAdminCatalogCollection GetCatalogCollection()
 {
     if (oAppCollection == null)
     {
         oAppCollection = (COMAdminCatalogCollection)GetCatalog().GetCollection("Applications");
         oAppCollection.Populate();
     }
     return(oAppCollection);
 }
コード例 #7
0
        /// <summary>
        /// Configures a COM+ application associated with the specified IIS virtual directory
        /// to run under the interactive user account instead of a system account.
        /// </summary>
        /// <param name="name">The virtual directory name</param>
        /// <returns>True if successful, otherwise false</returns>
        public static bool SetVirtualDirectoryHostIdentity(string name)
        {
            try
            {
                // Set application pool identity on IIS 6.0
                if (IsOldIsolationMode())
                {
                    // Instantiate the admin object
                    Type     type    = Type.GetTypeFromProgID("COMAdmin.COMAdminCatalog");
                    object   catalog = Activator.CreateInstance(type);
                    object[] args    = new object[] { "Applications" };

                    // Get the COM+ applications collection
                    COMAdminCatalogCollection apps = (COMAdminCatalogCollection)type.InvokeMember("GetCollection",
                                                                                                  BindingFlags.InvokeMethod, null, catalog, args);
                    apps.Populate();

                    string appName = "//root/" + name.ToLower() + "}";

                    // Look for our COM+ application
                    foreach (COMAdminCatalogObject app in apps)
                    {
                        if (app.Name.ToString().ToLower().EndsWith(appName))
                        {
                            // Set logon to interactive user
                            app.set_Value("Identity", "Interactive User");
                            app.set_Value("Password", "");
                            apps.SaveChanges();
                        }
                    }
                }
                else
                {
                    // Get pool object
                    DirectoryEntry pool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools/" + name);

                    // Set properties
                    pool.Properties["AppPoolIdentityType"][0] = 3;
                    pool.Properties["WAMUserName"][0]         = "Interactive User";
                    pool.Properties["WAMUserPass"][0]         = "";

                    // Save changes
                    pool.CommitChanges();
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        private bool CheckApplicationExists()
        {
            this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Checking whether Application exists: {0}", this.ApplicationName));
            COMAdminCatalogCollection appCollection = GetApplications();

            if (appCollection.Cast <COMAdminCatalogObject>().Any(app => app.Name.ToString() == this.ApplicationName))
            {
                this.Exists = true;
                return(true);
            }

            return(false);
        }
コード例 #9
0
 static void Main(string[] args)
 {
     COMAdminCatalog catalog = new COMAdminCatalog();
     COMAdminCatalogCollection applications = catalog.GetCollection("Applications");
     applications.Populate();
     for (int i = 0; i < applications.Count; i++)
     {
         COMAdminCatalogObject application = applications.Item[i];
         Console.WriteLine(application.Name);
         Console.WriteLine(application.Value["Identity"]);
     }
     Console.WriteLine("Press any key to continue...");
     Console.ReadKey();
 }
コード例 #10
0
        public ArrayList GetAppItemsList()
        {
            COMAdminCatalogCollection oList = GetAppItems();
            ArrayList oRes = new ArrayList();

            if (oList != null)
            {
                foreach (COMAdminCatalogObject obj in oList)
                {
                    oRes.Add(obj.Name);
                }
            }
            else
            {
                Common.Log.Write(this, "Can't retrieve remote COM list");
            }
            return(oRes);
        }
コード例 #11
0
        private void DeleteApplication()
        {
            if (!this.CheckApplicationExists())
            {
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Deleting Application: {0}", this.ApplicationName));

            COMAdminCatalogCollection appCollection = GetApplications();
            int i = 0;

            foreach (COMAdmin.COMAdminCatalogObject cat in appCollection)
            {
                if (cat.Name.ToString() == this.ApplicationName)
                {
                    appCollection.Remove(i);
                    appCollection.SaveChanges();
                    break;
                }

                i++;
            }
        }
コード例 #12
0
 public COMAdminCatalogCollection GetAppItems()
 {
     if (oCollection == null)
     {
         try
         {
             COMAdminCatalogCollection appColl = GetCatalogCollection();
             foreach (COMAdminCatalogObject app in appColl)
             {
                 if (app.Name.ToString().ToLower() == "")                         //Config.ComApplication.ToLower() )
                 {
                     oCollection = (COMAdminCatalogCollection)appColl.GetCollection("Components", app.Key);
                     oCollection.Populate();
                     break;
                 }
             }
         }
         catch (Exception oEx)
         {
             Common.Log.Write(this, oEx);
         }
     }
     return(oCollection);
 }
コード例 #13
0
        static private void performccreatecomappop(appoptions apopts)
        {
            try
            {
                bool bins   = ((apopts & appoptions.install) != 0);
                bool bunins = ((apopts & appoptions.uninstall) != 0);
                bool bstart = ((apopts & appoptions.start) != 0);
                bool bstop  = ((apopts & appoptions.stop) != 0);

                COMAdminCatalog           catalog      = new COMAdminCatalog();
                COMAdminCatalogCollection applications = catalog.GetCollection("Applications") as COMAdminCatalogCollection;
                applications.Populate();
                if (bins || bunins || bstart || bstop || breg)
                {
                    for (int i = 0; i < applications.Count; ++i)
                    {
                        COMAdminCatalogObject app = applications.get_Item(i) as COMAdminCatalogObject;
                        if (app.Name.ToString() == appname)
                        {
                            if (bstart)
                            {
                                catalog.StartApplication(appname);
                                return;
                            }

                            catalog.ShutdownApplication(appname);
                            if (bins || bunins)
                            {
                                applications.Remove(i);
                                applications.SaveChanges();
                            }
                            break;
                        }
                    }


                    if (bins)
                    {
                        applications.Populate();

                        COMAdminCatalogObject application = applications.Add() as COMAdminCatalogObject;
                        application.Value["ID"]         = Guid.NewGuid().ToString("B");
                        application.Value["Name"]       = appname;
                        application.Value["RunForever"] = brunforever;
                        applications.SaveChanges();

                        if (System.Environment.OSVersion.Version.Major > 5)
                        {
                            COMAdminCatalogCollection roles = (COMAdminCatalogCollection)applications.GetCollection("Roles", application.Key);
                            roles.Populate();
                            COMAdminCatalogObject role = roles.Add() as COMAdminCatalogObject;
                            role.Value["Name"] = "DefaultRole";
                            roles.SaveChanges();
                            COMAdminCatalogCollection users = (COMAdminCatalogCollection)roles.GetCollection("UsersInRole", role.Key);
                            users.Populate();
                            COMAdminCatalogObject user = users.Add() as COMAdminCatalogObject;
                            user.Value["User"] = "******";
                            users.SaveChanges();
                        }
                        applications.SaveChanges();
                    }
                }

                if (breg || bunreg)
                {
                    if (data.Count == 0)
                    {
                        if (filename == "")
                        {
                            ShowSyntax();
                        }

                        List <KeyValuePair <string, string> > progclsidlst = new List <KeyValuePair <string, string> >();
                        if (filename.ToLower().IndexOf(".wsc") != -1)
                        {
                            progclsidlst = CodeGenHelper.GetclsidsfromWSC(filename);
                        }
                        else
                        {
                            progclsidlst = CodeGenHelper.GetclsidsfromAssembly(filename);
                            if (progclsidlst.Count == 0)
                            {
                                progclsidlst = CodeGenHelper.GetclsidsfromTLB(filename);
                            }
                        }

                        foreach (var kv in progclsidlst)
                        {
                            data.Add(kv.Key);
                        }
                    }

                    foreach (string d in data)
                    {
                        if (breg)
                        {
                            catalog.ImportComponent(appname, d);
                        }
                    }
                }
                else if (bgac || bungac)
                {
                    if (bgac)
                    {
                        catalog.InstallComponent(appname, filename, "", "");
                    }
                }

                applications.SaveChanges();
            }
            catch
            {
            }
        }