How do I get the AD Kerberos ticket lifetime using .NET?
How do I get the ticket lifetime from the开发者_Go百科 Active Directory Kerberos Policy? Basically, I need to access the values found here: Computer Configuration > Policy > Windows Settings > Security Settings > Account Policies > Kerberos Policy.
(in both Windows Serve 2003 and Windows Serve 2008)
This can be done using WMI. Specifically in .NET you'll want to use WMI.NET. To find the specific value you're looking for I recommend that you use this tool:
http://thepowershellguy.com/blogs/posh/archive/2007/03/22/powershell-wmi-explorer-part-1.aspx
This allows you to browse the CIMV2 root and futz with the query until you're sure you've got it correct, then you can just paste the query into your WMI.NET code.
It'll look something like this:
WqlObjectQuery wqlQuery = new WqlObjectQuery("SELECT * FROM Win32_LogicalDisk");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wqlQuery);
foreach (ManagementObject disk in searcher.Get())
{
Console.WriteLine(disk.ToString());
}
I think this is actually the correct query (in VB.NET):
http://www.activexperts.com/activmonitor/windowsmanagement/scripts/grouppolicy/
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\rsop\computer")
Set colItems = objWMIService.ExecQuery _
("Select * from RSOP_SecuritySettingBoolean")
For Each objItem in colItems
Wscript.Echo "Key Name: " & objItem.KeyName
Wscript.Echo "Precedence: " & objItem.Precedence
Wscript.Echo "Setting: " & objItem.Setting
Wscript.Echo
Next
精彩评论