Authorization Functions


ConvertSidToStringSid Function

The ConvertSidToStringSid function converts a security identifier (SID) to a string format suitable for display, storage, or transmission.

To convert the string-format SID back to a valid, functional SID, call the ConvertStringSidToSid function.

Syntax

C++
BOOL ConvertSidToStringSid(
  __in   PSID Sid,
  __out  LPTSTR *StringSid
);

Parameters

Sid [in]

A pointer to the SID structure to be converted.

StringSid [out]

A pointer to a variable that receives a pointer to a null-terminated SID string. To free the returned buffer, call the LocalFree function.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError. The GetLastError function may return one of the following error codes.

Return codeDescription
ERROR_NOT_ENOUGH_MEMORY

Insufficient memory.

ERROR_INVALID_SID

The SID is not valid.

ERROR_INVALID_PARAMETER

One of the parameters contains a value that is not valid. This is most often a pointer that is not valid.

 

Remarks

The ConvertSidToStringSid function uses the standard S-R-I-S-S… format for SID strings. For more information about SID string notation, see SID Components.

Examples

For an example, see Converting a Binary SID to String Format

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderSddl.h
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesConvertSidToStringSidW (Unicode) and ConvertSidToStringSidA (ANSI)

See Also

Access Control Overview
Basic Access Control Functions
ConvertSecurityDescriptorToStringSecurityDescriptor
ConvertStringSecurityDescriptorToSecurityDescriptor
ConvertStringSidToSid
SID

Send comments about this topic to Microsoft

Build date: 9/11/2009

Tags :


Community Content

adeyblue
Has issues with 5 and 6 byte Identifier Authorities prior to Server 2003
Prior to Server 2003, this function has issues if either of the first two bytes of the SID's identifier authority structure are non-zero. Instead of taking them into account, they are effective ignored and identifier authority is truncated to 0xFFFFFFFF. As an example, a binary SID of the form S-1-0x010203040506-4-0 is converted to a string of S-1-4294967295-4-0.

The same truncation is also true of the ConvertStringSidToSid function which will truncate any stringified identifier authority larger than 0xFFFFFFFF down to that value.

For C++ functions that handle SIDs with these larger identifier authorities both from and to string form see http://www.cpplc.net/forum/index.php/topic,1555.0.html
Tags :

Page view tracker