Thursday, September 15, 2011

Lazy deployment of Active Directory group policies over firefox

This scenario has been tested using frontmotion firefox msi installer available at http://www.frontmotion.com/
 
First of all we will download and install the add-on this link. We can see that in our firefox profile's extensions folder (%APPDATA%/Mozilla/Firefox/Profiles/<profile>/Extensions) there's a new one called gpofirefox@extensions.org, if we copy that folder into other Firefox profile's extension folder it will apply without any other touching.

Now we will:

  • Put the add-on in a shared folder available for all the clients (\\ARSGPDC\software)
  • Add the Firefox policy template to our server
  • Add visual script on login time to copy this add-on to all the available firefox profiles
First step, download the .adm file in our computer. Then, we will need to open the group policy management console available in the administrative tools and create a new policy, for example called Set.Firefox.GlobalPreferences. We go to Administrative Templates under Computer Configuration, and select Add Template from the All Tasks menu using the right click:


And now we can start to edit our group policies with the new available menu:


Now, we can add this example vbs script in the logon scripts under the User Configuration. As I'm not much of a developer, this script is quiet dirty and have defined variables that are not used. However, it does work :)


The VB script basically will:

  1. Create the local folder c:\software
  2. Copy the add-on from the shared folder \\ARSGPDC\Software\FrontMotion\gpofirefox@extensions.org
  3. Copy the extension to each available profile in the user's firefox folder
  4. Create a control point on c:\software\gpofirefox.txt to avoid copying over and over again.

Here's the shit:

Option Explicit

'Set variables
Dim filesys
DIM fso
Dim WshShell
Dim return
Dim oFSO
Dim WshSysEnv
Dim AppdataPath
Dim FoxProfilePath
Dim GPOPath
Dim ProfileFolder
Dim ExtensionsPath

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
AppdataPath = WshSysEnv("APPDATA")
FoxProfilePath = AppdataPath & "\Mozilla\Firefox\Profiles\"
GPOPath = "C:\software\gpofirefox@extensions.org"

'Set Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set filesys = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists("C:\software\gpofirefox.txt")) Then
        if oFSO.FolderExists(FoxProfilePath) Then
                        For Each ProfileFolder In oFSO.GetFolder(FoxProfilePath).Subfolders
                                        ExtensionsPath =ProfileFolder & "\extensions\"
                                        'MsgBox(ExtensionsPath)
                                        oFSO.Copyfolder "C:\software\gpofirefox*",ExtensionsPath,True
                        Next
        End If
        Else

        'first check for folder
        Dim objFSO
        Set objFSO= CreateObject("Scripting.FileSystemObject")                                                                                                                
        'Create the folder software                                                                                                                                           
        If Not objFSO.FolderExists("C:\software") then                                                                                                                        
        objFSO.CreateFolder("C:\software")
        End If
        'copy folder
        Set WshShell = CreateObject("WScript.Shell")
        WshShell.Run "c:\windows\system32\xcopy.exe /E /I /Y /H \\ARSGPDC\software\FrontMotion\gpofirefox@extensions.org c:\software\gpofirefox@extensions.org",0,true
        'Create control file
        Dim objFile
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.CreateTextFile("C:\software\gpofirefox.txt")
        if oFSO.FolderExists(FoxProfilePath) Then
                        For Each ProfileFolder In oFSO.GetFolder(FoxProfilePath).Subfolders
                                        ExtensionsPath =ProfileFolder & "\extensions\"
                                        'MsgBox(ExtensionsPath)
                                        oFSO.Copyfolder "C:\software\gpofirefox*",ExtensionsPath,True
                        Next
        End If
End If
'Exit Script


WScript.Quit()







No comments:

Post a Comment