Link to home
Start Free TrialLog in
Avatar of urif
urif

asked on

getting owner of a file under Windows NT/2000 and changing file attributes

hi,
i need to know the owner of a file under Windows NT/2000 and change the file attributes, meaning that if a file is own by me and i would like to (for example) set the attribute to all users can copy/view... etc

thanks
Avatar of Madshi
Madshi

You can use Get/SetFileSecurity or Get/SetSecurityInfo. Both is not easy to use. If you have D4 or D5, you might want to look at my package "madSecurity" (free for non-commercial usage). With it you can do things like this:

with FileSecurity(fileNameOrHandle) do
  if Owner = CurrentUser then
    DAcl.SetFileAccess(Account('AnotherUser'), true);

This checks, whether the file is owned by the current user, and if it is, write access to the file is granted to the user "AnotherUser".

Regards, Madshi.
Avatar of urif

ASKER

mmm actually i was looking for some code snippets.
i'm not allowed to intall any soft on the machine i'm working on...

thanks!
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of urif

ASKER

it was usefull, though it was micro$soft site (to be scare of...)

thanks