Monday, December 12, 2005

Post with VBScript Using NTLM, HTTPS

There are many ways to post data to a web site using VBScript. It becomes harder when you must use HTTPS. It gets downright silly when the script must use integrated authentication to the web server as the user running it.

Here are all my attempts to do just that, listing the last one that finally succeeded:

Function post(sText)
  dim http

  'This line sets the client XML object.
  'This method appears to require hard-coded credentials, or it will revert to anonymous.
  'It also needs the host and certificate names to match when using HTTPS.
  ' set http = Createobject("MSXML2.XMLHTTP")

  'This line sets the server XML object.
  'This method appears to require hard-coded credentials, or it will revert to anonymous.
  'It will do HTTPS if the host and certificate names don't match.
  ' set http = Createobject("MSXML2.ServerXMLHTTP")

  'These lines set the server XML object, version 4.
  'This method will pass NTLM credentials when the proxy configuration is set.
  'It also will do HTTPS if the host and certificate names don't match.
  'But most clients don't have MSXML4.
  ' set http = Createobject("MSXML2.ServerXMLHTTP.4.0")
  ' http.setProxy 2, "gkproxy", "gkweb"

  'These lines set the WinHTTPRequest object.
  'This method will pass NTLM credentials when the proxy configuration is set.
  'It also will do HTTPS if the host and certificate names don't match.
  'And most clients support it!
  set http = CreateObject("WinHttp.WinHttpRequest.5.1")
  http.SetAutoLogonPolicy 0

  http.Open "POST", "https://host/default.spx", false
  http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  http.send sText
  post = http.responseText
  Set http = nothing
End Function

Sunday, December 04, 2005

Remove Add/Modify FTP Locations

I've been locking down a new Terminal Server for Microsoft Office. It's fun playing God. You shall not save files here!

Anyway, I found a feature that could not be disabled with your typical policies. I did not want users trying to save to an FTP site. So I created an ADM file:

CLASS USER

CATEGORY "Microsoft Office 2003"
  KEYNAME "Software\Microsoft\Office\11.0\Common"
  POLICY "Remove 'Add/Modify FTP Locations' when you open or save a file"
    PART "Check to enforce setting on; uncheck to enforce setting off" CHECKBOX
     VALUENAME RemoveFTPLocationsFromLookIn
     VALUEON NUMERIC 1
     VALUEOFF NUMERIC 0
    END PART
  END POLICY
END CATEGORY


Save the text as an .ADM file and import it into your group policy. Be sure to set the filter to view templates that can't be fully managed. This means that the setting controlled by this ADM file is "tattooed" and remains when the policy is removed.