Thursday, 16 October 2014

How do I create a internet proxy for an account that does not have internet access?

The development domain for my current client does not given its account internet access. Thi can be overcome in Powershell scripts as follows:

$user = "MyDomain\MyAccount"

$password = ConvertTo-SecureString –String "password" –AsPlainText -Force
$cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $user, $password

[System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred

but it becomes a problem is the current user credential is used do download files or if the proxy server blocks certain actions. A fantastic tool to resolve this problem is cntlm, which allows you create a local internet proxy.

The configuration (simplified) is as follows:

1. Download and install the software.
2. Set the username and domain in the .ini file. Remove the password setting
3. Type the Url of internet proxy.pac file in a browser and get proxy urls. Add these urls to the config file and remove the 'sample' entries.
4. Execute 'cntlm -M' and get the authentication type. Copy the Auth and Password to the configuration file.
5. Remove/uncheck the 'Automatic configuration' settings and update the proxy in the browser to point to localhost 3128 (which is configured as the listen port)

6. Close existing browsers and restart the windows service.

You should be good to go.

No comments:

Post a comment