G
giovannialbamonte
Hi,
I discover this developing my project.
Developer Machine
SO: Windows Server 2003
Name: ServerDev
Domain: aedes (Active directory 2003)
File System Machine
SO: Windows Server 2003
Name: ServerFS
Domain: aedes (Active directory 2003)
On File System Machine
Create a folder c:\test
Share this folder and assign everyone full control in share permission tab
On security tab remove all users from and assing to Everyone only read
permission.
So nobody can create file or subfolder in c:\test
On SeerverDev
Create a aspx 2.0 project with this identity on web.config
<identity impersonate="true" user="aedes\user1" password="Password.1" />
Create aspx page with this code:
System.Security.Principal.IIdentity WinId =
HttpContext.Current.User.Identity;
System.Security.Principal.WindowsIdentity wi =
(System.Security.Principal.WindowsIdentity)WinId;
System.Security.Principal.WindowsImpersonationContext wic =
wi.Impersonate();
try
{
string path = TextBox1.Text;
string newfolderName = TextBox2.Text;
Directory.CreateDirectory(Path.Combine(path,newfolderName));
}
catch (Exception ex)
{
throw (ex);
}
finally
{
wic.Undo();
}
Aedes\User1 is local administrators group of ServerDev
Aedes\User1 is local administrators group of ServerFS
Running this code it is possible create subfolder in \\ServerFS\Test
Although c:\Test has only read permission for everyone
Regards
Giovanni
I discover this developing my project.
Developer Machine
SO: Windows Server 2003
Name: ServerDev
Domain: aedes (Active directory 2003)
File System Machine
SO: Windows Server 2003
Name: ServerFS
Domain: aedes (Active directory 2003)
On File System Machine
Create a folder c:\test
Share this folder and assign everyone full control in share permission tab
On security tab remove all users from and assing to Everyone only read
permission.
So nobody can create file or subfolder in c:\test
On SeerverDev
Create a aspx 2.0 project with this identity on web.config
<identity impersonate="true" user="aedes\user1" password="Password.1" />
Create aspx page with this code:
System.Security.Principal.IIdentity WinId =
HttpContext.Current.User.Identity;
System.Security.Principal.WindowsIdentity wi =
(System.Security.Principal.WindowsIdentity)WinId;
System.Security.Principal.WindowsImpersonationContext wic =
wi.Impersonate();
try
{
string path = TextBox1.Text;
string newfolderName = TextBox2.Text;
Directory.CreateDirectory(Path.Combine(path,newfolderName));
}
catch (Exception ex)
{
throw (ex);
}
finally
{
wic.Undo();
}
Aedes\User1 is local administrators group of ServerDev
Aedes\User1 is local administrators group of ServerFS
Running this code it is possible create subfolder in \\ServerFS\Test
Although c:\Test has only read permission for everyone
Regards
Giovanni