private static void InitializePolicyHierarchy () { string machinePolicyPath = Path.GetDirectoryName (Environment.GetMachineConfigPath ()); // note: use InternalGetFolderPath to avoid recursive policy initialization string userPolicyPath = Path.Combine (Environment.UnixGetFolderPath (Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create), "mono"); PolicyLevel enterprise = new PolicyLevel ("Enterprise", PolicyLevelType.Enterprise); _level = enterprise; enterprise.LoadFromFile (Path.Combine (machinePolicyPath, "enterprisesec.config")); PolicyLevel machine = new PolicyLevel ("Machine", PolicyLevelType.Machine); _level = machine; machine.LoadFromFile (Path.Combine (machinePolicyPath, "security.config")); PolicyLevel user = new PolicyLevel ("User", PolicyLevelType.User); _level = user; user.LoadFromFile (Path.Combine (userPolicyPath, "security.config")); ArrayList al = new ArrayList (); al.Add (enterprise); al.Add (machine); al.Add (user); _hierarchy = ArrayList.Synchronized (al); _level = null; }
public static PolicyLevel LoadPolicyLevelFromFile (string path, PolicyLevelType type) { if (path == null) throw new ArgumentNullException ("path"); PolicyLevel pl = null; try { pl = new PolicyLevel (type.ToString (), type); pl.LoadFromFile (path); } catch (Exception e) { throw new ArgumentException (Locale.GetText ("Invalid policy XML"), e); } return pl; }