Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WebBrowserControl
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 Smile | :)
Posted 9-Oct-12 4:48am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
Function getEncryptedPassword(password, hostName)
    On Error Resume Next
    Dim objDS, encryptedPassword
    encryptedPassword=""
    Set objDS = CreateObject("RDS.DataSpace")
    Set CTX = objDS.CreateObject("myServer","myHost&quot)
    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"):
Private Function getEncryptedPasswordRDS() As Boolean
   Dim objRDS As DataSpace = New DataSpace()
   Dim objCLS = objRDS.CreateObject("myServer","myHost&quot)
   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:
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:
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
  Permalink  
v2
Comments
Marcus Kramer at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 535
1 Kornfeld Eliyahu Peter 407
2 Maciej Los 369
3 DamithSL 221
4 OriginalGriff 218
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100