in reply to Overlapped i/o operation

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";

Replies are listed 'Best First'.
Re^2: Overlapped i/o operation
by kingjamesid (Acolyte) on Sep 14, 2009 at 02:24 UTC
    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.

        This code doenst work !!! :-( Still the same error. From the khen's code, i took some snippets to make it work. Like - final version that worked
        use strict; use warnings; use Win32::NetAdmin qw(UserGetAttributes); my $server = ""; my $username = Win32::LoginName; my $password = 'password'; my $passwordage = 0; my $homeDir = 'c:\\'; my $comment = 'The home dir for user'; my $scriptpath = 'C:\\'; Win32::NetAdmin::UserGetAttributes( "", $username, my $Getpassword, my $Getpasswordage, my $Getprivilege, my $GethomeDir, my $Getcomment, my $Getflags, my $Getscriptpath ); print "The homedir for $username is $homeDir \n";
        Why your code didnt work, even though its looks same. But what I dont understand is UserGetAttributes function is not used at all. In the above code, we are using some variables thats filled in and not from variables that are filled by USerGetAttributes. Shouldnt I say
        print "The homedir for $username is $GethomeDir";
        Please suggest and very sorry guys, I am just learning Perl if you think my questions are silly.
      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.