0

I'm writing a VBA code to check for access for my Database: The code check if I have privilege to connect to a web server so it grants me access to the DB.

Function WebVer(ByVal StrUserName As String, ByVal StrPassword As String) As String

   Dim Access As String
   Dim objHTTP As Object
   Dim URL As String
   Dim Response As String


   Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
   URL = "http://myweb.com/authenticator?app=WebDNC_server&service=authenticate&userid=" & StrUserName & "&password=" & StrPassword    
   objHTTP.Open "GET", URL, False
   objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
   objHTTP.Send ("")
   LDAPResponse = UCase(objHTTP.responseText)

    If Response Like "*BAD*" Then
        WebVer= "BAD PASSWORD"
    ElseIf Response Like "*PASS*" Then
        WebVer= "PASS"
    ElseIf Response Like "*USERID*" Then
        WebVer= "USERID Not RECOGNIZED"
    Else
        WebVer= "CONNECTION ERROR"
    End If



End Function

Now everything is going fine except that if the user uses special characters in the password it returns BAD Password. I think there is a problem on how VBA handles Special characters but still do not know how to solve it. Any help would be appreciated.

Erik A
  • 31,639
  • 12
  • 42
  • 67
user2320492
  • 151
  • 1
  • 14

1 Answers1

1

I'm pretty sure you have to URL-encode the username and password.

See: How can I URL encode a string in Excel VBA?

Community
  • 1
  • 1
kismert
  • 1,662
  • 1
  • 13
  • 19