代码之家  ›  专栏  ›  技术社区  ›  rkellerm

如何检索SID的字节数组

  •  0
  • rkellerm  · 技术社区  · 15 年前

    如何将PSID类型转换为包含SID字节值的字节数组? 比如:

    PSID pSid;
    byte sidBytes[68];//Max. length of SID in bytes is 68
     if(GetAccountSid(
            NULL,       // default lookup logic
            AccountName,// account to obtain SID
            &pSid       // buffer to allocate to contain resultant SID
            )
    

    {

    ConvertPSIDToByteArray(pSid, sidBytes);
    

    }

    --我应该如何编写ConvertPSIDToByteArray函数?

    2 回复  |  直到 8 年前
        1
  •  0
  •   user257111 user257111    15 年前

    ConvertSidToStringSid . 总的想法是把 PSID 结构到a LPTSTR 这实际上是一种 wchar_t . 然后可以使用标准函数将其转换为多字节字符数组 wcstombs 它将以字节为单位给出SID。或者,您可以在 世界卫生组织 直接输入,然后写出来-有一些函数可以处理它。无论哪种情况,结果都是 UTF-16 LE

        2
  •  2
  •   Hans Passant    15 年前

    使用GetLengthSid()获取所需的字节数。然后从PSID中选择memcpy()。