예제 #1
0
        }// CreateChildren

        internal CSinglePermissionSet AddPermissionSet(NamedPermissionSet nps)
        {
            // Make sure we have a unique permission set name
            int    nCounter = 1;
            String sBase    = nps.Name;

            while (Security.isPermissionSetNameUsed(m_pl, nps.Name))
            {
                if (nCounter == 1)
                {
                    nps.Name = String.Format(CResourceStore.GetString("CSinglePermissionSet:NewDupPermissionSet"), sBase);
                }
                else
                {
                    nps.Name = String.Format(CResourceStore.GetString("CSinglePermissionSet:NumNewDupPermissionSet"), nCounter.ToString(), sBase);
                }
                nCounter++;
            }

            // Now add the new permission set
            m_pl.AddNamedPermissionSet(nps);
            CNode node    = new CSinglePermissionSet(nps, m_pl, ReadOnly);
            int   nCookie = CNodeManager.AddNode(ref node);

            AddChild(nCookie);
            InsertSpecificChild(nCookie);
            // Return the node we created
            return((CSinglePermissionSet)node);
        } // AddPermissionSet
예제 #2
0
        }// GetRootCodeGroupNode

        //-------------------------------------------------
        // CreateChildren
        //
        // This function will create all the codegroup nodes
        // for this policy level
        //-------------------------------------------------
        internal override void CreateChildren()
        {
            SuperCodeGroupArrayList al;

            Security.ListifyCodeGroup(m_pl.RootCodeGroup.Copy(), null, out al);


            // Now run through all the others and put them in too
            for (int i = 0; i < al.Count; i++)
            {
                CNode parentNode;
                // If this is the root codegroup, it has a different parent
                if (i == 0)
                {
                    parentNode = this;
                }
                else
                {
                    parentNode = (CNode)(al[al[i].nParent].o);
                }

                CodeGroup cg        = al[i].cg;
                CNode     childNode = new CSingleCodeGroup(ref m_pl, ref cg, ReadOnly);
                int       iCookie   = CNodeManager.AddNode(ref childNode);
                parentNode.AddChild(iCookie);

                // Now set this codegroup's node
                al[i].o = childNode;
            }
        } // CreateChildren
예제 #3
0
        }// CRootNode

        //-------------------------------------------------
        // CreateChildren
        //
        // This function creates the node's children, registers
        // the nodes with the node manager, and places the node's
        // cookies in it's child array
        //-------------------------------------------------
        internal override void CreateChildren()
        {
            CNode node = new CComputerNode();

            // We'll mark this as the local machine
            node.Data = 1;
            int iCookie = CNodeManager.AddNode(ref node);

            AddChild(iCookie);
        } // CreateChildren
예제 #4
0
        internal CWizard()
        {
            // Register this Wizard with the node manager
            CNode me = this;

            m_nCookie = CNodeManager.AddNode(ref me);
            // Set our Property Page Template to use that of wizards
            m_sPropPageTemplate = "IDD_WFCWRAPPERWIZARD";
            m_fFinish           = false;
            m_fBack             = false;
            m_fNext             = false;
            m_fDisabledFinish   = false;
        }// CWizard
예제 #5
0
        }// Paste

        //-------------------------------------------------
        // CreateChildren
        //
        // This function creates the node's children, registers
        // the nodes with the node manager, and places the node's
        // cookies in it's child array
        //-------------------------------------------------
        internal override void CreateChildren()
        {
            CNode node    = null;
            int   iCookie = 0;

            // Let's scrounge together a permission set enumerator
            IEnumerator permsetEnumerator = m_pl.NamedPermissionSets.GetEnumerator();

            while (permsetEnumerator.MoveNext())
            {
                NamedPermissionSet permSet = (NamedPermissionSet)permsetEnumerator.Current;
                node    = new CSinglePermissionSet(permSet, m_pl, ReadOnly);
                iCookie = CNodeManager.AddNode(ref node);
                AddChild(iCookie);
            }
        }// CreateChildren
예제 #6
0
        }// PermissionSetNode

        //-------------------------------------------------
        // CreateChildren
        //
        // This function creates the node's children, registers
        // the nodes with the node manager, and places the node's
        // cookies in it's child array
        //-------------------------------------------------
        internal override void CreateChildren()
        {
            CNode node    = null;
            int   iCookie = 0;

            node    = new CCodeGroups(ref m_pl, ReadOnly);
            iCookie = CNodeManager.AddNode(ref node);
            AddChild(iCookie);

            node    = new CPermissionSet(m_pl, ReadOnly);
            iCookie = CNodeManager.AddNode(ref node);
            AddChild(iCookie);

            node    = new CTrustedAssemblies(m_pl, ReadOnly);
            iCookie = CNodeManager.AddNode(ref node);
            AddChild(iCookie);
        } // CreateChildren
예제 #7
0
        //-------------------------------------------------
        // CData - Constructor
        //
        // The constructor is responsible for constructing
        // the nodes that will be displayed in the snapin
        //-------------------------------------------------
        public CData()
        {
            if (m_rn != null)
            {
                throw new Exception(CResourceStore.GetString("CData::OnlyOneInstanceofSnapin"));
            }

            // First, null out all the member variables
            m_Component       = new ArrayList();
            m_ucsole          = null;
            m_ucsoleNameSpace = null;

            m_rn = new CRootNode();
            // Register ourselves with the Node Manager
            CNodeManager.Data = this;

            // Let's generate our own computer node
            CNodeManager.Init();
            CNodeManager.RootNodeCookie = CNodeManager.AddNode(ref m_rn);
        }// CData
예제 #8
0
        }// CreatePropertyPages

        //-------------------------------------------------
        // CreateChildren
        //
        // This function creates the node's children, registers
        // the nodes with the node manager, and places the node's
        // cookies in it's child array
        //-------------------------------------------------
        internal override void CreateChildren()
        {
            CNode node    = null;
            int   iCookie = 0;

            bool fNonMMC = CNodeManager.Console is INonMMCHost;


            // Some of these nodes we shouldn't add if we're not MMC


            // This node is only valid on the local machine
            if (Data == 1 && !fNonMMC)
            {
                node    = new CSharedAssemblies();
                iCookie = CNodeManager.AddNode(ref node);
                AddChild(iCookie);
            }

            if (!fNonMMC)
            {
                // Now add a Version Policy node
                node    = new CVersionPolicy();
                iCookie = CNodeManager.AddNode(ref node);
                AddChild(iCookie);

                // Now add a Subscribed services node
                node    = new CRemoting();
                iCookie = CNodeManager.AddNode(ref node);
                AddChild(iCookie);
            }
            // Add a Security policy node
            node    = new CGenSecurity();
            iCookie = CNodeManager.AddNode(ref node);
            AddChild(iCookie);

            // And add an Applications Node
            node    = new CGenApplications();
            iCookie = CNodeManager.AddNode(ref node);
            AddChild(iCookie);
        } // CreateChildren
예제 #9
0
        }// AddPermissionSet

        private CSecurityPolicy CreatePolicyNode(PolicyLevelType nType, PolicyLevel pl)
        {
            int             iCookie = 0;
            int             nIndex  = 0;
            CSecurityPolicy node;

            // This node's ordering of the children nodes it inserts is very important
            if (m_iChildren == null || m_iChildren.Length != 3)
            {
                m_iChildren = new int[3];
            }

            switch (nType)
            {
            case PolicyLevelType.Enterprise:
                node = new CSecurityPolicy("Enterprise", pl);
                break;

            case PolicyLevelType.Machine:
                node = new CSecurityPolicy("Machine", pl);
                break;

            case PolicyLevelType.User:
                node = new CSecurityPolicy("User", pl);
                break;

            default:
                throw new Exception("I don't know about this type");
            }

            nIndex = GetNodeIndexNumber(nType);
            CNode gennode = (CNode)node;

            iCookie             = CNodeManager.AddNode(ref gennode);
            m_iChildren[nIndex] = iCookie;

            return(node);
        }// CreatePolicyNode
예제 #10
0
        }// AppDependsNode

        //-------------------------------------------------
        // CreateChildren
        //
        // An application node has a binding policy node and a
        // subscribed services node
        //-------------------------------------------------
        internal override void CreateChildren()
        {
            CNode node    = null;
            int   iCookie = -1;

            // We'll only give an application depends node if we have an app file
            if (m_appInfo.sAppFile.Length > 0)
            {
                // add a application depencies node
                node    = new CApplicationDepends(m_appInfo.sAppFile);
                iCookie = CNodeManager.AddNode(ref node);
                AddChild(iCookie);
            }

            // Now add a Version Policy node
            node    = new CVersionPolicy(m_appInfo.sAppConfigFile);
            iCookie = CNodeManager.AddNode(ref node);
            AddChild(iCookie);

            // Now add a Remoting node
            node    = new CRemoting(m_appInfo.sAppConfigFile);
            iCookie = CNodeManager.AddNode(ref node);
            AddChild(iCookie);
        }// CreateChildren
예제 #11
0
        }// AddCodeGroup

        protected CSingleCodeGroup AddCodeGroup(CodeGroup ucg, bool fPrepTree, PolicyLevel polSrc)
        {
            if (fPrepTree)
            {
                // Check for codegroups with multiple names, and permission sets that
                // may not exist in this policy level
                Security.PrepCodeGroupTree(ucg, polSrc, m_pl);
            }
            m_cg.AddChild(ucg);

            // Now add this codegroup (and its children) to the policy tree
            CNode     nodeFirst = null;
            ArrayList al        = new ArrayList();

            // The ArrayList is laid out as follows...

            // A parent CNode is placed in the ArrayList first, and then
            // CodeGroups follow that should be wrapped in a CNode and be children
            // to the first 'parent' CNode.

            // So the ArrayList could look like this
            //
            // Node1 -> CG1 -> CG2 -> CG3 -> Node2 -> CG4 -> CG5 -> Node3 -> .....
            //
            // So CG1, CG2, and CG3 should all be nodes that are children of Node1.
            // CG4 and CG5 should be nodes that are children of Node2, and so on.

            al.Add(this);
            al.Add(ucg);

            while (al.Count > 0)
            {
                // First item should be a node
                CNode nodeParent = (CNode)al[0];

                // Remove the parent node
                al.RemoveAt(0);

                // Now we should have (possibly) multiple codegroups
                while (al.Count > 0 && !(al[0] is CNode))
                {
                    CodeGroup cg        = (CodeGroup)al[0];
                    CNode     nodeChild = new CSingleCodeGroup(ref m_pl, ref cg, ReadOnly);
                    if (nodeFirst == null)
                    {
                        nodeFirst = nodeChild;
                    }

                    int nCookie = CNodeManager.AddNode(ref nodeChild);

                    // Inform the parent that it has a new child
                    nodeParent.AddChild(nCookie);

                    // And place this new node in the tree
                    nodeParent.InsertSpecificChild(nCookie);

                    // If this codegroup has any children, we'll need to worry about that too
                    bool fHaveChildren = false;

                    // Iterate through this guy's children
                    IEnumerator enumCodeGroups = cg.Children.GetEnumerator();

                    while (enumCodeGroups.MoveNext())
                    {
                        if (!fHaveChildren)
                        {
                            // Put this new 'parent node' in the array list
                            al.Add(nodeChild);
                            fHaveChildren = true;
                        }
                        // And then add all its children
                        CodeGroup cgChild = (CodeGroup)enumCodeGroups.Current;
                        al.Add(cgChild);
                    }
                    // Remove this child codegroup
                    al.RemoveAt(0);
                }
            }

            SecurityPolicyChanged();
            return((CSingleCodeGroup)nodeFirst);
        }// AddCodeGroup
예제 #12
0
        }// AddMenuItems

        internal override void MenuCommand(int iCommandID)
        {
            if (iCommandID == COMMANDS.ADD_APPLICATION)
            {
                // Pop up a dialog so the user can find an assembly
                CChooseAppDialog cad = new CChooseAppDialog();

                System.Windows.Forms.DialogResult dr = cad.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    String sConfigFile  = cad.Filename;
                    String sAppFilename = "";

                    // If this is an executable or Dll, or if it is managed
                    int iLen = sConfigFile.Length;
                    if (iLen > 3)
                    {
                        String sExtension = sConfigFile.Substring(sConfigFile.Length - 3).ToUpper(CultureInfo.InvariantCulture);
                        if (sExtension.ToUpper(CultureInfo.InvariantCulture).Equals("EXE") || sExtension.ToUpper(CultureInfo.InvariantCulture).Equals("DLL") || Fusion.isManaged(sConfigFile))
                        {
                            sAppFilename = sConfigFile;
                            // Let's add a config extension
                            sConfigFile = sConfigFile + ".config";
                        }
                        else if (iLen > 6)
                        {
                            // Check to see if they selected a config file
                            sExtension = sConfigFile.Substring(sConfigFile.Length - 6).ToUpper(CultureInfo.InvariantCulture);

                            if (sExtension.ToUpper(CultureInfo.InvariantCulture).Equals("CONFIG"))
                            {
                                // They've selected a config file. Let's see if there is an assembly around there as well.
                                String sAssemName = sConfigFile.Substring(0, sConfigFile.Length - 7);
                                if (File.Exists(sAssemName))
                                {
                                    sAppFilename = sAssemName;
                                }
                            }
                        }
                    }
                    AppFiles appFile = new AppFiles();
                    appFile.sAppFile       = sAppFilename;
                    appFile.sAppConfigFile = sConfigFile;

                    // Check to see if we already have this app file shown
                    CNode node = CheckForDuplicateApp(appFile);
                    if (node == null)
                    {
                        CConfigStore.SetSetting("AppConfigFiles", appFile);
                        node = new CApplication(appFile);
                        int iCookie = CNodeManager.AddNode(ref node);
                        AddChild(iCookie);
                        InsertSpecificChild(iCookie);
                    }
                    CNodeManager.Console.SelectScopeItem(node.HScopeItem);
                }
            }
            else if (iCommandID == COMMANDS.FIX_APPLICATION)
            {
                PolicyManager(CNodeManager.MMChWnd, null, null, null);
            }
        }// MenuCommand
예제 #13
0
        }// CheckForDuplicateApp

        //-------------------------------------------------
        // CreateChildren
        //
        // This function creates the node's children, registers
        // the nodes with the node manager, and places the node's
        // cookies in it's child array
        //-------------------------------------------------
        internal override void CreateChildren()
        {
            // Don't bother doing any of this if we're not using MMC
            if (!(CNodeManager.Console is INonMMCHost))
            {
                // Grab all the applications we know about and display the names to the
                // user
                ArrayList alApps = (ArrayList)CConfigStore.GetSetting("AppConfigFiles");

                int iLen = alApps.Count;
                for (int i = 0; i < iLen; i++)
                {
                    // Check to see if this App still exists
                    AppFiles af = (AppFiles)alApps[i];

                    // We need either an exe or a config file to do this
                    bool fHaveSomething = false;

                    // Verify the exe still exists....
                    if (af.sAppFile != null && af.sAppFile.Length > 0)
                    {
                        if (File.Exists(af.sAppFile))
                        {
                            fHaveSomething = true;
                        }
                        else
                        {
                            // The exe doesn't exist anymore. Let's update the record
                            CConfigStore.SetSetting("RemoveAppConfigFile", af);
                            af.sAppFile = "";
                            CConfigStore.SetSetting("AppConfigFiles", af);
                        }
                    }

                    // Verify the config file exists
                    if (af.sAppConfigFile != null && af.sAppConfigFile.Length > 0)
                    {
                        // If we don't have an exe, let's see if we can find it
                        if ((af.sAppFile == null || af.sAppFile.Length == 0) && af.sAppConfigFile.Length > 6)
                        {
                            String sExtension = af.sAppConfigFile.Substring(af.sAppConfigFile.Length - 6).ToUpper(CultureInfo.InvariantCulture);

                            if (sExtension.ToUpper(CultureInfo.InvariantCulture).Equals("CONFIG"))
                            {
                                // This is an appropriately named config file. Let's see if there is an assembly around there as well.
                                String sAssemName = af.sAppConfigFile.Substring(0, af.sAppConfigFile.Length - 7);
                                if (File.Exists(sAssemName))
                                {
                                    // Cool. When the user first added the application, they only had a config
                                    // file. Now they have an exe too. We'll take note of that
                                    CConfigStore.SetSetting("RemoveAppConfigFile", af);
                                    af.sAppFile = sAssemName;
                                    CConfigStore.SetSetting("AppConfigFiles", af);
                                    fHaveSomething = true;
                                }
                            }
                        }
                        // Check to see if the config file is still valid
                        if (File.Exists(af.sAppConfigFile))
                        {
                            fHaveSomething = true;
                        }
                        // If it doesn't exist... not a big deal. Config files could get
                        // deleted. No worries.
                    }

                    // See if we snagged something to go off of
                    if (fHaveSomething)
                    {
                        CNode node    = new CApplication(af);
                        int   iCookie = CNodeManager.AddNode(ref node);
                        AddChild(iCookie);
                    }
                    // This entry is now bogus. Get rid of it
                    else
                    {
                        CConfigStore.SetSetting("RemoveAppConfigFile", af);
                    }
                }
            }
        }// CreateChildren