G
Guest
Hi,
I will appreciate any insights to set the right permissions to a Windows
Forms Control that is embedded in an html document. The control will be
downloaded by the html doc to the local system to do its job. It requires
file system and registry access rights (read/write).
One of the problems is that restricted users will open the html document
(using IE) and the control needs to have enough rights to access the file
system and registry as mentioned above.
I have done the following:
1) Signed the control.
2) Created a NET policy to grant the respective rights to the control using
NET configuration snap-in. (even tried full trust and am having problems)
Attempted granting read access to a subkey as below but failed. The specific
code lines are:
try
{
new RegistryPermission(RegistryPermissionAccess.Read, subKey).Assert();
RegistryKey rk;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// Revert assert here
}
catch (SecurityException e)
{
MessageBox.Show(e.ToString());
}
I get an SecurityException at OpenSubKey above.
The file system security settings are given using:
// Set unrestricted permissions to access the filesystem
new FileIOPermission(PermissionState.Unrestricted).Assert();
string[] sts = Directory.GetLogicalDrives();
// Revert assert here
I get an SecurityException at above line. However the below code works
(weird!!)
new FileIOPermission(PermissionState.Unrestricted).Assert();
string directoryPath = "c:\\";
string st[] = Directory.GetDirectories(directoryPath);
// Revert assert here
Questions:
What is the best way to do it?
Should I impersonate the access with elevated rights? How?
Can I avoid creating a msi package to have the administrator installing the
control locally, before using it?
Thank you,
Carlos
I will appreciate any insights to set the right permissions to a Windows
Forms Control that is embedded in an html document. The control will be
downloaded by the html doc to the local system to do its job. It requires
file system and registry access rights (read/write).
One of the problems is that restricted users will open the html document
(using IE) and the control needs to have enough rights to access the file
system and registry as mentioned above.
I have done the following:
1) Signed the control.
2) Created a NET policy to grant the respective rights to the control using
NET configuration snap-in. (even tried full trust and am having problems)
Attempted granting read access to a subkey as below but failed. The specific
code lines are:
try
{
new RegistryPermission(RegistryPermissionAccess.Read, subKey).Assert();
RegistryKey rk;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// Revert assert here
}
catch (SecurityException e)
{
MessageBox.Show(e.ToString());
}
I get an SecurityException at OpenSubKey above.
The file system security settings are given using:
// Set unrestricted permissions to access the filesystem
new FileIOPermission(PermissionState.Unrestricted).Assert();
string[] sts = Directory.GetLogicalDrives();
// Revert assert here
I get an SecurityException at above line. However the below code works
(weird!!)
new FileIOPermission(PermissionState.Unrestricted).Assert();
string directoryPath = "c:\\";
string st[] = Directory.GetDirectories(directoryPath);
// Revert assert here
Questions:
What is the best way to do it?
Should I impersonate the access with elevated rights? How?
Can I avoid creating a msi package to have the administrator installing the
control locally, before using it?
Thank you,
Carlos