}// AddMenuItems internal override void MenuCommand(int iCommandID) { // All these menu commands are going to require the policy nodes to be created and expanded. // Let's check to see if we've done that already.... if (NumChildren == 0) { CNodeManager.CNamespace.Expand(HScopeItem); } if (iCommandID == COMMANDS.NEW_SECURITYPOLICY) { CNewSecurityPolicyDialog nspd = new CNewSecurityPolicyDialog(); System.Windows.Forms.DialogResult dr = nspd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { // To get a 'New' Security policy, we just load a policy from a file that doesn't exist CSecurityPolicy secpolnode = GetSecurityPolicyNode(nspd.SecPolType); // Ok, this is really dumb. I need to create a security file where the user // wants to store the policy before I can tell the Security Manager about it. File.Copy(secpolnode.MyPolicyLevel.StoreLocation, nspd.Filename, true); PolicyLevel pl = SecurityManager.LoadPolicyLevelFromFile(nspd.Filename, nspd.SecPolType); pl.Reset(); secpolnode.SetNewSecurityPolicyLevel(pl); secpolnode.SecurityPolicyChanged(); // Select the policy node the user just mucked with CNodeManager.SelectScopeItem(secpolnode.HScopeItem); } } else if (iCommandID == COMMANDS.OPEN_SECURITYPOLICY) { COpenSecurityPolicyDialog ospd = new COpenSecurityPolicyDialog(new String[] { EnterpriseNode.ComputerPolicyFilename, MachineNode.ComputerPolicyFilename, UserNode.ComputerPolicyFilename }); System.Windows.Forms.DialogResult dr = ospd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { // Try and load the given security policy PolicyLevel pl; try { pl = SecurityManager.LoadPolicyLevelFromFile(ospd.Filename, ospd.SecPolType); } catch { MessageBox(String.Format(CResourceStore.GetString("CGenSecurity:isNotASecurityFile"), ospd.Filename), CResourceStore.GetString("CGenSecurity:isNotASecurityFileTitle"), MB.ICONEXCLAMATION); return; } CSecurityPolicy secpolnode = GetSecurityPolicyNode(ospd.SecPolType); secpolnode.SetNewSecurityPolicyLevel(pl); // Select the policy node the user just mucked with CNodeManager.SelectScopeItem(secpolnode.HScopeItem); } } else if (iCommandID == COMMANDS.EVALUATE_ASSEMBLY) { CWizard wiz = new CEvalAssemWizard(); wiz.LaunchWizard(Cookie); } else if (iCommandID == COMMANDS.TRUST_ASSEMBLY) { // Let's create a new wizard now to dump any old settings we have CFullTrustWizard wiz = new CFullTrustWizard(MachineNode.ReadOnly, UserNode.ReadOnly); wiz.LaunchWizard(Cookie); // See if it updated anything a codegroup if (wiz.MadeChanges) { CSecurityPolicy sp = GetSecurityPolicyNode(Security.GetPolicyLevelTypeFromLabel(wiz.PolLevel.Label)); sp.RedoChildren(); sp.SecurityPolicyChanged(); } } else if (iCommandID == COMMANDS.ADJUST_SECURITYPOLICY) { CSecurityAdjustmentWizard wiz = new CSecurityAdjustmentWizard(MachineNode.ReadOnly, UserNode.ReadOnly); wiz.LaunchWizard(Cookie); // Check to see if we need to tell any policies that we changed them if (wiz.didUserPolicyChange) { UserNode.RedoChildren(); UserNode.SecurityPolicyChanged(); } if (wiz.didMachinePolicyChange) { MachineNode.RedoChildren(); MachineNode.SecurityPolicyChanged(); } } else if (iCommandID == COMMANDS.CREATE_MSI) { CWizard wiz = new CCreateDeploymentPackageWizard(this); wiz.LaunchWizard(Cookie); } else if (iCommandID == COMMANDS.RESET_POLICY) { int nRes = MessageBox(CResourceStore.GetString("CGenSecurity:ConfirmResetAll"), CResourceStore.GetString("CGenSecurity:ConfirmResetAllTitle"), MB.YESNO | MB.ICONQUESTION); if (nRes == MB.IDYES) { if (!EnterpriseNode.ReadOnly) { EnterpriseNode.ResetSecurityPolicy(); } if (!MachineNode.ReadOnly) { MachineNode.ResetSecurityPolicy(); } if (!UserNode.ReadOnly) { UserNode.ResetSecurityPolicy(); } MessageBox(CResourceStore.GetString("CGenSecurity:PoliciesResetAll"), CResourceStore.GetString("CGenSecurity:PoliciesResetAllTitle"), MB.ICONINFORMATION); } } }// MenuCommand