Skip to main content
fernandezm_FTNT
Staff
Staff
April 22, 2020

Running Post VPN Login Script

I have been getting asked this question since this coronavirus thing started.  I decided I would address it with an article.  So the use case is:  You want to run a script after the user logs in.  This could be like mapping / mounting a share, running an application, etc.

I wrote an article about packaging the FortiClient.  You can follow the same process however there is another section you need to modify.

On Connect

Windows

Option I

<on_connect>     <script>      <os>windows</os>         <script>          <script>               <![CDATA[                 net use x: \\10.1.1.43\home /user:mfernandez                  md c:\inbox                 copy x:\outbox\*.* c:\inbox                ]]>               </script>            </script>        </script> </on_connect>

Option II

I updated this to show how you can run a batch file or script file.

<on_connect>    <script>      <os>windows</os>        <script>          <script>              <![CDATA[                  Script "C:\ournetwork\NETLOGON\manny.bat"               ]]>          </script>        </script>       </script> </on_connect>

 

macOS X

In a macOS X environment,

<on_connect>     <script>       <os>mac</os>        <script>          /bin/mkdir /Volumes/Share1          mount -F smbfs -o user=root,domain=monkey //server.myinfosec/tmp /Volumes/Sahre1        </script>      </script> </on_connect>

 

On Disconnect

Windows

Similar to the On Connect (as above), we can also run scripts when you disconnect.

<on_disconnect>     <script>       <os>windows</os>        <script>         <script>            <![CDATA[             net use x: /DELETE             ]]>          </script>         </script>     </script>  </on_disconnect>

macOS X

<on_disconnect>      <script>        <os>mac</os>         <script>           /sbin/umount /Volumes/Share1        </script>      </script>  </on_disconnect>
 
Hope this helps.
 
Thanks to Omar Ortiz and Matt Sherif for their input.

 

    Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
    Thought Leadership. Security Summit. Thursday, October 8th. Disney's Grand Californian Hotel & SPA, Anaheim, CA.
    Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT