![]() |
|
|
Published: Wednesday, October 20, 1999 By Brian Atkinson
Protecting Everything dealt with the scenario of a programmer wanting to make PDF files of invoices available to specific customers via the web, but the programmer also wanted to keep customers from guessing URLs to view content that belongs to other customers. The question was, "How can i make this project viable and secure?" The article offers a viable and semi-secure solution, in that ASP and a database are used to provide a security check and then the Software Artisans SA-FileManager V1.1 component was used to distribute the file. It was also stated in the article that: "If someone were to guess the full URL of the PDF files, and typed that URL into their browser, they would be able to view the PDF files; it's not a security flaw, just the nature of the web." While this statement is true, there is a way to make this process even more secure, and eliminate the guessing process entirely by placing the PDF files in a non-web accessible folder and having an ActiveX DLL distribute the file(s) that theuser has requested and permitted to view. Microsoft Knowledge Base Article Q193998 explores the distribution of Binary files from a folder that is not available via the web. This is accomplished by using an ActiveX DLL. What this means is that customers will not be able to guess file locations by tampering with URLs, because the ActiveX DLL will have to provide the customer with only the content that he or she has requested and what he or she is allowed to view. This process can be used to protect and distribute files of any type, but we will follow the lead of the original article and use PDF files. To accomplish this process we will need an HTML page, an ASP page and an ActiveX DLL.
First create a simple
Next create
The example above is rough indeed, but the general idea is there. You would definitely want to include additional error-checking to ensure that the data being passed to the DLL is valid, and redirect mistakes to an appropriate error page. The database verification code found in the original "Protecting Everything" article was omitted in the ASP file above, because it would probably be better suited if it was located inside the ActiveX DLL. The final step is to create the ActiveX DLL. The ActiveX DLL code is fairly straightforward, and the code below is adapted directly from Microsoft's Knowledge Base Article Q193998.
2. Rename the project MyObject. 3. Rename the class module BinRead. 4. Enter this code:
5. Save the project and compile the DLL in the
at a command prompt.
Without going in too much detail, these three pieces of code will do the trick. The ActiveX DLL code above does not handle errors gracefully, in that the errHandler just stops the execution of the DLL. This will leave end-users with a blank screen. It is definitely a better idea to give users descriptive error messages, but again this is a little beyond the scope of this document. There are many articles available that go in to great detail on how to develop ActiveX DLLs, that one could use to expand on the Visual Basic code provided above. The article Createing a Server Component with Visual Basic is a great starting point.
Other Notable Points:
Although the folder
Attachments: DEFAULT.HTM in Text FormatPROCESS.ASP in Text Format
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||