Esempio n. 1
0
        public List <user> GetDiscoveredUsers(string secret)
        {
            //' Construct users list
            var userList = new List <user>();

            //' Validate secret key
            if (secret == secretKey)
            {
                //' Connect to SMS Provider
                smsProvider          smsProvider = new smsProvider();
                WqlConnectionManager connection  = smsProvider.Connect(siteServer);

                //' Query for all discovered users
                string        query        = "SELECT * FROM SMS_R_User";
                IResultObject queryResults = connection.QueryProcessor.ExecuteQuery(query);

                if (queryResults != null)
                {
                    foreach (IResultObject queryResult in queryResults)
                    {
                        //' Collect property values from instance
                        string fullUserName      = queryResult["FullUserName"].StringValue;
                        string uniqueUserName    = queryResult["UniqueUserName"].StringValue;
                        string userPrincipalName = queryResult["UserPrincipalName"].StringValue;
                        string userName          = queryResult["UserName"].StringValue;
                        string resourceId        = queryResult["ResourceId"].StringValue;
                        string windowsNTDomain   = queryResult["WindowsNTDomain"].StringValue;
                        string fullDomainName    = queryResult["FullDomainName"].StringValue;

                        //' Construct new user object
                        user user = new user();
                        user.fullUserName      = fullUserName;
                        user.uniqueUserName    = uniqueUserName;
                        user.userPrincipalName = userPrincipalName;
                        user.userName          = userName;
                        user.resourceId        = resourceId;
                        user.windowsNTDomain   = windowsNTDomain;
                        user.fullDomainName    = fullDomainName;

                        //' Add user object to user list
                        userList.Add(user);
                    }
                }
            }

            //' Return list of users
            return(userList);
        }
Esempio n. 2
0
        public List <taskSequence> GetHiddenTaskSequenceDeployments(string secret)
        {
            //' Construct hidden task sequences list
            var hiddenTaskSequences = new List <taskSequence>();

            //' Validate secret key
            if (secret != secretKey)
            {
                return(hiddenTaskSequences);
            }
            else
            {
                //' Connect to SMS Provider
                smsProvider          smsProvider = new smsProvider();
                WqlConnectionManager connection  = smsProvider.Connect(siteServer);

                //' Define query string
                string query = "SELECT * FROM SMS_AdvertisementInfo WHERE PackageType = 4";

                //' Query for Task Sequence package
                IResultObject queryResults = connection.QueryProcessor.ExecuteQuery(query);

                foreach (IResultObject queryResult in queryResults)
                {
                    //' Collect property values from instance
                    string taskSequenceName = queryResult["PackageName"].StringValue;
                    string advertId         = queryResult["AdvertisementId"].StringValue;
                    int    advertFlags      = queryResult["AdvertFlags"].IntegerValue;

                    //' Construct new taskSequence class object and define properties
                    taskSequence returnObject = new taskSequence();
                    returnObject.PackageName     = taskSequenceName;
                    returnObject.AdvertFlags     = advertFlags;
                    returnObject.AdvertisementId = advertId;

                    //' Add object to list if bit exists
                    if ((advertFlags & 0x20000000) != 0)
                    {
                        hiddenTaskSequences.Add(returnObject);
                    }
                }
                return(hiddenTaskSequences);
            }
        }
Esempio n. 3
0
        public string GetBootImageSourceVersion(string packageId, string secret)
        {
            //' Validate secret key
            if (secret != secretKey)
            {
                return("A secret key was not specified or cannot be validated");
            }
            else
            {
                //' Connect to SMS Provider
                smsProvider          smsProvider = new smsProvider();
                WqlConnectionManager connection  = smsProvider.Connect(siteServer);

                try
                {
                    //' Query for Boot Image instance
                    IResultObject queryResult = connection.GetInstance("SMS_BootImagePackage.PackageID='" + packageId + "'");

                    if (queryResult != null)
                    {
                        //' Return SourceVersion property from instance
                        int sourceVersion = queryResult["SourceVersion"].IntegerValue;
                        return(sourceVersion.ToString());
                    }
                    else
                    {
                        return("Unable to find any Boot Images");
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(DateTime.Now + ": Unhandled exception occured: " + ex.ToString());
                    return("Unhandled exception occured");
                }
            }
        }