Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
GeneralRe: Is there a difference? Pin
sps-itsec463-Mar-04 8:48
sps-itsec463-Mar-04 8:48 
GeneralRe: Is there a difference? Pin
Meysam Mahfouzi3-Mar-04 17:27
Meysam Mahfouzi3-Mar-04 17:27 
GeneralHELP with Code Access Security! Pin
Throckmorton2-Mar-04 11:10
Throckmorton2-Mar-04 11:10 
GeneralRe: HELP with Code Access Security! Pin
Heath Stewart2-Mar-04 12:19
protectorHeath Stewart2-Mar-04 12:19 
GeneralRe: HELP with Code Access Security! Pin
Throckmorton2-Mar-04 13:58
Throckmorton2-Mar-04 13:58 
GeneralRe: HELP with Code Access Security! Pin
Throckmorton2-Mar-04 17:23
Throckmorton2-Mar-04 17:23 
GeneralRe: HELP with Code Access Security! Pin
Heath Stewart3-Mar-04 3:27
protectorHeath Stewart3-Mar-04 3:27 
GeneralRe: HELP with Code Access Security! Pin
Throckmorton3-Mar-04 9:19
Throckmorton3-Mar-04 9:19 
Thanks again,

I think I have this working to my satisfaction (for the time being at least - till I figure out more of how all this works).

What I do is enumerate down to the groups below LocalIntranet_Zone and look for MyCustomAccess. Then I also check that it is type URL and points to the appropriate share location. I also check that it has FullTrust permission set.

Here's my next problem:
If I do NOT find the proper code group with proper permissions, I want to add one. I have seen many examples in various places. Every example creates a new code group at the same level as LocalIntranet_Zone (siblings(?)). I want to create a new group that is a child of LocalIntranet_Zone. While I haven't keyed in the examples, I assume they work. The issue I have is when I call SecurityManager.SavePolicy() - it does not actually get saved, even though the group was added or at least seems to have been added.

Here is my code: can you tell me what is wrong? Why doesn't it save?
		<br />
static bool addCodeGroup() <br />
{<br />
		<br />
	// Enumerate all the policies<br />
	IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy();<br />
<br />
	// Move through policies until we hit Machine<br />
	while (policyEnumerator.MoveNext()) <br />
	{	<br />
			<br />
		PolicyLevel machineLevel = (PolicyLevel)policyEnumerator.Current;<br />
<br />
		// If we are in the Machine Security Policy...<br />
		if (machineLevel.Label == "Machine") <br />
		{<br />
			// Build an enumerator to move through the machine level groups<br />
			IEnumerator ie_MachineLevelGroups = machineLevel.RootCodeGroup.Children.GetEnumerator();<br />
					<br />
			while (ie_MachineLevelGroups.MoveNext()) <br />
			{<br />
						<br />
				CodeGroup machineLevelGroup = (CodeGroup)ie_MachineLevelGroups.Current;<br />
<br />
				// if we are in the LocalIntranet_Zone Code Group...<br />
				if (machineLevelGroup.Name == "LocalIntranet_Zone") <br />
				{<br />
<br />
					PermissionSet permSet1 = new NamedPermissionSet("FullTrust");<br />
					IMembershipCondition membership1 = new UrlMembershipCondition("file://wstltest/*");<br />
					PolicyStatement policy1 = new PolicyStatement(permSet1);<br />
					CodeGroup codeGroup1 = new UnionCodeGroup(membership1, policy1);<br />
					codeGroup1.Name = "WSTLTEST_ACCESS";<br />
					machineLevelGroup.AddChild(codeGroup1);<br />
					SecurityManager.SavePolicy();<br />
									<br />
<br />
						} // end if (machineLevelGroup.Name == "LocalIntranet_Zone") <br />
<br />
					} // end while (ie_MachineLevelGroups.MoveNext()) <br />
<br />
								} // end if (machineLevel.Label == "Machine") <br />
<br />
	<br />
			} // end while (policyEnumerator.MoveNext()) <br />
<br />
<br />
			return true;<br />
<br />
		}

GeneralRe: HELP with Code Access Security! Pin
Heath Stewart3-Mar-04 9:27
protectorHeath Stewart3-Mar-04 9:27 
GeneralRe: HELP with Code Access Security! Pin
Throckmorton3-Mar-04 10:11
Throckmorton3-Mar-04 10:11 
GeneralRe: HELP with Code Access Security! Pin
Heath Stewart3-Mar-04 10:16
protectorHeath Stewart3-Mar-04 10:16 
Generalproblems in running app at win startup Pin
visiontec2-Mar-04 10:22
visiontec2-Mar-04 10:22 
GeneralRe: problems in running app at win startup Pin
Dave Kreskowiak2-Mar-04 11:12
mveDave Kreskowiak2-Mar-04 11:12 
GeneralClient size of an control ... Pin
Andres Coder2-Mar-04 7:49
Andres Coder2-Mar-04 7:49 
GeneralRe: Client size of an control ... Pin
Heath Stewart2-Mar-04 9:24
protectorHeath Stewart2-Mar-04 9:24 
Generalinternet explorer Pin
cmarmr2-Mar-04 7:27
cmarmr2-Mar-04 7:27 
GeneralRe: internet explorer Pin
Heath Stewart2-Mar-04 9:39
protectorHeath Stewart2-Mar-04 9:39 
GeneralRe: internet explorer Pin
cmarmr2-Mar-04 9:55
cmarmr2-Mar-04 9:55 
GeneralRe: internet explorer Pin
Heath Stewart2-Mar-04 10:00
protectorHeath Stewart2-Mar-04 10:00 
GeneralRemoting: sharing an object Pin
Judah Gabriel Himango2-Mar-04 7:24
sponsorJudah Gabriel Himango2-Mar-04 7:24 
GeneralRe: Remoting: sharing an object Pin
Heath Stewart2-Mar-04 9:21
protectorHeath Stewart2-Mar-04 9:21 
QuestionHow To: Wizard for my Application Pin
Ritesh Sompura2-Mar-04 7:01
Ritesh Sompura2-Mar-04 7:01 
AnswerRe: How To: Wizard for my Application Pin
Heath Stewart2-Mar-04 9:16
protectorHeath Stewart2-Mar-04 9:16 
AnswerRe: How To: Wizard for my Application Pin
Nick Parker2-Mar-04 9:27
protectorNick Parker2-Mar-04 9:27 
GeneralAnimation Pin
hxxbin2-Mar-04 6:55
hxxbin2-Mar-04 6:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.