private string getFullPath(RhspDataID websiteID, string relativePath)
 {
     return(SecurityTemplate.GetFullPath(
                ServerConfig.WebsiteDirectory,
                CreateManager <WebsiteManager>().Get(websiteID),
                relativePath));
 }
        public void SyncronizeFileSystem(SecurityTemplate securityTemplate)
        {
            string        fullPath      = securityTemplate.GetFullPath(ServerConfig.WebsiteDirectory);
            WindowsUser   windowsUser   = getWindowsUser(securityTemplate.Username);
            FileInfo      fileInfo      = new FileInfo(fullPath);
            DirectoryInfo directoryInfo = new DirectoryInfo(fullPath);

            if (fileInfo.Exists)
            {
                FileSecurity security = fileInfo.GetAccessControl();
                applySecurityAccessRule(securityTemplate, windowsUser, security);
                fileInfo.SetAccessControl(security);
            }
            else if (directoryInfo.Exists)
            {
                DirectorySecurity security = directoryInfo.GetAccessControl();
                applySecurityAccessRule(securityTemplate, windowsUser, security);
                directoryInfo.SetAccessControl(security);
            }
            else
            {
                throw new Exception(
                          "Cannot set security rule because the path '" + fullPath + "' does not exist.");
            }
        }
        private void deleteFromFileSystem(SecurityTemplate securityTemplate, SecurityIdentifier sid)
        {
            string        fullPath      = securityTemplate.GetFullPath(ServerConfig.WebsiteDirectory);
            FileInfo      fileInfo      = new FileInfo(fullPath);
            DirectoryInfo directoryInfo = new DirectoryInfo(fullPath);

            // If it exists, delete it, if not, ignore the delete request.
            if (fileInfo.Exists)
            {
                FileSecurity security = File.GetAccessControl(fileInfo.FullName);
                RemoveMatchingRules(security, sid, securityTemplate.GetAccessControlType());
                File.SetAccessControl(directoryInfo.FullName, security);
            }
            else if (directoryInfo.Exists)
            {
                DirectorySecurity security = Directory.GetAccessControl(directoryInfo.FullName);
                RemoveMatchingRules(security, sid, securityTemplate.GetAccessControlType());
                Directory.SetAccessControl(fileInfo.FullName, security);
            }
        }
 private string getFullPath(DirectoryInfo websiteDirectory, string relativePath)
 {
     return(SecurityTemplate.GetFullPath(
                websiteDirectory,
                relativePath));
 }