CopySid function (securitybaseapi.h)

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

Syntax

BOOL CopySid(
  [in]  DWORD nDestinationSidLength,
  [out] PSID  pDestinationSid,
  [in]  PSID  pSourceSid
);

Parameters

[in] nDestinationSidLength

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

[out] pDestinationSid

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

[in] 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

Requirement Value
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