I want to connect automatically. Now I must enter the credential manually :(
I don't remember exactly how we did the integration but I remember that AnyConnect is a pain. There is no way to provide the username and password to the command line. Maybe we could do something with a macro?
David Hervieux
I think in the future cisco will only provide the AnyConnect client, because there are no update for the cisco VPN client any more.
So I think the AnyConnect Client AddOn must be better in future :(
I will try the Macro-workaround
We will try to improve it and find a workaround
David Hervieux
Any news on this, having the same issue, need to supply the password and that is a pain
Regards,
Ingvar Orn Ingolfsson
System Engineer
Axdata AS - Norway
Nothing new for now. Have you tried the Macro?
David Hervieux
Which macro, if I can find a solution to this then it would be just great. We are still in the process of deciting if we should buy the RDMS Ent and if I can solve this then I´m atleast 10 steps closer to buying since VPN has always been a pain for uss here.
Regards,
Ingvar Orn Ingolfsson
System Engineer
Axdata AS - Norway
In the event tab page, you can configure a macro to be executed after the connection
David Hervieux
I had tried this before but it only runs after the rdp connection is on, now I have written a ps script that does this for me and I'm starting it from the script section in before connection in events.
But have not figured out how to take the username and password that is in credential repository and use that for the ps script, so now I have the password and username in the script.
Regards,
Ingvar Orn Ingolfsson
System Engineer
Axdata AS - Norway
I have the following parameters in the PS script now.
-VPNHost
-Username
-Password
the argument I'm trying to use is -VPNhost vpn.domain.com -Username $USERNAME$ -Password $PASSWORD$
This is working great with the host and the username put I just receive the password in the script as $PASSWORD$
If I use the same arguments and just type in the password then it's working.
So what am I doing wrong here, is it not possible to get the password from the credential depository or is my argument just simple wrong?
Regards,
Ingvar Orn Ingolfsson
System Engineer
Axdata AS - Norway
Are you sure that Anyconnect support the password parameter? Do you mean type the password in AnyConnect or hard code the password in the script?
David Hervieux
Hi again, just to clarify what I'm doing now.
I have written a powershell script that takes in 3 parameters who are -vpnhost, -username and -password. This is sent from RDM as argument.
This is the argument I send now: -VPNhost vpn.domain.com -Username $USERNAME$ -Password $PASSWORD$
And the script then receives the host and username correctly as from the credential repository (prompts to choice which cred) but the password is sent as $PASSWORD$.
But then I change the argument to: -VPNhost vpn.domain.com -Username $USERNAME$ -Password thepassword
Then everything works like a charm.
So my problem is that it seems like the RDM is not fetching the password like the username from the repository, any brilliant ideas here ;)
This is the powershell script if you like to try this.
<code>
#Parameters for the script
param (
[string]$VPNHost = $(throw "-VPNHost is required."),
[string]$username = $(throw "-username is required."),
[string]$Password = $(throw "-password is required.")
)
#Please check if file exists on following paths
[string]$vpncliAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe'
[string]$vpnuiAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe'
#Get the system forms assembly
Add-Type -AssemblyName System.Windows.Forms -ErrorAction Stop
#Set foreground window function
#This function is called in VPNConnect
Add-Type @'
using System;
using System.Runtime.InteropServices;
public class Win {
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
}
'@ -ErrorAction Stop
#quickly start VPN
#This function is called later in the code
Function VPNConnect()
{
Start-Process -FilePath $vpncliAbsolutePath -ArgumentList "connect $VPNHost"
$counter = 0; $h = 0;
while($counter++ -lt 1000 -and $h -eq 0)
{
sleep -m 20
$h = (Get-Process vpncli).MainWindowHandle
}
#if it takes more than 20 seconds then display message
if($h -eq 0){echo "Could not start VPNUI it takes too long."}
else{[void] [Win]::SetForegroundWindow($h)}
}
#Terminate all vpnui processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpnui")
{$Id = $_.Id; Stop-Process $Id; echo "Process vpnui with id: $Id was stopped"}}
#Terminate all vpncli processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpncli")
{$Id = $_.Id; Stop-Process $Id; echo "Process vpncli with id: $Id was stopped"}}
#Disconnect from VPN
echo "Trying to terminate remaining vpn connections"
start-Process -FilePath $vpncliAbsolutePath -ArgumentList 'disconnect' -wait
#Connect to VPN
###Err seeking, display the arguments the script got from RDM
echo "Connecting to VPN address '$VPNHost' as user '$username' with password '$Password'."
VPNConnect
#Write login and password, sends first one ENTER to accept protocol answer.
[System.Windows.Forms.SendKeys]::SendWait("{Enter}")
[System.Windows.Forms.SendKeys]::SendWait("$username{Enter}")
[System.Windows.Forms.SendKeys]::SendWait("$Password{Enter}")
#Start vpnui
start-Process -FilePath $vpnuiAbsolutePath
##Err seeking, Wait for keydown
echo "Press any key to continue ..."
try{$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")}catch{}
</code>
Thanks for the patient and a great service.
Regards,
Ingvar Orn Ingolfsson
System Engineer
Axdata AS - Norway
Hi,
Great script. I think that the only thing missing is in the Advanced tab page. Make sure that Allow Password in variable is checked
David Hervieux
Thanks for the script, it works awsome!
Hi
thanks for the script
I am having troubles getting th password to work
I keep getting
username:[admin] mypassword
Password:_
I doesnt seem to put the password in the right place.
I have tried the mypassword in arguments but it doesn't help
could someone help me?
Hey guys!
this anyconnect really is a pain in the A..!
i've seen several forum posts about this addon, but none seem to work. I can get the command line to work but do not know how to translate this to RDM. which would make me king of the depertment :-)
so here is what I have using the command line (something others may have discovered as well)
vpncli.exe -s connect <hostname> <c:\temp\answer.txt
in the answer.txt are the username and the password divided only using a new line, like so;
username
password
you cannot replace the txt file with parameters $username$ $password$. it don't work
So have some coffee and make it work!
Hi ReDxXx,
This seems to be a nice workaround. I will take a coffee and give it a try :) We are leaving for TechEd soon but you can expect an update as soon as we returned.
David Hervieux
I'm about to buy Remote Desktop Manager or something similar to our employers in my company. Most of our customer use Cisco AnyConnect and therefor I'm looking for a program to handle this too. We have about 1000 customer and about 1500 Devices to control. Are there any chance that connection with AnnyConnect together with Username and Password will be fixed in short time. RDM is a fine manager and got what we are looking for, except the AnyConnection VPN problem.
Best regards, Jan
Hi, you can use the script above but you will need to go into the advance tap and change so the client allows to send the password to the script.
Also then go into File-Templates select Session and then Other, double click Powershell
In the new window that pops up go into Advanced and click Allow Password in variable (second line from top number two), now click OK.
All script now in the future will use this template and you will be a happy little fellow to skip this step every time in the future.
Regards, Ingvar
Regards,
Ingvar Orn Ingolfsson
System Engineer
Axdata AS - Norway
Hi,
I need help to test an update. We don't have a Cisco VPN to test here.
I updated the Cisco AnyConnect add-on to support auto-login with the ReDxXx method.¸
First if you let the user name and password empty it should be the same behaviour that you know.
With user name and password it should create a temporary file to provide credentials to the VPN.
Of course, if you try the new method you must not use any other scripts or macros.
You just have to replace the VPNAddon.dll with the new one.
%LocalAppData%\Devolutions\RemoteDesktopManager
Please make a backup of the old dll because no real tests have been made.
Waiting for your feedback:)
Best regards,
André Sanscartier
I have just tested with the new dll both with my credentials set to default and embedded and there is no change. Still times out without connecting. It is like there is not enough time for RDM to enter the credentials before the window closes.
edited by wgentry on 5/22/2014
Hi Andre,
2bad for now but keep it up!
Hi again, and thanks #ingvarorn.
One of my tester, came up with another issue, as I would like to ask about.
Some of our customer are using Cisco VPN + SMS Passcode to make the VPN Connection. The SMS Passcode is an static code, but I can't find the place to add this SMS Passcode in the VPN Connection tab i RDM.
It might not be possible or what ?
Best regards Jan
Hi,
I don't think it's possible to send the SMS code to the command line. We already have issue just with the username and password.
David Hervieux
I think I have a workaround...
'Check is allready running
Dim objOldProcessCLI As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName("vpncli").FirstOrDefault
If Not objOldProcessCLI Is Nothing Then
objOldProcessCLI.Kill()
System.Threading.Thread.Sleep(1500)
End If
Dim objOldProcessGUI As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName("vpnui").FirstOrDefault
If Not objOldProcessGUI Is Nothing Then
objOldProcessGUI.Kill()
System.Threading.Thread.Sleep(1500)
End If
Dim objProcess As New System.Diagnostics.Process
objProcess.StartInfo.FileName = installationPath
objProcess.StartInfo.Arguments = processArgumentBuilder.ToString()
objProcess.StartInfo.WindowStyle = Diagnostics.ProcessWindowStyle.Normal
objProcess.Start() '(installationPath, processArgumentBuilder.ToString())
If (ciscoAnyConnectVPNConfiguration.WaitDelay > 0) Then
AddOnServices.ShowWaitVPN(ciscoAnyConnectVPNConfiguration.WaitDelay * 1000)
SetActiveWindow(objProcess.MainWindowHandle)
Else
SetActiveWindow(objProcess.MainWindowHandle)
End If
System.Windows.Forms.SendKeys.SendWait(ciscoAnyConnectVPNConfiguration.UserName)
SetActiveWindow(objProcess.MainWindowHandle)
System.Windows.Forms.SendKeys.SendWait("{ENTER}")
System.Threading.Thread.Sleep(1500)
SetActiveWindow(objProcess.MainWindowHandle)
System.Windows.Forms.SendKeys.SendWait(ciscoAnyConnectVPNConfiguration.Password)
SetActiveWindow(objProcess.MainWindowHandle)
System.Windows.Forms.SendKeys.SendWait("{ENTER}")
objProcess.WaitForExit(ciscoAnyConnectVPNConfiguration.WaitDelay * 1000)
And of course, at the top of the CiscoAnyConnectVPNAddOn class
Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As Integer) As Integer