예제 #1
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String advID = request.Inputs["Existing Advertisement ID"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = CM2012Interop.getSCCMAdvertisement(connection, "AdvertisementID LIKE '" + advID + "'");
                CM2012Interop.deleteSCCMAdvertisement(connection, advID);

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Advertisements", ObjCount);
            }
        }
예제 #2
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String objID = request.Inputs["Child Collection ID"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = null;
                col = CMInterop.getSCCMParentCollection(connection, objID);

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col, connection));
                }
                response.Publish("Number of Collections", ObjCount);
            }
        }
예제 #3
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName      = settings.UserName;
            password      = settings.Password;
            domain        = settings.Domain;
            port          = settings.Port;
            virtualCenter = settings.VirtualCenter;

            VMName        = request.Inputs["Virtual Machine Name"].AsString();
            CapacityKB    = request.Inputs["CapacityKB"].AsString();
            Persistence   = request.Inputs["Persistence"].AsString();
            Datastore     = request.Inputs["Datastore"].AsString();
            StorageFormat = request.Inputs["StorageFormat"].AsString();
            HostUser      = request.Inputs["HostUser"].AsString();
            HostPassword  = request.Inputs["HostPassword"].AsString();
            GuestUser     = request.Inputs["GuestUser"].AsString();
            GuestPassword = request.Inputs["GuestPassword"].AsString();
            ToolsWaitSecs = request.Inputs["ToolsWaitSecs"].AsString();
            HelperVM      = request.Inputs["HelperVM"].AsString();
            Inflate       = request.Inputs["Inflate"].AsString();

            response.WithFiltering().PublishRange(runCommand());
        }
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String pkgID             = request.Inputs["Existing Package ID"].AsString();
            String pkgSourceFilePath = request.Inputs["New Package Source Path"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = CM2012Interop.configureSCCMPackageSourcePath(connection, pkgID, pkgSourceFilePath);

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Packages", ObjCount);
            }
        }
예제 #5
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String objID = request.Inputs["Package ID"].AsString();
            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = null;
                CM2012Interop.refreshSCCMPackageSource(connection, objID);
                col = CM2012Interop.getSCCMPackage(connection, "PackageID LIKE '" + objID + "'");

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Packages", ObjCount);
            }
        }
예제 #6
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String filter = request.Inputs["Filter"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = null;
                col = CMInterop.getSCCMTaskSequencePackage(connection, filter);

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Task Sequence Packages", ObjCount);
            }
        }
예제 #7
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String objID = request.Inputs["Package ID"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            try
            {
                String[] propertyNameChoices = CMInterop.getSCCMObjectPropertyNames(connection, "SMS_DriverPackage");
                foreach (String propertyName in propertyNameChoices)
                {
                    if ((request.Inputs.Contains(propertyName + " : Property Type")) && (request.Inputs.Contains(propertyName + " : Property Value")))
                    {
                        CMInterop.modifySCCMDriverPackage(connection, objID, request.Inputs[(propertyName + " : Property Type")].AsString(), propertyName, request.Inputs[(propertyName + " : Property Value")].AsString());
                    }
                }

                IResultObject col = null;
                col = CMInterop.getSCCMDriverPackage(connection, "PackageID LIKE '" + objID + "'");

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Packages", ObjCount);
            }
            finally
            {
                connection.Close();
                connection.Dispose();
            }
        }
예제 #8
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String objID         = request.Inputs["Collection ID"].AsString();
            String contentIDList = request.Inputs["Content ID List (CSV)"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = null;
                col = CMInterop.modifySCCMUpdatesAssignmentAddCIs(connection, objID, contentIDList);

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Updates Assignments", ObjCount);
            }
        }
예제 #9
0
파일: NewVM.cs 프로젝트: tryinmybest/scorch
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName      = settings.UserName;
            password      = settings.Password;
            domain        = settings.Domain;
            port          = settings.Port;
            virtualCenter = settings.VirtualCenter;

            Name                = request.Inputs["Name"].AsString();
            VMHost              = request.Inputs["VMHost"].AsString();
            VMFilePath          = request.Inputs["VMFilePath"].AsString();
            ResourcePool        = request.Inputs["ResourcePool"].AsString();
            VApp                = request.Inputs["VApp"].AsString();
            Datastore           = request.Inputs["Datastore"].AsString();
            DiskMB              = request.Inputs["DiskMB"].AsString();
            DiskPath            = request.Inputs["DiskPath"].AsString();
            DiskStorageFormat   = request.Inputs["DiskStorageFormat"].AsString();
            MemoryMB            = request.Inputs["MemoryMB"].AsString();
            NumCpu              = request.Inputs["NumCpu"].AsString();
            GuestId             = request.Inputs["GuestId"].AsString();
            AlternateGuestName  = request.Inputs["AlternateGuestName"].AsString();
            NetworkName         = request.Inputs["NetworkName"].AsString();
            HARestartPriority   = request.Inputs["HARestartPriority"].AsString();
            HAIsolationResponse = request.Inputs["HAIsolationResponse"].AsString();
            DRSAutomationLevel  = request.Inputs["DRSAutomationLevel"].AsString();
            VMSwapfilePolicy    = request.Inputs["VMSwapfilePolicy"].AsString();
            Description         = request.Inputs["Description"].AsString();
            OSCustomizationSpec = request.Inputs["OSCustomizationSpec"].AsString();
            VM       = request.Inputs["VM To Clone"].AsString();
            Template = request.Inputs["Template"].AsString();
            CD       = request.Inputs["CD"].AsString();
            floppy   = request.Inputs["floppy"].AsString();
            Folder   = request.Inputs["Folder"].AsString();

            response.WithFiltering().PublishRange(getVM());
        }
예제 #10
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String pkgID   = request.Inputs["Existing Package ID"].AsString();
            String prgName = request.Inputs["Existing Program Name"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = CM2012Interop.getSCCMProgram(connection, "PackageID LIKE '" + pkgID + " AND ProgramName LIKE '" + prgName + "'");
                CM2012Interop.deleteSCCMProgram(connection, pkgID, prgName);

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Programs", ObjCount);
            }
        }
예제 #11
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String colID = request.Inputs["Existing Collection ID"].AsString();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                CM2012Interop.refreshSCCMCollection(connection, colID);

                IResultObject col = CM2012Interop.getSCCMCollection(connection, "CollectionID='" + colID + "'");

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Collections", ObjCount);
            }
        }
예제 #12
0
 public void Execute(IActivityRequest request, IActivityResponse response)
 {
     forest = request.Inputs["ForestName"].AsString();
     response.WithFiltering().PublishRange(getChildDomains(forest));
 }
예제 #13
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            if (request.Inputs.Contains("Alternate Mailbox"))
            {
                alternateMailbox = request.Inputs["Alternate Mailbox"].AsString();
            }
            if (request.Inputs.Contains("Subject Line"))
            {
                subjectFilter = request.Inputs["Subject Line"].AsString();
            }
            if (request.Inputs.Contains("Subject Line Match Type"))
            {
                subjectFilterType = request.Inputs["Subject Line Match Type"].AsString();
            }
            if (request.Inputs.Contains("From Address"))
            {
                fromAddressFilter = request.Inputs["From Address"].AsString();
            }
            if (request.Inputs.Contains("From Address Match Type"))
            {
                fromAddressFilterType = request.Inputs["From Address Match Type"].AsString();
            }
            if (request.Inputs.Contains("Recieved Time Offset (Seconds)"))
            {
                recievedTimeOffset = Convert.ToInt32(request.Inputs["Recieved Time Offset (Seconds)"].AsString());
            }
            if (request.Inputs.Contains("Recieved Time Filter Type"))
            {
                recievedTimeOffsetFilterType = request.Inputs["Recieved Time Filter Type"].AsString();
            }

            folderName      = request.Inputs["Folder Name"].AsString();
            MonitorInterval = request.Inputs["Monitor Interval [Seconds]"].AsInt32();
            bodyFormat      = request.Inputs["Body Format"].AsString();
            readMailFilter  = request.Inputs["Read Mail Filter"].AsString();

            ExchangeService service = SetupExchangeConnection();

            FindFolder(service);
            PropertySet propSet = setupPropertySet();

            complete = false;

            while (!complete)
            {
                try
                {
                    SearchFilter.SearchFilterCollection filterCollection = setupFilterCollection();
                    FindItemsResults <Item>             findResults      = service.FindItems(folderID, filterCollection, new ItemView(Int32.MaxValue));

                    if (findResults.TotalCount > 0)
                    {
                        response.WithFiltering().PublishRange(processMail(findResults.Items, service, propSet));
                        complete = true;
                        break;
                    }
                }
                catch (Exception e) { response.ReportWarningEvent("Exchange Monitor Problem", String.Format("{0}\n{1}\n{2}", e.Message, e.Source, e.StackTrace)); service = SetupExchangeConnection(); }
                // Delay looping by Monitor Interval
                Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(MonitorInterval)));
            }
        }
예제 #14
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String folderType = request.Inputs["Folder Type"].AsString();
            String filter     = request.Inputs["Filter"].AsString();

            switch (folderType)
            {
            case "SMS_Package":
                filter += " AND ObjectType = 2";
                break;

            case "SMS_Advertisement":
                filter += " AND ObjectType = 3";
                break;

            case "SMS_Query":
                filter += " AND ObjectType = 7";
                break;

            case "SMS_Report":
                filter += " AND ObjectType = 8";
                break;

            case "SMS_MeteredProductRule":
                filter += " AND ObjectType = 9";
                break;

            case "SMS_ConfigurationItem":
                filter += " AND ObjectType = 11";
                break;

            case "SMS_OperatingSystemInstallPackage":
                filter += " AND ObjectType = 14";
                break;

            case "SMS_StateMigration":
                filter += " AND ObjectType = 17";
                break;

            case "SMS_ImagePackage":
                filter += " AND ObjectType = 18";
                break;

            case "SMS_BootImagePackage":
                filter += " AND ObjectType = 19";
                break;

            case "SMS_TaskSequencePackage":
                filter += " AND ObjectType = 20";
                break;

            case "SMS_DeviceSettingPackage":
                filter += " AND ObjectType = 21";
                break;

            case "SMS_DriverPackage":
                filter += " AND ObjectType = 23";
                break;

            case "SMS_Driver":
                filter += " AND ObjectType = 25";
                break;

            case "SMS_SoftwareUpdate":
                filter += " AND ObjectType = 1011";
                break;

            default:
                break;
            }

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = null;
                col = CMInterop.getSCCMObject(connection, "SMS_ObjectContainerNode", filter);

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Folders", ObjCount);
            }
        }
예제 #15
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            String userLDAPPath = CapitalizeLDAPPath(request.Inputs["User LDAP Path"].AsString());

            response.WithFiltering().PublishRange(getGroups(userLDAPPath));
        }
예제 #16
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            String databaseServer = credentials.DatabaseServer;
            String initialCatalog = credentials.InitialCatalog;

            String commandText = request.Inputs[ResourceStrings.sqlQuery].AsString();
            Dictionary <string, string> ParameterList = new Dictionary <string, string>();

            int timeout = -1;

            if (request.Inputs.Contains(ResourceStrings.Timeout))
            {
                timeout = request.Inputs[ResourceStrings.Timeout].AsInt32();
            }

            for (int i = 0; i < maxParameterNumber; i++)
            {
                if (request.Inputs.Contains(i.ToString() + " Parameter Name") && request.Inputs.Contains(i.ToString() + " Parameter Value"))
                {
                    string paramName  = request.Inputs[i.ToString() + " Parameter Name"].AsString();
                    string paramValue = request.Inputs[i.ToString() + " Parameter Value"].AsString();

                    ParameterList.Add(paramName, paramValue);
                }
            }

            SqlConnectionStringBuilder conString = new SqlConnectionStringBuilder();

            conString.IntegratedSecurity = true;
            conString.DataSource         = databaseServer;
            if (!initialCatalog.Equals(string.Empty))
            {
                conString.InitialCatalog = initialCatalog;
            }

            String        connectionString = conString.ToString();
            SqlConnection connection       = new SqlConnection(connectionString);

            try
            {
                SqlCommand command = new SqlCommand();
                command.Connection  = connection;
                command.CommandText = commandText;

                if (timeout > 0)
                {
                    command.CommandTimeout = timeout;
                }

                foreach (String paramName in ParameterList.Keys)
                {
                    command.Parameters.AddWithValue(paramName, ParameterList[paramName]);
                }

                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                response.WithFiltering().PublishRange(parseResults(reader));
            }
            catch { throw; }
            finally { connection.Close(); }


            response.Publish(ResourceStrings.DatabaseServer, databaseServer);
            response.Publish(ResourceStrings.Query, commandText);
            response.Publish(ResourceStrings.NumberOfRows, numberOfResults);
        }
예제 #17
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            String RunbookIdentifier = request.Inputs["Runbook Identifier"].AsString();
            String IdentifierType    = request.Inputs["Identifier Type"].AsString();
            String WaitForExit       = request.Inputs["Wait For Exit"].AsString();

            String RunbookServerName = String.Empty;

            String altUserName   = String.Empty;
            String altUserDomain = String.Empty;
            String altPassword   = String.Empty;

            if (request.Inputs.Contains("Alternate User Name") && request.Inputs.Contains("Alternate User Domain") && request.Inputs.Contains("Password"))
            {
                altPassword   = request.Inputs["Password"].AsString();
                altUserDomain = request.Inputs["Alternate User Domain"].AsString();
                altUserName   = request.Inputs["Alternate User Name"].AsString();
            }

            if (request.Inputs.Contains("Runbook Server Name"))
            {
                RunbookServerName = request.Inputs["Runbook Server Name"].AsString();
            }

            Dictionary <string, string> ParameterList = new Dictionary <string, string>();

            for (int i = 0; i < Credentials.MaxInputParameters; i++)
            {
                if (i < 10)
                {
                    if (request.Inputs.Contains("0" + i.ToString() + "_ParameterName") && request.Inputs.Contains("0" + i.ToString() + "_ParameterValue"))
                    {
                        string paramName  = request.Inputs["0" + i.ToString() + "_ParameterName"].AsString();
                        string paramValue = request.Inputs["0" + i.ToString() + "_ParameterValue"].AsString();

                        ParameterList.Add(paramName, paramValue);
                    }
                }
                else
                {
                    if (request.Inputs.Contains(i.ToString() + "_ParameterName") && request.Inputs.Contains(i.ToString() + "_ParameterValue"))
                    {
                        string paramName  = request.Inputs["0" + i.ToString() + "_ParameterName"].AsString();
                        string paramValue = request.Inputs["0" + i.ToString() + "_ParameterValue"].AsString();

                        ParameterList.Add(paramName, paramValue);
                    }
                }
            }

            OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL));

            if (altUserName.Equals(String.Empty))
            {
                sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain);
            }
            else
            {
                sco.Credentials = new NetworkCredential(altUserName, altPassword, altUserDomain);
            }
            sco.MergeOption = MergeOption.OverwriteChanges;

            Guid jobInstanceGUID = Guid.NewGuid();

            if (RunbookServerName.Equals(String.Empty))
            {
                switch (IdentifierType.ToUpper())
                {
                case "RUNBOOK PATH":
                    jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, ParameterList)).Id;
                    break;

                case "RUNBOOK GUID":
                    Guid runbookGUID = new Guid(RunbookIdentifier);
                    jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, runbookGUID, ParameterList)).Id;
                    break;

                default:
                    jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, ParameterList)).Id;
                    break;
                }
            }
            else
            {
                switch (IdentifierType.ToUpper())
                {
                case "RUNBOOK PATH":
                    jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, RunbookServerName, ParameterList)).Id;
                    break;

                case "RUNBOOK GUID":
                    Guid runbookGUID = new Guid(RunbookIdentifier);
                    jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, runbookGUID, RunbookServerName, ParameterList)).Id;
                    break;

                default:
                    jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, RunbookServerName, ParameterList)).Id;
                    break;
                }
            }

            if (WaitForExit.Equals("True"))
            {
                JobInstance ji = SCOrch.getJobDetails(sco, jobInstanceGUID);
                while (!(ji.job.Status.Equals("Completed") || ji.job.Status.Equals("Canceled") || ji.job.Status.Equals("Failed")))
                {
                    System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3));
                    ji = SCOrch.getJobDetails(sco, jobInstanceGUID);
                }
            }

            JobInstance jobInstance = SCOrch.getJobDetails(sco, jobInstanceGUID);

            response.WithFiltering().PublishRange(parseResults(jobInstance));
        }
예제 #18
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            String   Summary         = String.Empty;
            String   SummaryCriteria = String.Empty;
            DateTime MinCreationDate = DateTime.MinValue;
            DateTime MaxCreationDate = DateTime.MaxValue;

            foreach (IFilterCriteria filter in request.Filters)
            {
                switch (filter.Name)
                {
                case "CreationTime":
                    switch (filter.Relation)
                    {
                    case Relation.After:
                        MinCreationDate = Convert.ToDateTime(filter.Value.AsString());
                        break;

                    case Relation.Before:
                        MaxCreationDate = Convert.ToDateTime(filter.Value.AsString());
                        break;
                    }
                    break;

                case "Summary":
                    Summary = filter.Value.AsString();
                    switch (filter.Relation)
                    {
                    case Relation.Contains:
                        SummaryCriteria = "Contains";
                        break;

                    case Relation.EqualTo:
                        SummaryCriteria = "Equals";
                        break;
                    }
                    break;

                default:
                    break;
                }
            }



            OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL));

            sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain);
            sco.MergeOption = MergeOption.OverwriteChanges;

            Event[] eventArray = null;

            if (Summary.Equals(String.Empty))
            {
                eventArray = SCOrch.getOrchestartorEvents(sco, MinCreationDate, MaxCreationDate);
            }
            else
            {
                eventArray = SCOrch.getOrchestartorEvents(sco, MinCreationDate, MaxCreationDate, Summary, SummaryCriteria);
            }


            response.WithFiltering().PublishRange(parseResults(eventArray));
            response.Publish("Number of Events", numberOfEvents);
        }
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String objID = request.Inputs["Advertisement ID"].AsString();

            uint flags = 0x00000000;

            if (request.Inputs["IMMEDIATE"].AsBoolean())
            {
                flags ^= IMMEDIATE;
            }
            if (request.Inputs["ONSYSTEMSTARTUP"].AsBoolean())
            {
                flags ^= ONSYSTEMSTARTUP;
            }
            if (request.Inputs["ONUSERLOGON"].AsBoolean())
            {
                flags ^= ONUSERLOGON;
            }
            if (request.Inputs["ONUSERLOGOFF"].AsBoolean())
            {
                flags ^= ONUSERLOGOFF;
            }
            if (request.Inputs["WINDOWS_CE"].AsBoolean())
            {
                flags ^= WINDOWS_CE;
            }
            if (request.Inputs["DONOT_FALLBACK"].AsBoolean())
            {
                flags ^= DONOT_FALLBACK;
            }
            if (request.Inputs["ENABLE_TS_FROM_CD_AND_PXE"].AsBoolean())
            {
                flags ^= ENABLE_TS_FROM_CD_AND_PXE;
            }
            if (request.Inputs["OVERRIDE_SERVICE_WINDOWS"].AsBoolean())
            {
                flags ^= OVERRIDE_SERVICE_WINDOWS;
            }
            if (request.Inputs["REBOOT_OUTSIDE_OF_SERVICE_WINDOWS"].AsBoolean())
            {
                flags ^= REBOOT_OUTSIDE_OF_SERVICE_WINDOWS;
            }
            if (request.Inputs["WAKE_ON_LAN_ENABLED"].AsBoolean())
            {
                flags ^= WAKE_ON_LAN_ENABLED;
            }
            if (request.Inputs["SHOW_PROGRESS"].AsBoolean())
            {
                flags ^= SHOW_PROGRESS;
            }
            if (request.Inputs["NO_DISPLAY"].AsBoolean())
            {
                flags ^= NO_DISPLAY;
            }
            if (request.Inputs["ONSLOWNET"].AsBoolean())
            {
                flags ^= ONSLOWNET;
            }

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                String flagsString = Convert.ToString((int)flags);

                CM2012Interop.modifySCCMAdvertisement(connection, objID, "IntegerValue", "AdvertFlags", flagsString);
                IResultObject col = CM2012Interop.getSCCMAdvertisement(connection, "AdvertisementID LIKE '" + objID + "'");
                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Advertisements", ObjCount);
            }
        }
예제 #20
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            SearchField  = request.Inputs["Search Field"].AsString();
            SearchString = request.Inputs["Search String"].AsString();

            string alternateMailbox = string.Empty;

            if (request.Inputs.Contains("Alternate Mailbox"))
            {
                alternateMailbox = request.Inputs["Alternate Mailbox"].AsString();
            }

            ExchangeService service = new ExchangeService();

            switch (exchangeVersion)
            {
            case "Exchange2007_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                break;

            case "Exchange2010":
                service = new ExchangeService(ExchangeVersion.Exchange2010);
                break;

            case "Exchange2010_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                break;

            default:
                service = new ExchangeService();
                break;
            }

            service.Credentials = new WebCredentials(userName, password, domain);
            String AccountUrl = userName + "@" + domain;

            if (serviceURL.Equals("Autodiscover"))
            {
                service.AutodiscoverUrl(AccountUrl, (a) => { return(true); });
            }
            else
            {
                service.Url = new Uri(serviceURL);
            }

            if (!alternateMailbox.Equals(String.Empty))
            {
                service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, alternateMailbox);
            }

            SearchFilter       folderFilter;
            FindFoldersResults results;
            FolderView         folderView = new FolderView(int.MaxValue);

            folderView.PropertySet = new PropertySet(BasePropertySet.IdOnly);
            folderView.PropertySet.Add(FolderSchema.DisplayName);
            folderView.Traversal = FolderTraversal.Deep;

            switch (SearchField)
            {
            case "Folder Name":
                folderFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, SearchString);
                results      = service.FindFolders(WellKnownFolderName.MsgFolderRoot, folderFilter, folderView);
                response.WithFiltering().PublishRange(getFolderMatches(results, service));
                break;

            case "Folder Id":
                Folder folder = Folder.Bind(service, SearchString);
                response.WithFiltering().PublishRange(singleMatch(folder.DisplayName.ToString(), folder.Id.ToString(), folder.ParentFolderId.ToString()));
                break;

            default:
                folderFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, SearchString);
                results      = service.FindFolders(WellKnownFolderName.MsgFolderRoot, folderFilter, folderView);
                response.WithFiltering().PublishRange(getFolderMatches(results, service));
                break;
            }
        }
예제 #21
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            userEmailAddr = request.Inputs["Mailbox Email Address"].AsString();


            ExchangeService service = new ExchangeService();

            switch (exchangeVersion)
            {
            case "Exchange2007_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                break;

            case "Exchange2010":
                service = new ExchangeService(ExchangeVersion.Exchange2010);
                break;

            case "Exchange2010_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                break;

            default:
                service = new ExchangeService();
                break;
            }

            service.Credentials = new WebCredentials(userName, password, domain);
            String AccountUrl = userName + "@" + domain;

            if (serviceURL.Equals("Autodiscover"))
            {
                service.AutodiscoverUrl(userEmailAddr, (a) => { return(true); });
            }
            else
            {
                service.Url = new Uri(serviceURL);
            }

            OofSettings userOOFSettings = service.GetUserOofSettings(userEmailAddr);

            if (request.Inputs.Contains("External Audiance"))
            {
                ExternalAudience = request.Inputs["External Audiance"].AsString();
                switch (ExternalAudience)
                {
                case "All":
                    userOOFSettings.ExternalAudience = OofExternalAudience.All;
                    break;

                case "Known":
                    userOOFSettings.ExternalAudience = OofExternalAudience.Known;
                    break;

                case "None":
                    userOOFSettings.ExternalAudience = OofExternalAudience.None;
                    break;

                default:
                    response.LogWarningMessage("State must be one of the following: Disabled, Enabled, Scheduled");
                    break;
                }
            }
            if (request.Inputs.Contains("Start Time"))
            {
                try
                {
                    StartTime = Convert.ToDateTime(request.Inputs["Start Time"].AsString());
                    userOOFSettings.Duration.StartTime = StartTime;
                }
                catch
                {
                    response.LogWarningMessage("Start Time must be a valid Date Time: Entered Value was " + request.Inputs["Start Time"].AsString());
                }
            }
            if (request.Inputs.Contains("End Time"))
            {
                try
                {
                    EndTime = Convert.ToDateTime(request.Inputs["End Time"].AsString());
                    userOOFSettings.Duration.EndTime = EndTime;
                }
                catch
                {
                    response.LogWarningMessage("End Time must be a valid Date Time: Entered Value was " + request.Inputs["End Time"].AsString());
                }
            }
            if (request.Inputs.Contains("External Reply"))
            {
                ExternalReply = request.Inputs["External Reply"].AsString();
                userOOFSettings.ExternalReply = ExternalReply;
            }
            if (request.Inputs.Contains("Internal Reply"))
            {
                InternalReply = request.Inputs["Internal Reply"].AsString();
                userOOFSettings.InternalReply = InternalReply;
            }
            if (request.Inputs.Contains("State"))
            {
                State = request.Inputs["State"].AsString();
                switch (State)
                {
                case "Disabled":
                    userOOFSettings.State = OofState.Disabled;
                    break;

                case "Enabled":
                    userOOFSettings.State = OofState.Enabled;
                    break;

                case "Scheduled":
                    userOOFSettings.State = OofState.Scheduled;
                    break;

                default:
                    response.LogWarningMessage("State must be one of the following: Disabled, Enabled, Scheduled");
                    break;
                }
            }

            service.SetUserOofSettings(userEmailAddr, userOOFSettings);
            userOOFSettings = service.GetUserOofSettings(userEmailAddr);
            response.WithFiltering().PublishRange(getOOF(userOOFSettings));
        }
예제 #22
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String objID = request.Inputs["Advertisement ID"].AsString();

            uint flags = 0x00000000;

            if (request.Inputs["BATTERY_POWER"].AsBoolean())
            {
                flags ^= BATTERY_POWER;
            }
            if (request.Inputs["RUN_FROM_CD"].AsBoolean())
            {
                flags ^= RUN_FROM_CD;
            }
            if (request.Inputs["DOWNLOAD_FROM_CD"].AsBoolean())
            {
                flags ^= DOWNLOAD_FROM_CD;
            }
            if (request.Inputs["RUN_FROM_LOCAL_DISPPOINT"].AsBoolean())
            {
                flags ^= RUN_FROM_LOCAL_DISPPOINT;
            }
            if (request.Inputs["DOWNLOAD_FROM_LOCAL_DISPPOINT"].AsBoolean())
            {
                flags ^= DOWNLOAD_FROM_LOCAL_DISPPOINT;
            }
            if (request.Inputs["DONT_RUN_NO_LOCAL_DISPPOINT"].AsBoolean())
            {
                flags ^= DONT_RUN_NO_LOCAL_DISPPOINT;
            }
            if (request.Inputs["DOWNLOAD_FROM_REMOTE_DISPPOINT"].AsBoolean())
            {
                flags ^= DOWNLOAD_FROM_REMOTE_DISPPOINT;
            }
            if (request.Inputs["RUN_FROM_REMOTE_DISPPOINT"].AsBoolean())
            {
                flags ^= RUN_FROM_REMOTE_DISPPOINT;
            }
            if (request.Inputs["DOWNLOAD_ON_DEMAND_FROM_LOCAL_DP"].AsBoolean())
            {
                flags ^= DOWNLOAD_ON_DEMAND_FROM_LOCAL_DP;
            }
            if (request.Inputs["DOWNLOAD_ON_DEMAND_FROM_REMOTE_DP"].AsBoolean())
            {
                flags ^= DOWNLOAD_ON_DEMAND_FROM_REMOTE_DP;
            }
            if (request.Inputs["BALLOON_REMINDERS_REQUIRED"].AsBoolean())
            {
                flags ^= BALLOON_REMINDERS_REQUIRED;
            }
            if (request.Inputs["RERUN_ALWAYS"].AsBoolean())
            {
                flags ^= RERUN_ALWAYS;
            }
            if (request.Inputs["RERUN_NEVER"].AsBoolean())
            {
                flags ^= RERUN_NEVER;
            }
            if (request.Inputs["RERUN_IF_FAILED"].AsBoolean())
            {
                flags ^= RERUN_IF_FAILED;
            }
            if (request.Inputs["RERUN_IF_SUCCEEDED"].AsBoolean())
            {
                flags ^= RERUN_IF_SUCCEEDED;
            }

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                String flagsString = Convert.ToString((int)flags);

                CM2012Interop.modifySCCMAdvertisement(connection, objID, "IntegerValue", "RemoteClientFlags", flagsString);
                IResultObject col = CM2012Interop.getSCCMAdvertisement(connection, "AdvertisementID LIKE '" + objID + "'");
                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Advertisements", ObjCount);
            }
        }
예제 #23
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            emailID      = request.Inputs["Email ID"].AsString();
            SaveLocation = request.Inputs["Save Location"].AsString();

            string alternateMailbox = string.Empty;

            if (request.Inputs.Contains("Alternate Mailbox"))
            {
                alternateMailbox = request.Inputs["Alternate Mailbox"].AsString();
            }

            bool overwriteExistingAttachment = true;

            if (request.Inputs.Contains("Overwrite Existing Attachment"))
            {
                overwriteExistingAttachment = Convert.ToBoolean(request.Inputs["Overwrite Existing Attachment"].AsString());
            }

            string attachmentSaveName = string.Empty;

            if (request.Inputs.Contains("Attachment Save Name"))
            {
                attachmentSaveName = request.Inputs["Attachment Save Name"].AsString();
            }


            ExchangeService service = new ExchangeService();

            switch (exchangeVersion)
            {
            case "Exchange2007_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                break;

            case "Exchange2010":
                service = new ExchangeService(ExchangeVersion.Exchange2010);
                break;

            case "Exchange2010_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                break;

            default:
                service = new ExchangeService();
                break;
            }

            service.Credentials = new WebCredentials(userName, password, domain);
            String AccountUrl = userName + "@" + domain;

            if (serviceURL.Equals("Autodiscover"))
            {
                service.AutodiscoverUrl(AccountUrl, (a) => { return(true); });
            }
            else
            {
                service.Url = new Uri(serviceURL);
            }

            if (!alternateMailbox.Equals(String.Empty))
            {
                service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, alternateMailbox);
            }

            EmailMessage message = EmailMessage.Bind(service, emailID);

            if (message.HasAttachments)
            {
                response.Publish("Attachments Saved", message.Attachments.Count);
                response.WithFiltering().PublishRange(getAttachments(message, overwriteExistingAttachment, attachmentSaveName));
            }
            else
            {
                response.Publish("Attachments Saved", 0);
            }
        }
예제 #24
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            String groupDN = CapitalizeLDAPPath(request.Inputs["Group LDAP Path"].AsString());

            response.WithFiltering().PublishRange(getGroupMembers(groupDN));
        }
예제 #25
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            OuDn = CapitalizeLDAPPath(request.Inputs["Containing OU LDAP Path"].AsString());

            response.WithFiltering().PublishRange(getChildObjects(OuDn));
        }
예제 #26
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String objID   = request.Inputs["Package ID"].AsString();
            String prgName = request.Inputs["Program Name"].AsString();

            uint programFlags = 0x00000000;

            if (request.Inputs["UNATTENDED"].AsBoolean())
            {
                programFlags ^= UNATTENDED;
            }
            if (request.Inputs["USER CONTEXT"].AsBoolean())
            {
                programFlags ^= USERCONTEXT;
            }
            if (request.Inputs["EVERY USER"].AsBoolean())
            {
                programFlags ^= EVERYUSER;
            }
            if (request.Inputs["USE UNC PATH"].AsBoolean())
            {
                programFlags ^= USEUNCPATH;
            }
            if (request.Inputs["Authorized Dynamic Install"].AsBoolean())
            {
                programFlags ^= AUTHORIZED_DYNAMIC_INSTALL;
            }
            if (request.Inputs["USE CUSTOM PROGRESS MSG"].AsBoolean())
            {
                programFlags ^= USECUSTOMPROGRESSMSG;
            }
            if (request.Inputs["DEFAULT PROGRAM"].AsBoolean())
            {
                programFlags ^= DEFAULT_PROGRAM;
            }
            if (request.Inputs["DISABLE MOM ALERT ON RUNNING"].AsBoolean())
            {
                programFlags ^= DISABLEMOMALERTONRUNNING;
            }
            if (request.Inputs["MOM ALERT ON FAIL"].AsBoolean())
            {
                programFlags ^= MOMALERTONFAIL;
            }
            if (request.Inputs["RUN DEPENDANT ALWAYS"].AsBoolean())
            {
                programFlags ^= RUN_DEPENDANT_ALWAYS;
            }
            if (request.Inputs["WINDOWS CE"].AsBoolean())
            {
                programFlags ^= WINDOWS_CE;
            }
            if (request.Inputs["COUNTDOWN"].AsBoolean())
            {
                programFlags ^= COUNTDOWN;
            }
            if (request.Inputs["FORCE RERUN"].AsBoolean())
            {
                programFlags ^= FORCERERUN;
            }
            if (request.Inputs["DISABLED"].AsBoolean())
            {
                programFlags ^= DISABLED;
            }
            if (request.Inputs["ADMIN RIGHTS"].AsBoolean())
            {
                programFlags ^= ADMINRIGHTS;
            }
            if (request.Inputs["USE CUSTOM PROGRESS MSG"].AsBoolean())
            {
                programFlags ^= USECUSTOMPROGRESSMSG;
            }
            if (request.Inputs["NO USER LOGGED IN"].AsBoolean())
            {
                programFlags ^= NOUSERLOGGEDIN;
            }
            if (request.Inputs["OK TO QUIT"].AsBoolean())
            {
                programFlags ^= OKTOQUIT;
            }
            if (request.Inputs["OK TO REBOOT"].AsBoolean())
            {
                programFlags ^= OKTOREBOOT;
            }
            if (request.Inputs["PERSIST CONNECTION"].AsBoolean())
            {
                programFlags ^= PERSISTCONNECTION;
            }
            if (request.Inputs["RUN MINIMIZED"].AsBoolean())
            {
                programFlags ^= RUNMINIMIZED;
            }
            if (request.Inputs["RUN MAXIMIZED"].AsBoolean())
            {
                programFlags ^= RUNMAXIMIZED;
            }
            if (request.Inputs["HIDE WINDOW"].AsBoolean())
            {
                programFlags ^= HIDEWINDOW;
            }
            if (request.Inputs["OK TO LOGOFF"].AsBoolean())
            {
                programFlags ^= OKTOLOGOFF;
            }
            if (request.Inputs["RUN ACCOUNT"].AsBoolean())
            {
                programFlags ^= RUNACCOUNT;
            }
            if (request.Inputs["ANY PLATFORM"].AsBoolean())
            {
                programFlags ^= ANY_PLATFORM;
            }
            if (request.Inputs["STILL RUNNING"].AsBoolean())
            {
                programFlags ^= STILL_RUNNING;
            }
            if (request.Inputs["SUPPORT UNINSTALL"].AsBoolean())
            {
                programFlags ^= SUPPORT_UNINSTALL;
            }
            if (request.Inputs["Platform Not Supported"].AsBoolean())
            {
                programFlags ^= Platform_Not_Supported;
            }
            if (request.Inputs["SHOW IN ARP"].AsBoolean())
            {
                programFlags ^= SHOW_IN_ARP;
            }

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                String prgFlags = Convert.ToString((int)programFlags);

                CMInterop.modifySCCMProgram(connection, objID, prgName, "IntegerValue", "ProgramFlags", prgFlags);
                IResultObject col = CMInterop.getSCCMProgram(connection, "PackageID LIKE '" + objID + "' AND ProgramName LIKE '" + prgName + "'");
                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Programs", ObjCount);
            }
        }
예제 #27
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String folderName = request.Inputs["Folder Name"].AsString();
            String folderType = request.Inputs["Folder Type"].AsString();

            String searchFolder = String.Empty;
            String searchXML    = String.Empty;

            if (request.Inputs.Contains("Search Folder"))
            {
                searchFolder = request.Inputs["Search Folder"].AsString();
            }
            if (request.Inputs.Contains("Search Folder Query"))
            {
                searchXML = request.Inputs["Search Folder Query"].AsString();
            }

            int parentContainerID = request.Inputs["Parent Container ID"].AsInt32();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = null;

                switch (folderType)
                {
                case "SMS_Package":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_Package, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_Package, parentContainerID);
                    }
                    break;

                case "SMS_Advertisement":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_Advertisement, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_Advertisement, parentContainerID);
                    }
                    break;

                case "SMS_Query":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_Query, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_Query, parentContainerID);
                    }
                    break;

                case "SMS_Report":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_Report, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_Report, parentContainerID);
                    }
                    break;

                case "SMS_MeteredProductRule":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_MeteredProductRule, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_MeteredProductRule, parentContainerID);
                    }
                    break;

                case "SMS_ConfigurationItem":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_ConfigurationItem, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_ConfigurationItem, parentContainerID);
                    }
                    break;

                case "SMS_OperatingSystemInstallPackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_OperatingSystemInstallPackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_OperatingSystemInstallPackage, parentContainerID);
                    }
                    break;

                case "SMS_StateMigration":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_StateMigration, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_StateMigration, parentContainerID);
                    }
                    break;

                case "SMS_ImagePackage": if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_ImagePackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_ImagePackage, parentContainerID);
                    }
                    break;

                case "SMS_BootImagePackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_BootImagePackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_BootImagePackage, parentContainerID);
                    }
                    break;

                case "SMS_TaskSequencePackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_TaskSequencePackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_TaskSequencePackage, parentContainerID);
                    }
                    break;

                case "SMS_DeviceSettingPackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_DeviceSettingPackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_DeviceSettingPackage, parentContainerID);
                    }
                    break;

                case "SMS_DriverPackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_DriverPackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_DriverPackage, parentContainerID);
                    }
                    break;

                case "SMS_Driver":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_Driver, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_Driver, parentContainerID);
                    }
                    break;

                case "SMS_SoftwareUpdate":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CM2012Interop.createSearchFolder(connection, folderName, CM2012Interop.folderType.SMS_SoftwareUpdate, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CM2012Interop.createConsoleFolder(connection, folderName, CM2012Interop.folderType.SMS_SoftwareUpdate, parentContainerID);
                    }
                    break;

                default:
                    break;
                }

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Object Container Nodes", ObjCount);
            }
        }
예제 #28
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            folderName        = request.Inputs["Folder Name"].AsString();
            maxNumberOfEmails = request.Inputs["Max Number of Emails"].AsString();
            if (request.Inputs.Contains("Body Format"))
            {
                bodyFormat = request.Inputs["Body Format"].AsString();
            }
            if (request.Inputs.Contains("Read Mail Filter"))
            {
                readMailFilter = request.Inputs["Read Mail Filter"].AsString();
            }

            string alternateMailbox = string.Empty;

            if (request.Inputs.Contains("Alternate Mailbox"))
            {
                alternateMailbox = request.Inputs["Alternate Mailbox"].AsString();
            }

            try
            {
                Convert.ToInt32(maxNumberOfEmails);
            }
            catch
            {
                maxNumberOfEmails = "100";
            }

            ExchangeService service = new ExchangeService();

            switch (exchangeVersion)
            {
            case "Exchange2007_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                break;

            case "Exchange2010":
                service = new ExchangeService(ExchangeVersion.Exchange2010);
                break;

            case "Exchange2010_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                break;

            default:
                service = new ExchangeService();
                break;
            }

            service.Credentials = new WebCredentials(userName, password, domain);
            String AccountUrl = userName + "@" + domain;

            if (serviceURL.Equals("Autodiscover"))
            {
                service.AutodiscoverUrl(AccountUrl, (a) => { return(true); });
            }
            else
            {
                service.Url = new Uri(serviceURL);
            }

            if (!alternateMailbox.Equals(String.Empty))
            {
                service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, alternateMailbox);
            }

            SearchFilter.SearchFilterCollection FolderfilterCollection = new SearchFilter.SearchFilterCollection(LogicalOperator.And);
            SearchFilter.SearchFilterCollection EmailfilterCollection  = new SearchFilter.SearchFilterCollection(LogicalOperator.Or);

            FolderfilterCollection.Add(new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName));

            switch (readMailFilter)
            {
            case "All Email":
                EmailfilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, true));
                EmailfilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
                break;

            case "Unread Only":
                EmailfilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
                break;

            case "Read Only":
                EmailfilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, true));
                break;

            default:
                EmailfilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
                break;
            }

            FolderView view = new FolderView(int.MaxValue);

            view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
            view.PropertySet.Add(FolderSchema.DisplayName);
            view.Traversal = FolderTraversal.Deep;
            FindFoldersResults results = service.FindFolders(WellKnownFolderName.MsgFolderRoot, FolderfilterCollection, view);

            foreach (Folder folder in results)
            {
                folderID = folder.Id;
                break;
            }

            FindItemsResults <Item> findResults = service.FindItems(folderID, EmailfilterCollection, new ItemView(Convert.ToInt32(maxNumberOfEmails)));

            response.Publish("Number of Emails", findResults.Items.Count.ToString());
            response.WithFiltering().PublishRange(getMail(findResults, service));
        }
예제 #29
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            SearchField     = request.Inputs["Search Field"].AsString();
            SearchString    = request.Inputs["Search String"].AsString();
            SearchAlgorithm = request.Inputs["Search Algorithm"].AsString();
            folderName      = request.Inputs["Folder Name"].AsString();

            string alternateMailbox = string.Empty;

            if (request.Inputs.Contains("Alternate Mailbox"))
            {
                alternateMailbox = request.Inputs["Alternate Mailbox"].AsString();
            }

            FolderId folderID = new FolderId(WellKnownFolderName.Inbox);

            ExchangeService service = new ExchangeService();

            switch (exchangeVersion)
            {
            case "Exchange2007_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                break;

            case "Exchange2010":
                service = new ExchangeService(ExchangeVersion.Exchange2010);
                break;

            case "Exchange2010_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                break;

            default:
                service = new ExchangeService();
                break;
            }

            service.Credentials = new WebCredentials(userName, password, domain);
            String AccountUrl = userName + "@" + domain;

            if (serviceURL.Equals("Autodiscover"))
            {
                service.AutodiscoverUrl(AccountUrl, (a) => { return(true); });
            }
            else
            {
                service.Url = new Uri(serviceURL);
            }

            if (!alternateMailbox.Equals(String.Empty))
            {
                service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, alternateMailbox);
            }

            if (!folderName.Equals(String.Empty))
            {
                SearchFilter folderFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName);
                FolderView   folderView   = new FolderView(int.MaxValue);
                folderView.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                folderView.PropertySet.Add(FolderSchema.DisplayName);
                folderView.Traversal = FolderTraversal.Deep;
                FindFoldersResults results = service.FindFolders(WellKnownFolderName.MsgFolderRoot, folderFilter, folderView);

                foreach (Folder folder in results)
                {
                    folderID = folder.Id;
                    break;
                }
            }

            ItemView     emailView   = new ItemView(int.MaxValue);
            SearchFilter EmailFilter = new SearchFilter.ContainsSubstring(EmailMessageSchema.Subject, SearchString);

            switch (SearchField)
            {
            case "Subject":
                switch (SearchAlgorithm)
                {
                case "Equals":
                    EmailFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.Subject, SearchString);
                    break;

                case "Contains String":
                    EmailFilter = new SearchFilter.ContainsSubstring(EmailMessageSchema.Subject, SearchString);
                    break;

                case "Does Not Equal":
                    EmailFilter = new SearchFilter.IsNotEqualTo(EmailMessageSchema.Subject, SearchString);
                    break;
                }
                break;

            case "From":
                switch (SearchAlgorithm)
                {
                case "Equals":
                    EmailFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.From, SearchString);
                    break;

                case "Contains String":
                    EmailFilter = new SearchFilter.ContainsSubstring(EmailMessageSchema.From, SearchString);
                    break;

                case "Does Not Equal":
                    EmailFilter = new SearchFilter.IsNotEqualTo(EmailMessageSchema.From, SearchString);
                    break;
                }
                break;

            default:
                switch (SearchAlgorithm)
                {
                case "Equals":
                    EmailFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.Subject, SearchString);
                    break;

                case "Contains String":
                    EmailFilter = new SearchFilter.ContainsSubstring(EmailMessageSchema.Subject, SearchString);
                    break;

                case "Does Not Equal":
                    EmailFilter = new SearchFilter.IsNotEqualTo(EmailMessageSchema.Subject, SearchString);
                    break;
                }
                break;
            }

            FindItemsResults <Item> findResults = service.FindItems(folderID, EmailFilter, emailView);

            response.Publish("Number of Results", findResults.Items.Count.ToString());
            response.WithFiltering().PublishRange(getMail(findResults, service));
        }