How to write/read a ntw folder from a clickonce C# application where the user does not have permissi

J

jpf.wk

I have developed a clickonce WindowsForm C# Application. Users
download it without problems from my web server (IIS), new versions
are always signaled to the final user, etc... Let's suppose user X
download my application. X does not have access (read/write/connect)
to a network folder called, e.g., \\remotemachine\documents. But my
application should have this permission. In other words, X can not
write on \\remotemachine\documents, but my program should do it
(without give explicit previous explicit permission to X). X can only
access that network folder in a controlled way through my
application.Outside this possibility, X can not access it (even for
read it).

I spent all day long trying to understand CAS, CASPOL, Framework 2.0
and clickonce apps security restrictions. I understand that my program
should have "elevated permissions". In my program I assert access to
the remote folder and it works!

FileIOPermission fiop = new
FileIOPermission(FileIOPermissionAccess.AllAccess, <remote folder>);

try
{
fiop.Assert();
MessageBox.Show("demand succesful");
}
catch (SecurityException securityEx)
{
MessageBox.Show(securityEx.Message, "Security
Exception");
}

But when I File.Copy a file to that remote folder, it throws an
exception System.UnauthorizedAccessException, denying access to the
network folder.

Before continuing, should I have to change my deployment strategy or
is there some security policy modif that supports what I need?

Bye,
JP
 
K

Kevin Spencer

Your application would have to impersonate a user with the necessary
permission.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top