Software

[asp] Gestire il download autorizzato di file e/o documenti

Una delle problematiche più diffuse quando si realizza un sito con protezione, è gestire i download di file e documenti autorizzandolo ai soli utenti abilitati o a seconda di regole personalizzate. Se i file o i documenti risiedono in una cartella del sito, facilmente vi è possibile accedervi da browser una volta “scoperto” il nome del file. Per evitare questo, è sufficiente scrivere una pagina asp che si occupi di verificare se l’utente può o meno accedere al file.
In caso affermativo, il file verrà inviato al client.


<%
Function ReadBinaryFile(FileName)Const adTypeBinary = 1'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")'Specify stream type - we want To get binary data.
BinaryStream.Type = adTypeBinary

'Open the stream
BinaryStream.Open

'Load the file data from disk To stream object
BinaryStream.LoadFromFile FileName

'Open the stream And get binary data from the object
ReadBinaryFile = BinaryStream.Read

End Function

'Logica di gestione
'Verifico se l'utente può accedere al file e setto BlnOK a True o a False
BlnOK = True

If BlnOK Then
Response.Buffer = True
Response.BinaryWrite ReadBinaryFile(Session("File"))
Else
Response.Write "Errore!"
End If

%>

Utilizzando le variabili di sessione, si passa il nome del file. All’interno della sezione Logica di gestione si concede o meno il download. La funzione ReadBinaryFile leggerà dal filesystem del server il file (che può essere anche in una posizione di rete, purchè accedibile e leggibile dall’utente con cui lavora il sito su IIS) e lo invierà al client con la funzione Response.BinaryWrite.

05/10/2007 Asp
No Comments

[hot-to] Proteggere l'accesso ad una cartella su Apache 2

[howto] Configurare OpenFire (ex wildfire) jabber-server su Debian Etch (4.0)

Lascia un commento

Devi essere connesso per inviare un commento.

Agosto 2026
L M M G V S D
 12
3456789
10111213141516
17181920212223
24252627282930
31  
« Gen    

Categorie

  • Access
  • Asp
  • Cyberoam
  • Dell
  • ESX / vmWare
  • Exchange
  • Exchange 2007
  • How-To
  • IIS
  • iPhone
  • Linux
  • Mac
  • Office 365
  • Outlook
  • plesk
  • Promox
  • Sophos XG
  • SQL Server
  • TeamSystem
  • Tips
  • Trend Micro
  • Uncategorized
  • Vb.NET
  • VB6
  • Windows 10
  • Windows 7
  • Windows SBS
  • Windows Server
  • Windows Vista
  • Windows XP
  • WSUS

How-To

  • Configure SMTP O365 Migration Using TLS 1.2 For SQL Database Mail
  • Debian anti-spam and anti-virus e-mail gateway
  • How to install Small Business Server 2003 in an existing Active Directory domain
  • Sophos XG Firewall and Firebox Branch Office VPN Integration Guide
  • Squid, SquidGard, NTLM Authentication con Samba 3.x su Debian Sarge
  • Troubleshoot high-CPU-usage issues in SQL Server

Utili

  • Chip Grafici per portatili – Benchmark
  • Il blog su Microsoft Access
  • Processori per portatili – Benchmark
  • Sophos Wireless: Wi-Fi Fundamentals
  • Zentyal – Linux Small Business Server

Meta

  • Accedi
  • Feed dei contenuti
  • Feed dei commenti
  • WordPress.org
Agosto 2026
L M M G V S D
 12
3456789
10111213141516
17181920212223
24252627282930
31  
« Gen    

Archivio

  • Gennaio 2026
  • Settembre 2025
  • Giugno 2024
  • Febbraio 2024
  • Settembre 2023
  • Agosto 2023
  • Novembre 2022
  • Agosto 2022
  • Marzo 2022
  • Ottobre 2021
  • Maggio 2020
  • Aprile 2020
  • Febbraio 2020
  • Settembre 2019
  • Luglio 2019
  • Giugno 2019
  • Marzo 2018
  • Novembre 2017
  • Settembre 2017
  • Aprile 2017
  • Dicembre 2016
  • Luglio 2016
  • Giugno 2016
  • Maggio 2016
  • Dicembre 2015
  • Novembre 2015
  • Settembre 2015
  • Luglio 2015
  • Maggio 2015
  • Dicembre 2013
  • Novembre 2013
  • Dicembre 2012
  • Novembre 2012
  • Ottobre 2012
  • Settembre 2012
  • Maggio 2012
  • Gennaio 2012
  • Novembre 2011
  • Maggio 2011
  • Ottobre 2010
  • Giugno 2010
  • Aprile 2010
  • Marzo 2010
  • Gennaio 2010
  • Dicembre 2009
  • Novembre 2009
  • Settembre 2009
  • Luglio 2009
  • Giugno 2009
  • Marzo 2009
  • Febbraio 2009
  • Novembre 2008
  • Settembre 2008
  • Luglio 2008
  • Giugno 2008
  • Maggio 2008
  • Aprile 2008
  • Gennaio 2008
  • Ottobre 2007
  • Settembre 2007
  • Agosto 2007
  • Maggio 2007

Categorie

  • Access (1)
  • Asp (3)
  • Cyberoam (2)
  • Dell (1)
  • ESX / vmWare (8)
  • Exchange (11)
  • Exchange 2007 (8)
  • How-To (32)
  • IIS (2)
  • iPhone (1)
  • Linux (1)
  • Mac (1)
  • Office 365 (3)
  • Outlook (6)
  • plesk (1)
  • Promox (1)
  • Sophos XG (4)
  • SQL Server (7)
  • TeamSystem (1)
  • Tips (40)
  • Trend Micro (3)
  • Uncategorized (1)
  • Vb.NET (1)
  • VB6 (2)
  • Windows 10 (3)
  • Windows 7 (3)
  • Windows SBS (3)
  • Windows Server (22)
  • Windows Vista (2)
  • Windows XP (3)
  • WSUS (2)

Meta

  • Accedi
  • Feed dei contenuti
  • Feed dei commenti
  • WordPress.org
Proudly powered by WordPress | Theme: Neblue by NEThemes.