Try to read Values in Local Group policy in C# using WMI RRS feed

  • Question

  • Hi all,

    I am trying to read two setting values in Local Group policy (gpedit.msc). The path is :

    Local Computer Policy\Windows Settings\Security Settings\Local Policies\User Rights Assignment

    The Policy that I want to read are :
    1. Perform volume maintainace tasks (Users assigned to it) 2. Lock Pages in memory (Users assigned to it).

    I have searched the web (including all stackoverflow threads) and could not find a solution to this but could not get a solution to this. Below is the code I am using currently but it only returns me 7 values only and not the ones required. Values 1. returned are : (SeDenyBatchLogonRight , SeDenyInteractiveLogonRight , SeDenyServiceLogonRight , SeDenyBatchLogonRight , SeRemoteShutdownPrivilege , SeDenyServiceLogonRight , SeDenyBatchLogonRight)

    I am not sure if this is possible. Please suggest. I am using C# .NET as language and would prefer if possible be able to read these setting from a remote machine (so I am preferring WMI approach).

    I have gone through this link but I would not prefer to install anything on my servers (if that is possible).

    Also I only want to read values. No editing or adding/removal...

    Please suggest..

    • Girija
    private void Test()
                ManagementScope scope =
                          new ManagementScope(
                ObjectQuery query = new ObjectQuery(
                    "SELECT * FROM RSOP_UserPrivilegeRight");
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher(scope, query);
                ManagementObjectCollection queryCollection = searcher.Get();
                List<string> val = new List<string>();
                foreach (ManagementObject mgo in queryCollection)
                    var d = mgo["Name"];

    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria

    Friday, April 3, 2015 10:12 AM


All replies