Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binary passthrough of a file - with Windows Authentication 1

Status
Not open for further replies.

ESquared

Programmer
Dec 23, 2003
6,129
US
I already have working code that binary reads a file and returns it so I can have .asp links do things like return images (and do stuff like create an audit trail, enforce permissions, have different links for different groups of people, and so on).

The trick is that I need to do so using a particular domain user name. I can't run the IIS process itself using the domain user credentials for various reasons. (It's a non-person domain user that's okay for admin-type people to see the password in a source ASP, for example.)

XP has the "runas" command but that doesn't do me any good as far as I can see--there's no way to make that return what I need.

Before I go and create my own DLL that uses an alternate username/password and returns the binary contents of a file to my page, I wonder if anyone already knows how to use authentication with an ADO Stream reading from a windows file share. There IS no connection string to specify the username and password, as far as I can tell.

Or, if not ADO Stream, any method, with integrated authentication username & password specified, to get a file's binary contents into a variable. I can take the rest from there.

Here's some stripped-down working code for retrieving the file. Don't worry about hacking at the moment since I won't actually be using the filename later, but for testing now I just need the process working.

Code:
Dim sPath
Dim sFileName
sPath = Request.QueryString("path")
sFileName = Request.QueryString("filename")
If sPath = "" Then
	sPath = "Error-nodocumentinfo.png"	
End If

If sFileName = "" Then sFileName = Int(Rnd * 1000000000)

Dim oStream

Set oStream = Server.CreateObject("ADODB.Stream")
oStream.Type = 1 ' 1=binary 2=text
oStream.Open
oStream.LoadFromFile sPath
oStream.Position = 0 'may be unnecessary
Response.Clear
Response.AddHeader "Content-Disposition", "inline; filename=" & EscapeFileName(sFileName) & ".tif"
Response.AddHeader "Content-Length", oStream.Size
Response.BinaryWrite oStream.Read
Response.Flush
oStream.Close
Set oStream = Nothing

Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt.
 
Do you have a hint for me about how to create the EXE in a process using impersonated credentials? And how does the object communicate with the EXE to return the binary stream once it has been launched?

[COLOR=#aa88aa black]Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt.[/color]
 
I'll check at home tonight to see if I happened to save the source code. I remember that I named it ShapeShifter.DLL so it should be easy to find if I still have it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top