Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

FileIOPermissionAccess.PathDiscovery permission needed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian Stoop - 07 Mar 2008 22:15 GMT
How can I give the logged in User FileIOPermissionAccess.PathDiscovery
permission to execute a Environment.SpecialFolder.ApplicationData  method ?

thanks Brian,
Alvin Bruney [ASP.NET MVP] - 07 Mar 2008 23:13 GMT
One way is to create an account that has the required permission and
impersonate that user through code.

Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> How can I give the logged in User FileIOPermissionAccess.PathDiscovery
> permission to execute a Environment.SpecialFolder.ApplicationData  method
> ?
>
> thanks Brian,
Brian Stoop - 08 Mar 2008 02:00 GMT
Alvin,

Do you know how I give a user FileIOPermissionAccess.PathDiscovery
permission? Is it via the Group Policy editor?

thanks

> One way is to create an account that has the required permission and
> impersonate that user through code.
[quoted text clipped - 4 lines]
>>
>> thanks Brian,
Alvin Bruney [ASP.NET MVP] - 10 Mar 2008 01:49 GMT
One way is to create an assembly that has an attribute that demands the
fileIOPermissionAccess permission. Inside the assembly, you can create a
method that does the dirty work. The downside with this is that the entire
class has the permissions, if you want to restrict it to just a method, you
can demand the permission thru code. There's a link with an implementation
sample here:
http://msdn2.microsoft.com/en-us/library/system.security.permissions.fileiopermi
ssion.aspx
.
Read the pre-requesits VERY carefully. These are strong permissions you are
asking for and there is a very real potential for you, your code, or rogue
code to subvert or compromise the sub-system.

Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> Alvin,
>
[quoted text clipped - 11 lines]
>>>
>>> thanks Brian,
Brian Stoop - 10 Mar 2008 14:50 GMT
Alvin,

It is the FileIOPermissionAccess.PathDiscovery permission I want to set.
(I'm trying to get the value of  Environment.SpecialFolder.ApplicationData)

In the msdn examples we get::

FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Read,
"C:\\test_r");
f2.AddPathList(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read,
"C:\\example\\out.txt");

But I cannot figure out the call to set PathDiscovery permission as it has
no path?, and there appears to be no signature for it?

thanks, B

> One way is to create an assembly that has an attribute that demands the
> fileIOPermissionAccess permission. Inside the assembly, you can create a
[quoted text clipped - 22 lines]
>>>>
>>>> thanks Brian,
Alvin Bruney [ASP.NET MVP] - 11 Mar 2008 03:14 GMT
Hold on, why can't you simply access the environment variable, the worker
process should have rights to it. For instance, this code on a web page
returns the name of my computer

protected void Page_Load(object sender, EventArgs e)
   {
       Response.Write(Environment.MachineName);
   }

Modify the code to return what you want.
Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> Alvin,
>
[quoted text clipped - 40 lines]
>>>>>
>>>>> thanks Brian,
Brian Stoop - 11 Mar 2008 23:11 GMT
I moved call to the page load, but it still did not return the env variable.

Thanks for your suggestion, B

> Hold on, why can't you simply access the environment variable, the worker
> process should have rights to it. For instance, this code on a web page
[quoted text clipped - 50 lines]
>>>>>>
>>>>>> thanks Brian,
Alvin Bruney [ASP.NET MVP] - 12 Mar 2008 00:26 GMT
using System;
using System.Web;

public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
       Response.Write(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
       //this prints out C:\Users\vapor\AppData\Roaming
       //to my web page
   }
}

Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> I moved call to the page load, but it still did not return the env
> variable.
[quoted text clipped - 55 lines]
>>>>>>>
>>>>>>> thanks Brian,
Brian Stoop - 12 Mar 2008 15:04 GMT
Alvin,

Are you running as an Administrator? If so it will work. Try browsing to
your web application as a "Domain User" only, this is what fails for me.

Thanks, B

> using System;
> using System.Web;
[quoted text clipped - 69 lines]
>>>>>>>>
>>>>>>>> thanks Brian,
Alvin Bruney [ASP.NET MVP] - 13 Mar 2008 00:18 GMT
So if that's the case, you can use impersonation to solve the permissions
issue.

Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> Alvin,
>
[quoted text clipped - 76 lines]
>>>>>>>>>
>>>>>>>>> thanks Brian,

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.