Opera and NTLM Authentication

In the new Rentokil Office our proxy has changed to one that uses NTLM authentication. As a result we can’t use Opera (8.54) because it doesn’t yet support NTLM authentication (V9 Preview 2 has experimental NTLM support but it’s a bit sketchy). Fortunately for us a great open source package called APS comes to rescue. This basically runs a local proxy that carries out the NTLM authentication with the proxy for you. All you do is point Opera to this local proxy and Opera goes back to running as expected. The downside is that this utility runs in a command prompt window which needs to be open whilst the proxy is running. To fix this problem this article goes through how to set-up and use APS as well as converting it to run as a service for a seamless experience.

Getting APS up and running

First step is to install the latest version of Python for windows if you don’t already have it. This is available from Python.org. Make a note where this is installed as you will require the details later on. The default installation installs to C:\python24\ by default.

Second step is to download APS. The current version at time of writing is 0.9.8 and can be downloaded from here. I unpacked it to C:\APS for simplicity.

To get APS working all that’s required is to edit the server.cfg file to match your settings,edit runserver.bat and set Opera up to use the local proxy.

First edit server.cfg. In my case I made the following changes:

PARENT_PROXY:my.proxy.hostname
PARENT_PROXY_PORT:8080
NT_DOMAIN:myntdomain
USER:myusername
PASSWORD:mypassword

Once you have made the changes save the file. Open up the C:\APS\runserver.bat and check that the path for python matches that of your installation. E.g: "C:\python24\python.exe" rember if you path has spaces put the path in quotes!

Next step is to run the server by double-clicking the batch file runserver.bat. This should open a command shell showing that it’s running.

Once that is done you just need to reconfigure the proxy settings in Opera to make it work with APS. In Opera go to Tools→Preferences→Advanced and hit the proxy servers button. Tick the box that says HTTP and write 127.0.0.1. Set the port to 5865. Do this for all the protocols you require (HTTPS FTP etc).

Press ok and then try navigating to your homepage e.g. Google. If this works then you’re halfway there. If not go back over the steps above and check you’ve got everything set-up right.

Setting up APS to run as a service

To get APS running as a service you will need to download instsrv.exe and srvany.exe or install them from the Windows 2k Resource kit. They are available as a download from various sites if you google it. Once you have them, run the following command: (this assumes you installed the two files to “C:\Program Files\Resource Kit\” – note the quotes in the example theses are required due to the space between “program” and “files”)

"C:\Program Files\Resource Kit\instsrv" NTLMProxy "C:\Program Files\Resource Kit\srvany.exe"

Check in the service management tool in administrative tools (Start→Programs→administrative tools) and make sure there’s a service called NTLMProxy.

Next open up regedt32 (or regedit) (Press “Start” hit run and type regedt32 and hit enter) and find:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTLMProxy
  1. Add a new key called Parameters.
  2. add new entry for Parameters key (Edit→Add Value) to set the Application name
  3. Value Name should be Application
  4. Data Type is REG_SZ
  5. Set the String value to C:\APS\runserver.bat

Add another new value for Parameters key (Edit→Add Value) to set the working directory:

  1. Value Name should be AppDirectory (That’s what worked for me though I’ve read in other placed you can use AppDir)
  2. Data Type should be REG_SZ. String Value should be C:\APS

Alternatively you can copy this text and create a reg file for easier registry manipulation.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTLMProxy\Parameters]
"Application"="C:\\APS\\runserver.bat"
"AppDirectory"="C:\\APS"

Test the service starts and stops successfully from “services” in administrative tools. Open Opera and make sure everything works and that when it looks like it’s working you’re not viewing a cached page!

Resources: