This was definitely trial and error - lots of error so i'm putting this in for the next bastard who knows how to program but knows nothing about python.
I've set script security to 3 although that might be overkill.
On the server config I have:
[oconf=]script-security 3
client-connect 'c:\\python27\\python.exe c:\\openvpn\\scripts\\clientconnect.py'[/oconf]
The script is as follows (remember, this is expermintation):
import os
import sys
TempFile = 'None found'
CommonName = 'None found'
TrustedIP = 'None found'
TimeConnected = 'None found'
NumberOfArgsPassedIn = 0
TempFile = 'None Found'
WhatToWriteToFile = ''
try:
NumberOfArgsPassedIn = len(sys.argv)
TempFile = sys.argv[1] # this will be the temp file that the documentation talks about
CommonName = os.getenv('common_name','0') #environment variable set
TrustedIP = os.getenv('trusted_ip','0') #environment variable set
TimeConnected = os.getenv('time_ascii','0') #environment variable set
WhatToWriteToFile = 'New Connection' + '\r\n' + \
'Number of Args Passed In: ' + str(NumberOfArgsPassedIn) + '\r\n' + \
'Temp File: ' + TempFile + '\r\n' + \
'CommonName: ' + CommonName + '\r\n' + \
'Trusted IP of Client: ' + TrustedIP + '\r\n' + \
'Time Connected: ' + TimeConnected
except Exception1, Argument:
WhatToWriteToFile = Argument
finally:
save_file_path = "c:\OpenVPN\ConnectionLog.txt"
testfile = open(save_file_path,"a")
testfile.write(WhatToWriteToFile)
testfile.close()
sys.exit(0)