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

use Win32::NetAdmin; Win32::NetAdmin::UserGetAttributes("", $username, $password, $password +age, $privilege, $homeDir, $comment, $flags, $scriptpath) || die $^E; print "The homedir for $user, $username is $homeDir\n";
When i run this, i get the following error. Overlapped i/o operation is in progress at line 2. Any idea?

Replies are listed 'Best First'.
Re: Overlapped i/o operation
by Khen1950fx (Canon) on Sep 13, 2009 at 23:57 UTC
    This is untested because I don't have Windows, but let me know if this helps:

    #!/usr/bin/perl use strict; use warnings; use Win32::NetAdmin qw( UserGetAttributes ); my $server = ""; my $username = 'username'; my $password = 'password'; my $passwordage = 0; my $privilege = USER_PRIV_USER; my $homeDir = 'c:\\'; my $comment = 'The home dir for user'; my $flags = UF_SCRIPT; my $scriptpath = 'C:\\'; Win32::NetAdmin::UserGetAttributes( "", $username, my $Getpassword, my $Getpasswordage, my $Getprivilege, my $GethomeDir, my $Getcomment, my $Getflags, my $Getscriptpath ); print "The home dir for user, $username is $homeDir\n";
      Khen~ Though it didnt error out as before, the result was not as I expected. I did make some changes to the above script to make it run 1) my $privilege = ""; 2) my $flags = "" 3) my $username = Win32::LoginName; and the results is the home dir for user, myself is i.e. the homedir is not seen in the result. Any idea? BTW, how did this solve the error? whats the trick? Any idea?

        I did make some changes to the above script to make it run 1) my $privilege = ""; 2) my $flags = ""

        The appropriate action would be to remove these unused variables, not meaninglessly changing their value.

        #!/usr/bin/perl use strict; use warnings; use Win32::NetAdmin qw( UserGetAttributes ); my $username = Win32::LoginName(); UserGetAttributes( "", $username, my $password, my $password_age, my $privilege, my $home_dir, my $comment, my $flags, my $script_path ) or die("UserGetAttributes: $^E\n"); print "The home dir for user $username is $home_dir\n";

        When I run the code, I get a zero-length string too. Going to Computer Management and peeking at my user, the home dir is indeed blank there. I set the home directory of a test user to c:\foo using Computer Management, and UserGetAttributes returned c:\foo. It's working fine.

        the homedir is not seen in the result

        Then it must not be set.

        You might try my $homeDir = UF_HOMEDIR_REQUIRED; if the homeDir isn't seen.

        As for solving the error, the trick was in specifically stating UserGetAttributes to keep it from colliding with other exports; hence,

        use Win32::NetAdmin qw( UserGetAttributes ); works.

Re: Overlapped i/o operation
by Anonymous Monk on Sep 13, 2009 at 23:22 UTC