SetFileSecurity

  BOOL SetFileSecurity(lpFileName, SecurityInformation, pSecurityDescriptor)    
  LPTSTR lpFileName;    
  SECURITY_INFORMATION SecurityInformation;    
  PSECURITY_DESCRIPTOR pSecurityDescriptor;    

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

This call is only successful if the following conditions are met:

If the object's owner is to be set, the caller must have WRITE_OWNER permission or be the object's owner.

If the object's DACL is to be set, the caller must have WRITE_DAC permission or be the object's owner.

If the object's SACL is to be set, the caller must have SeSecurityPrivilege privilege.

The SetFileSecurity function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

Parameters

lpFileName

Pointer to a zero-terminated string that names the file or directory whose security this function will set.

SecurityInformation

A SECURITY_INFORMATION data structure that specifies the contents of the security descriptor pointed to by pSecurityDescriptor.

pSecurityDescriptor

A pointer to a well-formed SECURITY_DESCRIPTOR data structure.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

See Also

GetFileSecurity, GetPrivateObjectSecurity, SetPrivateObjectSecurity, CreatePrivateObjectSecurity, DestroyPrivateObjectSecurity, GetUserObjectSecurity, SetUserObjectSecurity