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

Copying files with security attributes

366 views
Skip to first unread message

Mark

unread,
Aug 3, 2001, 6:02:19 AM8/3/01
to
Hi,

I need to copy and move files and keep all the file attributes
including the NT security attributes. Can anyone tell me how
to do this?

TIA
Mark Williams

Jerry Coffin

unread,
Aug 3, 2001, 7:00:27 AM8/3/01
to
In article <3b6a76a9...@news.force9.net>,
mark@*NO*SPAM*techop*co.uk says...

> Hi,
>
> I need to copy and move files and keep all the file attributes
> including the NT security attributes. Can anyone tell me how
> to do this?

You've got a couple of possibilities. The most obvious is to copy
the file (e.g. with CopyFile) and then copy the security attributes
with GetFileSecurity and SetFileSecurity (after enabling the
SE_SECURITY_NAME privilege).

A less obvious way would be to call BackupRead to read the old file,
and then use BackupWrite to write the new one. These are supposed to
copy the entire file, including security attributes, secondary file
streams, and so on.

--
Later,
Jerry.

The Universe is a figment of its own imagination.

Mark

unread,
Aug 7, 2001, 9:07:32 AM8/7/01
to
Hi & Thanks,

On Fri, 3 Aug 2001 05:00:27 -0600, Jerry Coffin <jco...@taeus.com>
wrote:

>You've got a couple of possibilities. The most obvious is to copy
>the file (e.g. with CopyFile) and then copy the security attributes
>with GetFileSecurity and SetFileSecurity (after enabling the
>SE_SECURITY_NAME privilege).

How can the SE_SECURITY_NAME privilege be set?

TIA

Jerry Coffin

unread,
Aug 8, 2001, 11:58:36 AM8/8/01
to
In article <3b6fe7d7...@news.force9.net>,
mark@*NO*SPAM*techop*co.uk says...

Basically you OpenProcessToken then AdjustTokenPrivileges.

Michael Daniloff

unread,
Aug 8, 2001, 6:50:28 PM8/8/01
to
mark@*NO*SPAM*techop*co.uk (Mark) wrote in message news:<3b6a76a9...@news.force9.net>...

Check SHFileOperation() on MSDN.

You can copy/move more than one file by using this function.
You just have to set appropriate buffers and flags to do it right.
I think it copies security attributes by default, but there's a flag to disable it.

Regards,

Michael

Ralf Buschmann

unread,
Aug 9, 2001, 2:22:00 AM8/9/01
to
On Fri, 3 Aug 2001 05:00:27 -0600, Jerry Coffin <jco...@taeus.com>
wrote:
>A less obvious way would be to call BackupRead to read the old file,
>and then use BackupWrite to write the new one. These are supposed to
>copy the entire file, including security attributes, secondary file
>streams, and so on.

Note that there are some problems with BackupWrite in W2K, see
http://support.microsoft.com/support/kb/articles/Q271/3/98.ASP and
http://support.microsoft.com/support/kb/articles/Q259/3/93.ASP . I'm
also not sure that BackupRead/BackupWrite will process encrypted files
in W2K. See http://www.collakesoftware.com/files/efsraw10.zip for an
example on how to perform a "raw" copy of encrypted files.

Ralf.

0 new messages