Home All Groups Group Topic Archive Search About

DirectorySecurity's SetAccesControl works/not works?

Author
4 May 2007 12:29 PM
KKS
Look at the following example. The ASPNET account is added to the directory
but it has no rights. Its marked as special permissions only. No read and
execute. What could be wrong? Machine is XP SP2 .NET 2.0 and Visual Studio
2005.

AddDirectorySecurity( gatewayPath, "ASPNET",
FileSystemRights.ReadAndExecute, AccessControlType.Allow );

private void AddDirectorySecurity( string FileName, string account,
FileSystemRights rights, AccessControlType controlType )

{

DirectoryInfo dInfo = new DirectoryInfo( FileName );

DirectorySecurity dSecurity = dInfo.GetAccessControl( );

dSecurity.AddAccessRule( new FileSystemAccessRule( account, rights,
controlType ) );

dInfo.SetAccessControl( dSecurity );

}

AddThis Social Bookmark Button