How to do Proxy Authentication in SQL Server 2005 ?

The following example of Proxy Authentication in SQL Server 2005

Following function does proxy authentication.

Public Shared Function MyFunction(ByVal CardNumber As String) As SqlString

Dim myProxy As New WebProxy("myproxy ip address", portnum)
myProxy.Credentials = New NetworkCredential("myUserName", "myPassword", "myDomain")

Dim strURL As String = "myurl" & CardNumber
Dim Req As WebRequest

Req = WebRequest.Create(strURL)
Req.Proxy = myProxy

Dim Resp As WebResponse
Resp = Req.GetResponse

Dim netStream As StreamReader
netStream = New StreamReader(Resp.GetResponseStream)
Dim strData() As String = Split(netStream.ReadToEnd, "|")

Return New SqlString(strData(1))

End Function

By Perry    Popularity  (1218 Views)