LSA_UNICODE_STRING (Structures)
Last changed: egray1@hot.rr.com-24.26.210.211

.
Summary
TODO - a short description

C# Definition:

[StructLayout(LayoutKind.Sequential)]
struct LSA_UNICODE_STRING
{
    public UInt16 Length;
    public UInt16 MaximumLength;
    public IntPtr Buffer;
}

VB Definition:

Structure LSA_UNICODE_STRING
   Dim Length As Short
   Dim MaximumLength As Short
   Dim Buffer As IntPtr
End Structure

User-Defined Field Types:

None.

Notes:

None.

Sample Code (C#):

// You should already have the HPolicy and SID ready
IntPtr rightsPtr;
uint countOfRights;
LsaEnumerateAccountRights(HPolicy, SID, out rightsPtr, out countOfRights);
try
{
    IntPtr ptr = rightsPtr;
    LSA_UNICODE_STRING userRight;
    for (int i = 0; i < countOfRights; i++)
    {
       userRight = (LSA_UNICODE_STRING)Marshal.PtrToStructure(ptr, typeof(LSA_UNICODE_STRING));
       String userRightStr = Marshal.PtrToStringAuto(userRight.Buffer);
       Console.WriteLine("Another Privilege found: " + userRightStr);
       ptr = (IntPtr)((Int32)ptr + Marshal.SizeOf(userRight));
    }
}
finally
{
    LsaFreeMemory(rightsPtr);
}

Documentation