http request and asp.net 2.0

A

Amar

I have a LDAP directory service located at a remote site. My middleware group
has provided me with a client certificate to authenticate me as a valid
client. I have installed that on my web server which is again located on a
different machine from my development machine. I have installed this client
certificate in the machine store along with the private key and asp.net user
has complete access to this. The middleware group have brought up a webapp to
act as an proxy to the LDAP server.
They say to access the application
1. i must make a http request to the server address
"https://webapp-dev.middleware.iad.x.edu:2322/dir-proxy/search".
2. I must provide my client certificate as a part of the SSL negotiation
3. To search for results you post a parameter called 'query'.
So to find my record, you would post query=(uupid=mark).

Please tell me how to do this. I have VS.NET 2005 and Microsoft.NET
framewwork 2.0.
Here is some code that i have written but it fails at the getresponse()
statement giving this error: "System.Net.WebException: Unable to connect to
the remote server ---> System.Net.Sockets.SocketException: A socket operation
was attempted to an unreachable host at
System.Net.Sockets.Socket.DoConnect(.......................ETC."

Dim searchstring As String = "(uupid=mark)"
Dim url As String =
"https://webapp-dev.middleware.iad.x.edu:2322/dir-proxy/search"
url = url & "?query=" & searchstring & "&content-type=text"
Dim req As HttpWebRequest = WebRequest.Create(url)
req.ContentType = "text/plain"
req.Method = "POST"

Dim store As X509Store
Dim cert As X509Certificate2
Dim x As X509Certificate2
Dim i As Integer = 0

Try
store = New X509Store(StoreName.My, StoreLocation.LocalMachine)
store.Open(OpenFlags.OpenExistingOnly)
For Each x In store.Certificates
If i = 0 Then
cert = x
End If
i = i + 1
Next

' I know that this is the correct client certificate
If (cert.SerialNumber <> 0) Then
req.ClientCertificates.Add(cert)
End If


'Get the data as an HttpWebResponse object
'******************************************
' This is the line which spits the error

Dim resp As HttpWebResponse = req.GetResponse()
'******************************************


'Convert the data into a string (assumes that you are requesting
text)
Dim sr As New StreamReader(resp.GetResponseStream())
Dim results As String = sr.ReadToEnd()
sr.Close()

Catch wex As WebException
'Something went awry in the HTTP request!
Response.Write(wex.ToString)
End Try


PLEASE HELP ME WITH THE CODE! I DONT EVEN KNOW IF THIS IS THE CORRECT WAY TO
ACHIEVING THE RESULTS. IF YOU THINK THIS CODE IS WRONG PLEASE PROVIDE ME WITH
AN EXAMPLE CODE SNIPPET.
THANKS IN ADVANCE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top