I have a simple issue.. I just need to grant write/full access for a specified directory after my web setup project commits installation.
What I did is:
I created an installer class library for setup project. And I added the project into commit section of installation. After committing, my installer class library is executing and trying to give access for 3 directories (for uploading process). But I couldn't
find the right code for giving full permission for a directory. Below, you can see my code which is trying to give access.
But this code just adds special permissions and it doesn't work for my website to write that folder. So I found the code below which is a
command prompt code: icacls.exe C:\INETPUB\WWWROOT\TARGET_SITE /grant "IIS_WPG":(F,WDAC) /T and it's the same result like the first one. Doesnt' workk. So I still could not find any way to give full access permission for a directory.
Any Ideas? Does anybody must have to be done this before?
Thanks in advance.
r00Tsecurity
Member
5 Points
19 Posts
GRANT WRITE ACCESS FOR A FOLDER DURING WEB SETUP PROJECT INSTALLS?
Apr 20, 2008 08:23 PM|LINK
Hi,
I have a simple issue.. I just need to grant write/full access for a specified directory after my web setup project commits installation.
What I did is:
I created an installer class library for setup project. And I added the project into commit section of installation. After committing, my installer class library is executing and trying to give access for 3 directories (for uploading process). But I couldn't find the right code for giving full permission for a directory. Below, you can see my code which is trying to give access.
const string account1 = @"NT AUTHORITY\NETWORK SERVICE";
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
string targetDirectory = Context.Parameters["targetdir"] + "\\upload_directory";
SetSecuritySettings (targetDirectory , account1);
}
public static void SetSecuritySettings(String path, String account)
{
AddDirectorySecurity(path, account, fileRights, AccessControlType.Allow);
}
public static void AddDirectorySecurity(string path, string account, FileSystemRights rights, AccessControlType controlType)
{
try
{
DirectorySecurity dSecurity = Directory.GetAccessControl(path);
System.Security.AccessControl.FileSystemAccessRule fsar = new System.Security.AccessControl.FileSystemAccessRule(account, rights, controlType);
dSecurity.AddAccessRule(fsar);
Directory.SetAccessControl(path, dSecurity);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
But this code just adds special permissions and it doesn't work for my website to write that folder. So I found the code below which is a command prompt code:
icacls.exe C:\INETPUB\WWWROOT\TARGET_SITE /grant "IIS_WPG":(F,WDAC) /T
and it's the same result like the first one. Doesnt' workk. So I still could not find any way to give full access permission for a directory.
Any Ideas? Does anybody must have to be done this before?
Thanks in advance.
dhanashivam
Member
87 Points
71 Posts
Re: GRANT WRITE ACCESS FOR A FOLDER DURING WEB SETUP PROJECT INSTALLS?
Apr 30, 2008 10:06 AM|LINK
hi,
i am also need to give full rights for the IUSR account of the IIS to a particular directory. did you get any solution for this?
if you know let me too.
thanks in advance.
Regards,
dhana.
r00Tsecurity
Member
5 Points
19 Posts
Re: GRANT WRITE ACCESS FOR A FOLDER DURING WEB SETUP PROJECT INSTALLS?
May 14, 2008 07:56 AM|LINK
no. I haven't found any good solution
dhanashivam
Member
87 Points
71 Posts
Re: GRANT WRITE ACCESS FOR A FOLDER DURING WEB SETUP PROJECT INSTALLS?
May 14, 2008 08:26 AM|LINK
http://forums.asp.net/p/1255778/2354823.aspx#2354823
go thru this link. here i have given the solution for it.
regards,
dhana.
r00Tsecurity
Member
5 Points
19 Posts
Re: GRANT WRITE ACCESS FOR A FOLDER DURING WEB SETUP PROJECT INSTALLS?
May 14, 2008 11:46 AM|LINK
thanks I'll try it.