Cannot add a new code group under localintranet_zone programmatically
From: surya (suryanarayanan.varadarajan_at_honeywell.com)
Date: 02/26/04
- Previous message: Vincent: "RE: Create a file on the server from an aspx"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 26 Feb 2004 19:48:55 +0530
Hi,
I am trying to add a new code group under the localintranet_zone code group
in machine policy. The code goes through but it doesn't update the .Net
configuration. Howerver if I add a new code group under the ALL Code group
under machine policy it works. Have any of you faced this problem?
The code I am using is:
System.Collections.IEnumerator enu =
System.Security.SecurityManager.PolicyHierarchy();
while(enu.MoveNext())
{
polLevel = enu.Current as System.Security.Policy.PolicyLevel;
if(polLevel.Label.Equals("Machine"))
{
System.Security.Policy.CodeGroup allCodeGroup = polLevel.RootCodeGroup;
System.Collections.IList listOfCodeGroups = allCodeGroup.Children;
for(int i =0; i <listOfCodeGroups.Count; i++)
{
System.Security.Policy.CodeGroup curCodeGroup = listOfCodeGroups[i] as
System.Security.Policy.CodeGroup;
if(curCodeGroup.Name.Equals("LocalIntranet_Zone"))
{
byte[] publickey = { 129, 164, 169, 143, 72, 151, 76, 171, 134, 74,
103, 42, 135, 222, 191, 57, 137, 126, 221, 171, 237, 50, 18, 50, 195, 127,
51, 8, 73, 71, 101, 202, 171, 67, 37, 89, 13, 119, 145,
119, 246, 102, 64, 255, 236};
System.Security.Permissions.StrongNamePublicKeyBlob publickeyblob =
new System.Security.Permissions.StrongNamePublicKeyBlob (publickey);
System.Security.Policy.IMembershipCondition memCon =
new
System.Security.Policy.StrongNameMembershipCondition(publickeyblob,"Storage"
,null);
System.Security.PermissionSet ps =
polLevel.GetNamedPermissionSet("FullTrust");
System.Security.Policy.PolicyStatement statement = new
System.Security.Policy.PolicyStatement(ps,System.Security.Policy.PolicyState
mentAttribute.LevelFinal);
System.Security.Policy.UnionCodeGroup myTestCodeGroup =
new System.Security.Policy.UnionCodeGroup(memCon,statement);
myTestCodeGroup.Description = "This code group identifies all
storage assemblies";
myTestCodeGroup.Name = "Storage";
curCodeGroup.AddChild(myTestCodeGroup);
System.Security.SecurityManager.SavePolicy();
break;
}
}
}
- Previous message: Vincent: "RE: Create a file on the server from an aspx"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|