EDN Admin
Well-known member
Hi,
I have an assembly. I wanned to know what permissions are granted for it when I run it directly from the c: drive, and when I run it from the default C$ share.
I created CodeAccessPermission objects, and called the System.Security.SecurityManager.IsGranted() to see whether the permission is granted for the assembly or not.
Heres my code:
<div style="color:black; background-color:white
<pre><span style="color:blue Imports System.Security.Permissions
<span style="color:blue Imports System.Security
<span style="color:blue Imports System.Drawing.Printing
<span style="color:blue Module Module1
<span style="color:blue Sub WritePermissionState(<span style="color:blue ByVal p <span style="color:blue As CodeAccessPermission)
Console.WriteLine(p.<span style="color:blue GetType().ToString() + <span style="color:#a31515 ": " + SecurityManager.IsGranted(p).ToString)
<span style="color:blue End <span style="color:blue Sub
<span style="color:blue Sub Main()
WritePermissionState(<span style="color:blue New FileIOPermission(PermissionState.Unrestricted))
WritePermissionState(<span style="color:blue New EnvironmentPermission(EnvironmentPermissionAccess.Read, <span style="color:#a31515 "USERNAME"))
WritePermissionState(<span style="color:blue New FileDialogPermission(FileDialogPermissionAccess.Open))
WritePermissionState(<span style="color:blue New IsolatedStorageFilePermission(PermissionState.Unrestricted))
WritePermissionState(<span style="color:blue New ReflectionPermission(ReflectionPermissionFlag.MemberAccess))
WritePermissionState(<span style="color:blue New UIPermission(UIPermissionWindow.SafeTopLevelWindows))
WritePermissionState(<span style="color:blue New PrintingPermission(PrintingPermissionLevel.SafePrinting))
WritePermissionState(<span style="color:blue New Net.SocketPermission(PermissionState.Unrestricted))
WritePermissionState(<span style="color:blue New Net.DnsPermission(PermissionState.Unrestricted))
Console.WriteLine(<span style="color:#a31515 "Press Enter key to continue")
Console.Read()
<span style="color:blue End <span style="color:blue Sub
<span style="color:blue End <span style="color:blue Module
[/code]
<br/>
I built the assembly, then ran it from the C: drive; all the permission were granted. Then I ran the cmd and typed: \127.0.0.1c$Assembly.exe; all the permission are still granted, including the FileIOPermission.
<span style="text-decoration:underline Heres my question : when I ran the assembly from the c:, it has the My_Computer zone evidence, and all those permissions will be granted for it, I understand. But when I ran it from the C$
share, the FileIOPermission, the DNSPermission, and the SocketPermission should not be granted for it, because its running from the Internet zone.
Why are all those permissions granted to this assembly when its running on the Internet zone?
Please help
Abdul
View the full article
I have an assembly. I wanned to know what permissions are granted for it when I run it directly from the c: drive, and when I run it from the default C$ share.
I created CodeAccessPermission objects, and called the System.Security.SecurityManager.IsGranted() to see whether the permission is granted for the assembly or not.
Heres my code:
<div style="color:black; background-color:white
<pre><span style="color:blue Imports System.Security.Permissions
<span style="color:blue Imports System.Security
<span style="color:blue Imports System.Drawing.Printing
<span style="color:blue Module Module1
<span style="color:blue Sub WritePermissionState(<span style="color:blue ByVal p <span style="color:blue As CodeAccessPermission)
Console.WriteLine(p.<span style="color:blue GetType().ToString() + <span style="color:#a31515 ": " + SecurityManager.IsGranted(p).ToString)
<span style="color:blue End <span style="color:blue Sub
<span style="color:blue Sub Main()
WritePermissionState(<span style="color:blue New FileIOPermission(PermissionState.Unrestricted))
WritePermissionState(<span style="color:blue New EnvironmentPermission(EnvironmentPermissionAccess.Read, <span style="color:#a31515 "USERNAME"))
WritePermissionState(<span style="color:blue New FileDialogPermission(FileDialogPermissionAccess.Open))
WritePermissionState(<span style="color:blue New IsolatedStorageFilePermission(PermissionState.Unrestricted))
WritePermissionState(<span style="color:blue New ReflectionPermission(ReflectionPermissionFlag.MemberAccess))
WritePermissionState(<span style="color:blue New UIPermission(UIPermissionWindow.SafeTopLevelWindows))
WritePermissionState(<span style="color:blue New PrintingPermission(PrintingPermissionLevel.SafePrinting))
WritePermissionState(<span style="color:blue New Net.SocketPermission(PermissionState.Unrestricted))
WritePermissionState(<span style="color:blue New Net.DnsPermission(PermissionState.Unrestricted))
Console.WriteLine(<span style="color:#a31515 "Press Enter key to continue")
Console.Read()
<span style="color:blue End <span style="color:blue Sub
<span style="color:blue End <span style="color:blue Module
[/code]
<br/>
I built the assembly, then ran it from the C: drive; all the permission were granted. Then I ran the cmd and typed: \127.0.0.1c$Assembly.exe; all the permission are still granted, including the FileIOPermission.
<span style="text-decoration:underline Heres my question : when I ran the assembly from the c:, it has the My_Computer zone evidence, and all those permissions will be granted for it, I understand. But when I ran it from the C$
share, the FileIOPermission, the DNSPermission, and the SocketPermission should not be granted for it, because its running from the Internet zone.
Why are all those permissions granted to this assembly when its running on the Internet zone?
Please help
Abdul
View the full article