Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

Throckmorton

@Throckmorton
About
Posts
9
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Is there a way to programatically determine if a binary is managed code?
    T Throckmorton

    So i think it would be handy if I could write a function that does this: If \\server\share\binary.exe is managed code Do this Otherwise it is not managed code Do that Is such a thing possible? Thanks, Ian

    C# sysadmin question

  • HELP with Code Access Security!
    T Throckmorton

    Thanks Heath, but still not working - Where would I add SecurityManager.SavePolicyLevel(machineLevel) call? I tried adding it just before SavePolicy() call... Just after SavePolicy() call... In place of SavePolicy() call... Still doesn't save the machine policy.

    C# csharp database dotnet security help

  • HELP with Code Access Security!
    T Throckmorton

    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? static bool addCodeGroup() { // Enumerate all the policies IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy(); // Move through policies until we hit Machine while (policyEnumerator.MoveNext()) { PolicyLevel machineLevel = (PolicyLevel)policyEnumerator.Current; // If we are in the Machine Security Policy... if (machineLevel.Label == "Machine") { // Build an enumerator to move through the machine level groups IEnumerator ie_MachineLevelGroups = machineLevel.RootCodeGroup.Children.GetEnumerator(); while (ie_MachineLevelGroups.MoveNext()) { CodeGroup machineLevelGroup = (CodeGroup)ie_MachineLevelGroups.Current; // if we are in the LocalIntranet_Zone Code Group... if (machineLevelGroup.Name == "LocalIntranet_Zone") { PermissionSet permSet1 = new NamedPermissionSet("FullTrust"); IMembershipCondition membership1 = new UrlMembershipCondition("file://wstltest/*"); PolicyStatement policy1 = new PolicyStatement(permSet1); CodeGroup codeGroup1 = new UnionCodeGroup(membership1, policy1); codeGroup1.Name = "WSTLTEST_ACCESS"; machineLevelGroup.AddChild(codeGroup1); SecurityManager.SavePolicy(); } // end if (machineLevelGroup.Name == "LocalIntranet_Zone") } // end while (ie_MachineLevelGroups.MoveNext()) } // end if (machineLevel.Label == "Machine") } // end while (policyEnumerator.MoveNext()) return true; }

    C# csharp database dotnet security help

  • HELP with Code Access Security!
    T Throckmorton

    Ahh I figured it out finally :)

    C# csharp database dotnet security help

  • HELP with Code Access Security!
    T Throckmorton

    Thanks Heath - I hate to ask but given that I am a total noob at this - can you provide (or point me to) a more specific example of enumerating the PolicyHierarchy and searching for specific groups? I am unable to actually resolve specific group names or at least cannot figure out how to. Right now I have: IEnumerator levels = SecurityManager.PolicyHierarchy(); while(levels.MoveNext()) { PolicyLevel pl = (PolicyLevel)levels.Current; Console.WriteLine("Policy Level: {0}", pl.Label); } Which prints: Policy Level: Enterprise Policy Level: Machine Policy Level: User I see a method in there called ResolveMatchingCodeGroups() but it wants an "evidence" and no matter what I try in the Evidence object it always returns the same things, something like: All_Code All_Code All_Code I want to check if "MyCustomCodeGroup" exists. It is located here:

    - Runtime Security Policy
    - Machine
    - Code Groups
    - All_Code
    - LocalIntranet_Zone
    - MyCustomCodeGroup

    The membership condition type is "URL" and the URL is "file://MyServer/*". The permission set on this group is FullTrust. As for the other part of your reply - The appdomain/assembly stuff is complete greek to me. I will have to learn more about it. However I would say that the local exe calls remote exe's. The remote exe's can be managed code but also they can be .cmd/.bat files or even .msi, or .exe (C++ apps). Thanks for your help, Ian

    C# csharp database dotnet security help

  • HELP with Code Access Security!
    T Throckmorton

    Hello, I am wondering if there is a way to programatically find a code group in the configuration wizard? Basically, I have a c# app (local) that calls c# apps (remote share). If I try to call an app without the proper permissions set up, the CALLED app seems to throw a security exception. Since I have no idea how to trap an exception in localApp that is thrown by calledApp, I want to try something else: What I want to do is this: 1) Before calling remote app, somehow query the Machine Code Groups in .NET Framework Configuration (programatically). 2) If the required code group does not exist, create it. 3) Finally, call the remote app. Is this possible? Thanks, Ian

    C# csharp database dotnet security help

  • How to gain access to a network share?
    T Throckmorton

    Hello, My program needs to access a network share and either copy files from the share or else just execute a program. First I have the client check if it can see the share: if(Directory.Exists("\\\\server\\share") { // do whatever } else { // couldn't see share // provided the share is online // I assume the client does not have proper permission // basically I want to "net use" here. } Is there a function that does this? Or do i need to start a "net use" process? What is the preferred method of gaining access to a remote share through C#? Thanks, Ian

    C# sysadmin question csharp tutorial

  • How to start a process within the current command window?
    T Throckmorton

    Arg I figured it out. I used UseShellExecute = false and took out the CreateNoWindow = true.

    C# question csharp sysadmin tutorial

  • How to start a process within the current command window?
    T Throckmorton

    This might be a stupid question but I can't figure it out: I am writing a simple c# console app that calls another executable (usually a batch file but sometimes an exe). I want the other executable called to run in the same window that I ran the c# app. For instance, one of the executables I can call is an exe and it prints the build# to the screen. If I call it from the command prompt manually it runs in the same window: c:\>\\server\share\getversion build number: 3000 c:\> However in my C# app it always opens getversion.exe in a new window. How do I make it run in the current command window? I tried using ProcessStartInfo.CreateNoWindow = false but that doesn't work. if(Directory.Exists("\\\\server\\share\\")) { Process myProcess = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "\\\\server\\share\\getversion.exe"; myProcess.StartInfo = startInfo; myProcess.Start(); } When I run ConsoleApplication1.exe from a command prompt, it opens another command window, executes getversion.exe (which then closes immediately and you can't even see what it said).

    C# question csharp sysadmin tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups