CopySid function

The CopySid function copies a security identifier (SID) to a buffer.

Syntax

BOOL CopySid(
  DWORD nDestinationSidLength,
  PSID  pDestinationSid,
  PSID  pSourceSid
);

Parameters

nDestinationSidLength

Specifies the length, in bytes, of the buffer receiving the copy of the SID.

pDestinationSid

A pointer to a buffer that receives a copy of the source SID structure.

pSourceSid

A pointer to a SID structure that the function copies to the buffer pointed to by the pDestinationSid parameter.

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.

Remarks

An application can use the CopySid function to make a copy of a SID in an access token (for example, in a TOKEN_GROUPS structure) to use in an access control entry (ACE).

Examples

For an example that uses this function, see Getting the Logon SID.

Requirements

   
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header securitybaseapi.h (include Windows.h)
Library Advapi32.lib
DLL Advapi32.dll

See Also

Access Control Overview

AllocateAndInitializeSid

Basic Access Control Functions

EqualSid

GetLengthSid

GetSidIdentifierAuthority

GetSidLengthRequired

GetSidSubAuthority

GetSidSubAuthorityCount

InitializeSid

IsValidSid

SID