RSOP over WMI - Problem getting local policy data on Server 2008 R2
I have an application where I would like to programmatically display the current password policy settings from C# on a Server 2008 R2 machine. I have this working fine for domain attached machines, but it was more difficult to find what I needed for non-domain attached machines. Eventually I got a WMI query that did what I wanted, tested and working on 64-bit Windows 7 Professional (which I thought was pretty close to 2008 R2). Unfortunately, the same query which returns 18 objects on my development node (including the four I care about) returns zero objects on my Server 2008 R2. The application on the 2008 R2 machine normally runs as a service under LOCAL SYSTEM, however, I repeated the testing as local administrator with no change observed. I narrowed the issue down to this small test app: using System; using System.Management; // must add a reference to System.Management to build this using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\rsop\\computer", "SELECT * FROM RSOP_PolicySetting"); ManagementObjectCollection collect = searcher.Get(); Console.WriteLine("Search returned {0} objects.\n", collect.Count); foreach (ManagementObject queryObj in searcher.Get()) { Console.WriteLine("----{0}----", queryObj.Path); foreach (PropertyData q in queryObj.Properties) { Console.WriteLine("{0} -> '{1}'", q.Name, q.Value); } } } } } Works on my Win7 workstation, returns 0 objects (and no errors or exceptions) on Server 2008 R2. I tested both domain attached and not domain attached (but I am trying to get the information NOT domain atttached). Ultimately, whatever the method, I am just trying to read the following 4 settings from C# from the local, not domain, policy, when not attached to a domain: -Enforce Password History (how many passwords remembered) -Minimum password age (how many days) -Minimum password length (in characters) -Password must meet complexity requirements (yes/no) Anybody got any ideas? :) Thanks for reading.
June 2nd, 2011 4:48pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics