Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Win32::Perms - Can't use Add or Allow methods

by Schlika (Initiate)
on Apr 06, 2004 at 22:31 UTC ( [id://343150]=perlquestion: print w/replies, xml ) Need Help??

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

Hello,

I am desperately trying to get Win32::Perms to work for me.

Here is the code I am using:
use Win32::Perms; use diagnostics; use strict; my $path = "c:\\temp\\test"; my $login = "hostname\\testuser"; my $Dir = new Win32::Perms($path) or die "new: $^E"; $Dir->Add($login, CHANGE, ACCESS_ALLOWED_ACE_TYPE, OBJECT_INHERIT_ACE +| CONTAINER_INHERIT_ACE ) or die "allow: $^E"; $Dir->Set() or die "set: $^E"; $Dir->Close();
Output is:

Uncaught exception from user code:
allow: The network path was not found at test.pl line 8.

Environment is Windows XP, ActiveState Perl v5.8.3 build 809, Win32::Perms version 2002.6.5.O

Any ideas would be greatly appreciated as supersearch came up with a few similar threads but no working answer.

Cheers,

Schlika.

Replies are listed 'Best First'.
can't understand error message?
by PodMaster (Abbot) on Apr 07, 2004 at 04:19 UTC
    Is The network path was not found somehow unclear? To me that would indicate that $login had invalid information.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      It turns out that if I delete the DACL before populating it with the Add method, it works.

      So the code now looks like this:

      use Win32::Perms; use diagnostics; use strict; Win32::Perms::LookupDC( 0 ); my $path = 'c:\temp'; my $login = '\\hostname\testuser'; my $Dir = new Win32::Perms($path) or die "new: $^E"; $Dir->Remove( -1 ); # added this line $Dir->Add($login, CHANGE, ACCESS_ALLOWED_ACE_TYPE, OBJECT_INHERIT_ACE +| CONTAINER_INHERIT_ACE ) or die "allow: $^E"; $Dir->Set() or die "set: $^E"; $Dir->Close();
      Now I need to find out a way to extract the existing ACL, add the entry I want, and re-apply the whole thing...

      Schlika.

      Thank you for the insight, and although I am sometimes forgetful, in this particular case, I made sure the user actually exists.
      It could be however that because "hostname" is the name of a machine rather than the name of a domain it is unable to interpret $login correctly.
      I'll double-check what a valid username looks like for this module and post back.

      Schlika.
      Alright,

      Documentation states valid format for username is one of the following:

      username
      domainname\username
      \\machinename\username

      Tried all three but wihtout any luck...

      So it appears the obvious message is not what you thought after all.

      Schlika.

Re: Win32::Perms - Can't use Add or Allow methods
by esskar (Deacon) on Apr 06, 2004 at 22:47 UTC
    funny guy...
    are you sure that "hostname" is a valid login-domain and "testuser" a valid user in the login-domain?
    try using real users and it will work just fine :)
      hostname\testuser is not what I am really using but substituted information, where "hostname" is the name of the computer, and "testuser" is the name of a regular user.

      I'll remember to state the obvious next time :)

      Schlika.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-20 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found