Can anybody help with the declaration for using the LsaQueryInformationPolicy function available for use in C#, for example, to use the LsaClose API function after getting a handle to a policy you could use this:
[DllImport("advapi32.dll")]
A sample snippet where a policy value is retrieved would be perfect but not expected :-)
I want to do this on a standalone box, that doesn't participate in a domain, so RSOP thru WMI is not an option since I am interested in the local machine policy.
I'd like the solution to be backwards compatible with Framework 1.1 so any new new system spaces, if there are any, in 2.0 will not help.

LsaQueryInformationPolicy
Mr Bongo
MaximeR
Here is the MSDN definition:
NTSTATUS LsaQueryInformationPolicy(
LSA_HANDLE PolicyHandle,
POLICY_INFORMATION_CLASS InformationClass,
PVOID* Buffer
)
So, I can only guess at information class mapping to a numeric datatype, but how does Buffer work
Was saddened when I misunderstood RSOP - I thought it would include the local machine policy as well which would have been perfect - you can see the differences if you view your machine policies thru the RSOP snap-in and then the gpedit.msc - I have even seen it stated in places these two views show the same data, believe me, they dont. RSOP seems to be the result of network based policies combined ONLY. At least thats my understanding for now. I want to programmatically get things like Password Policy whether its defined or not thru a DC GPO - I want to read the values you see in the Group Policy MMC editor for local Computer Policy with C#, and preferably without relearning C or trying to understand C++
Once again, thanks Konstatin.
Ruel C
Declare it as an out IntPtr parameter. You'll get a pointer returned through it. Use that pointer in a call to Marshal.PtrToStructure to dereference to the appropriate struct depending on what kind of policy information you requested. Finally free the memeory with LsaFreeMemory.
BTW, the return type on your LsaClose decaration should be (u)int, not long.
Unitrip
Mattias, Thanks for the info, it works perfectly and also the heads up.
BTW, you obviously know your stuff. If you ever come across documentation explaining the data types returned from the LsaQuery<Local>InformationPolicy Win32 function could you pass it on to me at my email address. Not sure why MS haven't documented it on MSDN, or at least I cant find it there.
Once again, thank you.