Hi guys, I am busy trying to tidy up security in my coding today and while this coding works, its not really what I want.

Basically what this code does is it runs the function setpass which will set the username and password for IE Proxy server settings depending on the user logged on.

My problem is twofold. One I have to create a file for the proxy username and a separate file for the proxy password. The second problem is that I have to create a username file and password file for every proxy user. I currently only have about five proxy users (which will mean ten text files) as active directory groups are using one proxy username per group. For example students get the USA proxy username and staff get the China proxy username.

Is it possible to create ONE text file and have the script read that one file and allocate the username and password based on what active directory group they belong to? I am not sure if you can do that when you are reading normal text files.

The reason why I want the script to read the usernames and passwords from a text file is so that I can have one script that applies to all my clients and the clients have different usernames and passwords on site. The secondary consideration is that I want to ultimately encrypt the text file so that nobody snooping on the network can get the passwords.

Thanks Rob

 Code:
;==================================================================================================================
;  IE11 proxy authentication
;==================================================================================================================

setpass ("adminuser.txt", "adminpass.txt")


 Code:
;================================================================================================
;  Sets the default proxy username and password for IE for the logged on user
;================================================================================================

Function SetPass($PrintFile1, $PrintFile2)

$Handle = Freefilehandle ()
 if $handle > 0
    if Open ($handle, $ServerName + "\proxies\" + $Printfile1) = 0
    $proxyuser = Readline($handle)
	? $proxyuser
 ;  WHILE @ERROR = 0
        Close($handle)
   ELSE
   BEEP
   ? "Config file not opened, error code: [" + @ERROR + "]"
ENDIF
   
    if $handle > 0
    if Open ($handle, $ServerName + "\proxies\" + $Printfile2) = 0
    $proxypass = Readline($handle)
	 ? $proxypass
 ;  WHILE @ERROR = 0
        Close($handle)
   ELSE
   BEEP
   ? "Config file not opened, error code: [" + @ERROR + "]"
ENDIF
 
$shellcmd = 'cmdkey /generic: $ProxyServer /user: $proxyuser /pass: + $proxypass'
Shell $ShellCMD

EndFunction