Copy NTFS files with security

Skip to first unread message

David Lowndes

Feb 6, 2002, 8:28:01 AM2/6/02
>Has anyone got an example of how to copy files from one
>NTFS drive to another NTFS drive on the same box and keep
>the security?


Have you tried using SHFileOperation? The FOF_NOCOPYSECURITYATTRIBS
flag implies that the default operation would copy the security
settings - though I've never tried it.

My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Dan Ruder [MS]

Feb 6, 2002, 10:14:23 PM2/6/02
CopyFile/CopyFileEx will not preserve the file's security.

As David said, SHFileOperation may meet your needs. If not, then you would
have to call GetFileSecurity to get all of the info out of the source
file's security descriptor, use it to build a new SD, then copy the file,
and finally, apply the new SD to the file via SetFileSecurity. This is a
fair amount of work as you have to get and set all the types of info out of
the SD (owner, DACL, SACL, etc). You will need the restore privilege to
call SetFileSecurity to set the OWNER_SECURITY_INFORMATION to any user
besides the one your app runs in. Normally, backup operators have this
privilege, but normal user accounts don't.

Dan Ruder

This posting is provided "AS IS" with no warranties, and confers no rights.

Chuck Chopp

Feb 7, 2002, 8:42:28 AM2/7/02
"Dan Ruder [MS]" wrote:

And, in addition to what Dan mentioned, if your NTFS partitions are on separate
servers and you are moving the files between WinNT v3.5x/v4.0 and either
Win2K/XP then you have to deal with the different manner in which inheritable
ACEs are handled on those operating systems.

Chuck Chopp
ICQ # 22321532
RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651 800 774 0718 pager

Reply all
Reply to author
0 new messages