writing files/directories using Com objects / with asp 
Author Message
 writing files/directories using Com objects / with asp

Ok,

i was previously wrong about something.

here's the scoop.

i have a VB com object (code below)
its an example.  all it does is create a directory on the computer.

create the .dll

run it in VB, works fine.

run it from asp code, no go.

..

based on some other hints, because the asp runs within the IUSR_machinename
account.

man, i thought this was the one of the big deals with COM... a dll that is
compiled , thus more secure...  i thought it would be able to do some stuff
on the server.

are you able to set properties under directories using IIS (or personal web
server) to be able to write to certain directories?  when i set up those
permissions, is it the IUSR_machinename account that is affected?

just trying to get the big picture...

thanks

..

sloan

VB / active x dll code
Project Name = TestProj
ClassName = WriteStuff

Option Explicit

Public intErrorNumber As Integer
Public strErrorDescription As String

Private Sub setErrors(lngValue As Long, strValue As String)
intErrorNumber = lngValue
strErrorDescription = strValue
End Sub

Private Sub clearErrors()
intErrorNumber = 0
strErrorDescription = ""
End Sub

Public Function createDirectory(strDirectory As String) As Boolean
clearErrors
On Error GoTo errorhandler:

RmDir strDirectory
MkDir strDirectory

createDirectory = True

Exit Function

errorhandler:
createDirectory = False
Select Case Err.Number
    Case 53, 76
        Resume Next
    Case 75
        'i think this is "directory already exists"
        intErrorNumber = 75
        strErrorDescription = "Error Number 75 raised on 'MKDIR' command for
'" & strDirectory & "'"
        Exit Function

    Case Else
        Call setErrors(Err.Number, "Error creating the directory:" &
strDirectory & vbCrLf & Err.Description)
        'Err.Raise intErrorNumber, "", strErrorDescription
End Select

End Function

VB code with reference to above .dll

Option Explicit

Private Sub Command1_Click()

Dim o As TestProj.writestuff
Set o = New TestProj.writestuff

If o.createDirectory("c:\tempa") = True Then
    MsgBox "'c:\tempa' was created."
Else
    MsgBox o.intErrorNumber & " " & o.strErrorDescription
End If

Set o = Nothing

End Sub

Asp Code

<%

Dim o
Set o = Server.CreateObject("TestProj.WriteStuff")

'Response.write "*" &  server.MapPath (".") & "*"

'Response.End

dim strDir
strDir = server.MapPath(".") & "\tempa"

If o.createDirectory(cstr(strDir)) = True Then
   response.write "'" & strDir & "' was created."
Else
    response.write o.intErrorNumber & "<br>" & o.strErrorDescription
End If

Set o = Nothing

%>



Mon, 05 Jan 2004 06:29:11 GMT  
 writing files/directories using Com objects / with asp
Hi Sloan,

when you set permissions in WINDOWS-EXPLORER specifically for the folder
where you want to create the new folder(s) below, you will set these
permissions for iusr_machine_name only. This means, that the iusr_xyz is
allowed to write below the folder which has the write permissions. That's
it. This is rather selective, I think. I am doing so for some uploading
stuffs in internet. No problems yet, as the folder still is not browsable.
However, there are permissions which are to set in IIS and others in
Windows, this might be a little bit confusing.

Henning



Sat, 10 Jan 2004 04:58:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. REPOST writing files/directories using Com objects / with asp

2. Com+ and writing cookies using the ASP Response object

3. Writing a file out to the response object using asp

4. COM-Object in ASP with COM-Object as parameter

5. COM-Object in ASP with COM-Object as Parameter

6. com object will not read registry when com object called from asp (vb works fine)

7. Need to Access ASP Session Objects from External COM Object

8. Using ASP to let a webuser write text file on the server

9. Writing ASP code in to file by using FileSystemObject

10. Returning an object with sub objects from vb component (COM) to ASP

11. Using AppGetStatus on IIS web directory or virtual directory object

12. Writing An OLE Object To File Using CDO and C++

 

 
Powered by phpBB® Forum Software