Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copy NTFS files with security

436 views
Skip to first unread message

David Lowndes

unread,
Feb 6, 2002, 8:28:01 AM2/6/02
to
>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?

Richard,

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.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
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]

unread,
Feb 6, 2002, 10:14:23 PM2/6/02
to
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

unread,
Feb 7, 2002, 8:42:28 AM2/7/02
to
"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

Chuck...@rtfmcsi.com http://www.rtfmcsi.com
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
80077...@skytel.com


0 new messages