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

Changing the Security Properties of a file

0 views
Skip to first unread message

Yuval Nof

unread,
Jun 15, 2006, 7:26:15 AM6/15/06
to
Hi,
When I create a new file in winXP after logging in as the administrator, and
then I re-login as a different user and try to update the file - the attempt
fails.
I am looking for a component (or source code) that would allow to change
files properties that are under the "Security" category - in windows XP (the
"Security" category is manually accessible through the file properties in
the winXP menus).
Any help would be appreciated,

Thanx in advance, yuval


Remy Lebeau (TeamB)

unread,
Jun 15, 2006, 2:43:19 PM6/15/06
to

"Yuval Nof" <yuv...@elbit.co.il> wrote in message
news:44914482$1...@newsgroups.borland.com...

> When I create a new file in winXP after logging in as the
> administrator, and then I re-login as a different user and
> try to update the file - the attempt fails.

As it should be. The admin owns the file. Noone else can alter the admin's
files.

> I am looking for a component (or source code) that would allow
> to change files properties that are under the "Security" category

If you create the file in code using the CreateFile() function, then you can
specify security rights for it. CreateFile() has an lpSecurityAttributes
parameter for that. Provide a SECURITY_ATTRIBUTES structure that contains a
SECURITY_DESCRIPTOR pointing to a NULL DACL. Then the file will be be
accessible to all users. For example:

SECURITY_DESCRIPTOR sd;
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);

SECURITY_ATTRIBUTES sa = {0};
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd;
sa.bInheritHandle = FALSE;

HANDLE hFile = CreateFile(..., &sa, ...);


Gambit


Yuval Nof

unread,
Jun 15, 2006, 5:14:48 PM6/15/06
to
Hi & thanks so much for your response,
WinXP still enables the user to change the security updates manually.. and
actually this is what I do in order to be able to then update the file from
within the source code.
So my question is actually whether winXPoffers an equivalent way to do that
from within the source code (update security attributes of an exiting file
that was created by the Admin).

Thanx again :)

"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:4491aa9d$3...@newsgroups.borland.com...

Remy Lebeau (TeamB)

unread,
Jun 15, 2006, 4:26:18 PM6/15/06
to

"Yuval Nof" <yuva...@012.net.il> wrote in message
news:4491...@newsgroups.borland.com...

> So my question is actually whether winXP offers an equivalent way


> to do that from within the source code (update security attributes of
> an exiting file that was created by the Admin).

Look at the SetSecurityInfo() function. You would have to call it under the
context of the admin's account in order for the settings to be updatable.


Gambit


0 new messages