FileIOPermissionAccess.PathDiscovery permission needed

  • Thread starter Thread starter Brian Stoop
  • Start date Start date
B

Brian Stoop

How can I give the logged in User FileIOPermissionAccess.PathDiscovery
permission to execute a Environment.SpecialFolder.ApplicationData method ?

thanks Brian,
 
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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,

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


thanks

Alvin Bruney said:
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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


Brian Stoop said:
How can I give the logged in User FileIOPermissionAccess.PathDiscovery
permission to execute a Environment.SpecialFolder.ApplicationData method
?

thanks Brian,
 
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.fileiopermission.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.

--
--
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


Brian Stoop said:
Alvin,

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


thanks

Alvin Bruney said:
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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


Brian Stoop said:
How can I give the logged in User FileIOPermissionAccess.PathDiscovery
permission to execute a Environment.SpecialFolder.ApplicationData
method ?

thanks Brian,
 
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


Alvin Bruney said:
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.fileiopermission.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.

--
--
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


Brian Stoop said:
Alvin,

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


thanks

Alvin Bruney said:
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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,
 
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.
--
--
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


Brian Stoop said:
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


Alvin Bruney said:
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.fileiopermission.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.

--
--
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


Brian Stoop said:
Alvin,

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


thanks

"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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,
 
I moved call to the page load, but it still did not return the env variable.

Thanks for your suggestion, B



Alvin Bruney said:
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.
--
--
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


Brian Stoop said:
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


Alvin Bruney said:
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.fileiopermission.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.

--
--
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,

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


thanks

"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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,
 
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
}
}


--
--
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


Brian Stoop said:
I moved call to the page load, but it still did not return the env
variable.

Thanks for your suggestion, B



Alvin Bruney said:
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.
--
--
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


Brian Stoop said:
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


"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
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.fileiopermission.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.

--
--
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,

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


thanks

"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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,
 
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



Alvin Bruney said:
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
}
}


--
--
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


Brian Stoop said:
I moved call to the page load, but it still did not return the env
variable.

Thanks for your suggestion, B



Alvin Bruney said:
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.
--
--
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,

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


"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
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.fileiopermission.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.

--
--
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,

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


thanks

"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
One way is to create an account that has the required permission and
impersonate that user through code.

--
--
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,
 
So if that's the case, you can use impersonation to solve the permissions
issue.

--
--
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


Brian Stoop said:
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



Alvin Bruney said:
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
}
}


--
--
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


Brian Stoop said:
I moved call to the page load, but it still did not return the env
variable.

Thanks for your suggestion, B



"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
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.
--
--
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,

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


"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
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.fileiopermission.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.

--
--
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,

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


thanks

"Alvin Bruney [ASP.NET MVP]" <www.lulu.com/owc> wrote in message
One way is to create an account that has the required permission
and impersonate that user through code.

--
--
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,
 
Back
Top