Export (0) Print
Expand All

SetFileSecurity function

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

This function is obsolete. Use the SetNamedSecurityInfo function instead.

Syntax


BOOL WINAPI SetFileSecurity(
  _In_  LPCTSTR lpFileName,
  _In_  SECURITY_INFORMATION SecurityInformation,
  _In_  PSECURITY_DESCRIPTOR pSecurityDescriptor
);

Parameters

lpFileName [in]

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.

SecurityInformation [in]

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

pSecurityDescriptor [in]

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

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Winbase.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

SetFileSecurityW (Unicode) and SetFileSecurityA (ANSI)

See also

Low-level Access Control
Low-level Access Control Functions
GetFileSecurity
SECURITY_DESCRIPTOR
SECURITY_INFORMATION
SetKernelObjectSecurity
SetNamedSecurityInfo
SetPrivateObjectSecurity
SetUserObjectSecurity

 

 

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft