[DllImport("advapi32.dll")]
private static extern UInt32 LsaRetrievePrivateData(
IntPtr policyHandle,
[MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(LSAStringMarshaler))] string KeyName,
[MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(LSAStringMarshaler))] ref string PrivateData
);
Private Declare Function LsaRetrievePrivateData Lib "ADVAPI32.dll" (ByVal PolicyHandle As Long, ByRef KeyName As LSA_UNICODE_STRING, ByVal PrivateData As Long) As Long
Private Type LSA_UNICODE_STRING
Length As Integer ' WORD
MaximumLength As Integer ' WORD
Buffer As Long ' PWCHAR - pointer
End Type
Do you know one? Please contribute it!
See LsaOpenPolicy for the custom marshaler and some more info on it.
Do not use the LSA private data functions. Instead, use the CryptProtectData and CryptUnprotectData functions.
(However, these won't do when you need to modify COM runas Passwords ...)
Please add some!