/// <summary>
        /// Called when a step of this type is executed in the workflow.
        /// </summary>
        /// <param name="JobID">ID of the job being executed</param>
        /// <param name="StepID">ID of the step being executed</param>
        /// <param name="argv">Array of arguments passed into the step's execution</param>
        /// <param name="ipFeedback">Feedback object to return status messages and files</param>
        /// <returns>Return code of execution for workflow path traversal</returns>
        public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback)
        {
            System.Diagnostics.Debug.Assert(m_ipDatabase != null);

            if (!ConfigurationCache.IsInitialized)
            {
                ConfigurationCache.InitializeCache(m_ipDatabase);
            }

            IJTXJobManager jobMan      = m_ipDatabase.JobManager;
            IJTXJob2       m_ParentJob = (IJTXJob2)jobMan.GetJob(JobID);

            if (!GetInputParams(argv))
            {
                return(0);
            }

            return(CreateJobs(m_ParentJob));
        }
        static void Main(string[] args)
        {
            // Convert the arguments to objects
            object[] argv = new object[args.Length];
            for (int i = 0; i < args.Length; i++)
            {
                argv[i] = args[i];
            }

            // Check if they want to display the usage message
            string tmpOut;

            if (StepUtilities.GetArgument(ref argv, "h", true, out tmpOut) || StepUtilities.GetArgument(ref argv, "?", true, out tmpOut))
            {
                PrintUsageMessage();
                return;
            }

            if (CheckoutLicense())
            {
                try
                {
                    IJTXDatabaseManager2 dbMgr = new JTXDatabaseManagerClass() as IJTXDatabaseManager2;
                    IJTXDatabase         ipDB  = null;
                    if (StepUtilities.GetArgument(ref argv, argNames[0], true, out tmpOut))
                    {
                        // Database was specified
                        try
                        {
                            ipDB = dbMgr.GetDatabase(tmpOut);
                        }
                        catch (COMException)
                        {
                            Console.WriteLine("{0} is not a valid Workflow Manager database alias", tmpOut);
                        }
                        Console.WriteLine("Using database {0}", tmpOut);
                    }
                    else
                    {
                        // Use the default database
                        Console.WriteLine("Using default database");
                        ipDB = dbMgr.GetActiveDatabase(false);
                    }

                    // Get the domain. If one is not specified, use the current domain
                    string strDomain;
                    if (StepUtilities.GetArgument(ref argv, argNames[1], true, out tmpOut))
                    {
                        strDomain = tmpOut;
                    }
                    else
                    {
                        strDomain = Environment.UserDomainName;
                    }

                    // Get the username
                    string strUsername = "";
                    if (StepUtilities.GetArgument(ref argv, argNames[2], true, out tmpOut))
                    {
                        strUsername = tmpOut;
                    }

                    // Get the password
                    string strPassword = "";
                    if (strUsername != "" && StepUtilities.GetArgument(ref argv, argNames[3], true, out tmpOut))
                    {
                        strPassword = tmpOut;
                    }

                    // Get the userGroup.  If one is not specified, check the registry for the value the UI stored
                    string strUserGroup;
                    if (StepUtilities.GetArgument(ref argv, argNames[4], true, out tmpOut))
                    {
                        strUserGroup = tmpOut;
                    }
                    else
                    {
                        strUserGroup = GetGroupFromReg("UserADGroup");
                    }

                    // Get the groupGroup.  If one is not specified, check the registry for the value the UI stored
                    string strGroupGroup;
                    if (StepUtilities.GetArgument(ref argv, argNames[5], true, out tmpOut))
                    {
                        strGroupGroup = tmpOut;
                    }
                    else
                    {
                        strGroupGroup = GetGroupFromReg("GroupADGroup");
                    }

                    if (String.IsNullOrEmpty(strUserGroup) || String.IsNullOrEmpty(strGroupGroup))
                    {
                        Console.WriteLine("Error: Empty userGroup or groupGroup");
                        return;
                    }

                    ConfigurationCache.InitializeCache(ipDB);

                    // Synchronize
                    int groupCount, userCount;
                    ActiveDirectoryHelper.SyncronizeJTXDatabaseWithActiveDirectory(ipDB, strDomain, strUsername, strPassword,
                                                                                   strUserGroup, strGroupGroup, out groupCount, out userCount);

                    Console.WriteLine("Successfully imported {0} users in {1} groups", userCount, groupCount);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed with error: " + e.Message + e.StackTrace);
                }
                finally
                {
                    CheckinLicense();
                }
            }
            else
            {
                Console.WriteLine("Could not checkout license... exiting");
            }
        }