Click here to Skip to main content
15,887,304 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have been working on this problem for a week:

I have a class library that hosts a .net webbrowser control. This webbrowser control kicks off a vbscript which uses RDS technology to communicate with a database. Everthing works fine if I change my internet options to 'allow datasources accross domains'. However, this is not an option when deployment happens due to obvious security concerns. The problem then is getting the solution to work WITHOUT changing the global ie settings.

Things I have tried: *Adding the site that we access via RDS to our 'trusted sites' (didn't make a difference) *Researched the custom security manager for the webbrowser control *To find any other way to make this work besides the custom security manager since documentation seems lacking and it is tricky to implement

Where I need help: The custom security manager seems to be the way to go but I am having to pull from multiple posts and there seem to be gaps in how to implement it with c# in the .net framework. I am having some trouble getthing started here. I think if I had some footing of namespaces and project references that I might be able to use some other posts I have found which seem to provide the coding portion of the IInternetSecurityManager. There seems to be a need to override a base class, then inherit that from another base class, but I am having trouble there. So I need helping getting started if possible, and then be able to ask questions along the way after I get going.

What I would like to understand It seems the webbrowser control is not safe for scripting, so that it doesn't EXACTLY mimic IE. I wonder if there is a way to up the permissions on my class library, or register it, or give more permissions to the webbrowser control without having to implement the custom security manager?

HELP PLEASE. I'M DROWNING IN THIS :)
Posted

1 solution

Well, this isnt a solution to the above problem but a work around. I found a way to bring the RDS into vb.net and got that working successfully. Here is an example for othes who may be struggling:

vbscript:
VB
Function getEncryptedPassword(password, hostName)
    On Error Resume Next
    Dim objDS, encryptedPassword
    encryptedPassword=""
    Set objDS = CreateObject("RDS.DataSpace")
    Set CTX = objDS.CreateObject("myServer","myHost")
    Set objDS = Nothing

    encryptedPassword = CTX.EncryptString(1234567, password)
    If encryptedPassword = "" Then
        getEncryptedPassword = "nothing"
    Else
        getEncryptedPassword = encryptedPassword
    End If
End Function

translated to vb.net (must add reference to Microsoft Remote Data Services Library, then "Imports RDS"):
VB
Private Function getEncryptedPasswordRDS() As Boolean
   Dim objRDS As DataSpace = New DataSpace()
   Dim objCLS = objRDS.CreateObject("myServer","myHost")
   Dim encryptedPassword = objCLS.EncryptString(1234567, Me.password)

   If encryptedPassword = String.Empty Then           
       Return False
   Else
       Return True
   End If
End Function

----- TO TRANSLATE RECORDSETS -----------------------
vbscript:
VB
Function getIdToSubmit(invoiceId_producer,sessionId, dbId, hostName, customerId)
    On Error Resume Next
    Dim ObjDS, SQLStmnt, rs, ErrorText, RecordCount
    Set objDS = CreateObject("RDS.DataSpace")
    Set CTX = objDS.CreateObject("myServer","myHost" )
    Set objDS = Nothing

    SQLStmnt = "SELECT something1, something2 from someTable"
    Set rs = CTX.OpenRecordset(SQLStmnt, 3, 1, 0,sessionId, dbId, ErrorText)

           If rs.RecordCount > 0 Then
            Dim errormsg
            errormsg=Cstr(rs("something1"))

            If errormsg="" Then
                getIdToSubmit = CStr(rs("something2"))
            Else
                getIdToSubmit = Cstr(rs("something1"))
            End If

        Else
            getInvoiceIdToSubmit="There were no records returned."
        End If
End Function

vb.net translation:
VB
Private Function getIdToSubmit()
Dim objRDS As DataSpace = New DataSpace()
Dim objCLS = objRDS.CreateObject("myServer", "myHost")
Dim sqlStatement As String = "SELECT something1, something2 from someTable"
Dim rs = objCLS.OpenRecordset(sqlStatement, 3, 1, 0, _sessionId, dbId, ErrorText)

If rs.RecordCount > 0 Then
Dim errormsg
errormsg = rs.Fields("something1").Value.ToString()

If errormsg = "" Then
_myPrivateVariable= rs.Fields("something2").Value.ToString()
Else
 _myPrivateVariable = rs.Fields("something1").Value.ToString()
End If

Else
_myPrivateVariable="no records returned"
End If
 
Share this answer
 
v2
Comments
fjdiewornncalwe 9-Oct-12 17:39pm    
Thanks for providing the solution. +5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900