SetFileSecurityA function (winbase.h)

The SetFileSecurity function sets the security of a file or directory object.

This function is obsolete. Use the SetNamedSecurityInfo function instead.

Syntax

BOOL SetFileSecurityA(
  [in] LPCSTR               lpFileName,
  [in] SECURITY_INFORMATION SecurityInformation,
  [in] PSECURITY_DESCRIPTOR pSecurityDescriptor
);

Parameters

[in] lpFileName

A pointer to a null-terminated string that specifies the file or directory for which security is set. Note that security applied to a directory is not inherited by its children.

[in] SecurityInformation

Specifies a SECURITY_INFORMATION structure that identifies the contents of the security descriptor pointed to by the pSecurityDescriptor parameter.

[in] pSecurityDescriptor

A pointer to a SECURITY_DESCRIPTOR structure.

Return value

If the function succeeds, the function returns nonzero.

If the function fails, it returns zero. To get extended error information, call GetLastError.

Remarks

The SetFileSecurity function is successful only if the following conditions are met:

  • If the owner of the object is being set, the calling process must have either WRITE_OWNER permission or be the owner of the object.
  • If the discretionary access control list (DACL) of the object is being set, the calling process must have either WRITE_DAC permission or be the owner of the object.
  • If the system access control list (SACL) of the object is being set, the SE_SECURITY_NAME privilege must be enabled for the calling process.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winbase.h (include Windows.h)
Library Advapi32.lib
DLL Advapi32.dll

See also

GetFileSecurity

Low-level Access Control

Low-level Access Control Functions

SECURITY_DESCRIPTOR

SECURITY_INFORMATION

SetKernelObjectSecurity

SetNamedSecurityInfo

SetPrivateObjectSecurity

SetUserObjectSecurity