Visual Basic (.NET)
The following code example is written in Visual Basic,for use with the .NET framework:
- ' set up the SecureKey call
 - ' define parts of the SecureKey request URL
 - Dim strLogiAppBaseURL As String = "http://<yourServer>/<LogiApp>"
 - Dim strUserName = "Bob"
 - Dim strUserRoles = "Admin"
 - Dim strUserRights = "Manager"
 - Dim strClientBrowserAddr As String = Request.UserHostAddress
 - ' build complete URL to Logi app
 - Dim strGetKeyURL As String = "/rdTemplate/rdGetSecureKey.aspx?Username=" & strUserName & "&Roles=" & strUserRoles & "&Rights=" & strUserRights & "&ClientBrowserAddress=" & strClientBrowserAddr
 - Dim strFinalURL As String = strLogiAppBaseURL & strGetKeyURL
 - ' define web request and response receiver
 - Dim webRequest As Net.HttpWebRequest
 - Dim webResponse As Net.WebResponse
 - webRequest = Net.HttpWebRequest.Create(strFinalURL)
 - ' attempt to make SecureKey call
 - Try
 - webResponse = webRequest.GetResponse()
 - Catch ex As Exception
 - ' if server has Basic or NTLM authentication, try to set credentials from the current process
 - If ex.Message.IndexOf("401") <> -1 Then
 - webRequest.Credentials = Net.CredentialCache.DefaultCredentials
 - webResponse = webRequest.GetResponse()
 - Else
 - Throw ex
 - End If
 - End Try
 - ' receive the response and return it as function result
 - Dim sr As New IO.StreamReader(webResponse.GetResponseStream())
 - getSecureKey = sr.ReadToEnd()