Hi Lars
It appears like I have this working. I add the following constructor and function to the reference.vb file that is created when you inport a wsdl to VS
Public Sub New(ByVal securityCookie As String)
MyBase.New()
Me.Url = "http://myhost.com/web.nsf/webservice"
_authCookieValue = securityCookie
End Sub
Protected Overrides Function GetWebRequest(ByVal Uri As Uri) As System.Net.WebRequest
Dim request As System.Net.WebRequest
request = MyBase.GetWebRequest(Uri)
request.Headers.Add("Cookie", "LtpaToken=" & _authCookieValue)
Return request
End Function
securityCookie in the constructor is the LtpaToken of the user or admin depending on how you want to do it. If I am running as a user other than the current user, I have a function that I use to generate an admin LtpaToken.
''' <SUMMARY>
''' Generates a Notes Security Cookie for the specified user/password combo
''' </SUMMARY>
''' <PARAM name="loginUrl">The url to post to. (ex http://mycompany.com/names.nsf?Login)</PARAM>
''' <PARAM name="cookieName">The name of the returning cookine. (ex LtpaToken)</PARAM>
''' <PARAM name="userName">The username of the account to log in with</PARAM>
''' <PARAM name="password">The password of the account to log in with</PARAM>
''' <RETURNS type="System.Web.HttpCookie">The cookie generated with the login credentials</RETURNS> Public Shared Function GenerateLtpaToken(ByVal loginUrl As String, ByVal cookieName As String, ByVal userName As String, ByVal password As String) As System.Web.HttpCookie
'Put user code to initialize the page here
Dim req As HttpWebRequest
Dim res As System.Net.HttpWebResponse
Dim sr As System.IO.StreamReader
Dim cookieContainer As New System.Net.CookieContainer
Dim securityToken As String
Dim postDataByte As Byte()
Dim postStream As Stream
Dim retCode As Boolean = False
Dim authorizationCookie As System.web.HttpCookie
Try
System.Net.ServicePointManager.Expect100Continue = False
req = CType(WebRequest.Create(loginUrl), HttpWebRequest)
req.CookieContainer = New CookieContainer
'enncode the form data string into a byte array '
postDataByte = System.Text.Encoding.ASCII.GetBytes("username=" & userName & "&password=" & password)
'indicate that you will be posting the data
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.ContentLength = postDataByte.Length
req.AllowAutoRedirect = False
'send the form
postStream = req.GetRequestStream()
postStream.Write(postDataByte, 0, postDataByte.Length)
' Close the post
postStream.Close()
res = CType(req.GetResponse(), HttpWebResponse)
res.Cookies = req.CookieContainer.GetCookies(req.RequestUri)
'read in the page
'sr = New System.IO.StreamReader(res.GetResponseStream())
' Get the specified cookie
If Not res.Cookies(cookieName) Is Nothing Then
'_AuthorizationCookie = CType(res.Cookies.Item(_authorizationCookieName), System.Web.HttpCookie)
Dim responseCookie As Cookie = res.Cookies.Item(cookieName)
Dim passThruCookie As New System.Web.HttpCookie(cookieName)
' Convert the cookie to an httpCookie
passThruCookie.Domain = responseCookie.Domain
passThruCookie.Value = responseCookie.Value
passThruCookie.Expires = responseCookie.Expires
passThruCookie.Path = responseCookie.Path
authorizationCookie = passThruCookie
End If
Return authorizationCookie
Catch ex As Exception
Throw ex
End Try
End Function