Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

How to find the file owner on win32

by OzzyOsbourne (Chaplain)
on Jul 27, 2001 at 17:40 UTC ( #100295=perlquestion: print w/replies, xml ) Need Help??

OzzyOsbourne has asked for the wisdom of the Perl Monks concerning the following question:

I looked through the site, checked through some CPAN modules, and asked in the chatbox, abd I am a little befuddled with the lack of information on this topic, but:

How can one find the owner of a file on a win32 system with Perl?

Stat won't work, and none of the win32 modules that I checked have this functionality. Someone must've wanted to do this before.


Replies are listed 'Best First'.
Re: How to find the file owner on win32 -- use ntfsowner
by grinder (Bishop) on Jul 27, 2001 at 17:59 UTC
    It's a bit dumb that Win32::FileSecurity doesn't know how to do this. On the other hand, you could always use the ntfsowner module, which will do just what you want.

    I did hear an echo that this module is broken on W2K, and that the author can't/won't upgrade it. I think it was sniper who told me this. Message him to be sure.

    update: hmm, I just read Guildenstern's comments. I have used the module and it works as advertised. No (particular) need to be concerned about using it just because it doesn't come from CPAN.

    g r i n d e r
Re: How to find the file owner on win32
by $code or die (Deacon) on Jul 27, 2001 at 19:10 UTC
    See Win32::Perms...
    use Win32::Perms; my $file = new Win32::Perms($ARGV[0]); print $file->Owner;
    It's worth checking Dave Roth's site for almost any Win32 related question. Also, check out his Win32 Administrator book if you get the chance.

    Error: Keyboard not attached. Press F1 to continue.

    Update: Albannach beat me to it. But there's nothing like repeating good advice! ;)
Re: How to find the file owner on win32
by Albannach (Monsignor) on Jul 27, 2001 at 19:06 UTC
    You might want to check out Dave Roth's Win32::Perms module which appears to do what you want. I'm no NT permissions expert but Roth's modules have worked well for me in the past. His book looks interesting too.

    I'd like to be able to assign to an luser

(Guildenstern) Re: How to find the file owner on win32
by Guildenstern (Deacon) on Jul 27, 2001 at 17:50 UTC
    I, too, find it a bit surprising that there isn't a CPAN module to handle this. A logical place for it would be in Win32::FileSecurity, but that module appears to be quite stale. In a bit of Googling, I did come across this module, but I'm always a bit leery of non-CPAN stuff.

    This may be a good opportunity for someone to write a module. There's information on MSDN on how to do this programmatically from C, so it wouldn't be too hard to write a DLL that can be used via Win32::API. Heck, I may even try to put something together if I feel overly motivated this weekend.

    Negaterd character class uber alles!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://100295]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2022-10-04 22:57 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (19 votes). Check out past polls.