예제 #1
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 membershipType = request.Inputs["Direct Membership Type"].AsString();
            int    resourceID     = (int)request.Inputs["ResourceID"].AsUInt32();

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

            using (connection)
            {
                switch (membershipType)
                {
                case "System":
                    CMInterop.addDirectSCCMCollectionMemberMachine(connection, objID, resourceID);
                    break;

                case "User":
                    CMInterop.addDirectSCCMCollectionMemberUser(connection, objID, resourceID);
                    break;

                case "User Group":
                    CMInterop.addDirectSCCMCollectionMemberUserGroup(connection, objID, resourceID);
                    break;

                default:
                    response.LogErrorMessage("Invalid Direct Membership Type");
                    break;
                }

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

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Collections", ObjCount);
            }
        }