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

Hi monks!

I have a domain where users have Ftp access to some websites. I wont code something to try their account Ftp. I have admin permission. I have tried to melt NetAdmin with Net:Ftp...
I know that netAdmin never show pwd but IT GET IT ?
The code die at login
Why I have no result from Ftp failing ?
$utente='Auser'; Win32::NetAdmin::UserGetAttributes("", $utente, $password, $passwordAg +e, $privilege, $homeDir, $comment, $flags, $scriptPath) or die "UserG +etAttributes() failed: $^E"; $ftp = Net::FTP->new("www.aiming.it", Debug => 0); $ftp->login("$utente","$password")||die $!; $ftp->cwd("aiming"); while ($ftp->dir()){print} #OR ? @lista=$ftp->dir(); print "@lista\n"; $ftp->quit;

many thanks 4 help me in my goal(view my home node)
cheers from sunny Roma!

lor*

Replies are listed 'Best First'.
Re: Win32::netAdmin pwd question
by meetraz (Hermit) on Feb 25, 2003 at 16:15 UTC
    There is no way possible to retreive a user's plaintext password via the Win32 API. When you call UserGetAttributes(), the $password variable ends up being undefined.

    I'm not sure why the FTP login call isn't die()ing. But, you should first turn on warnings and use strict if you're not already. Also, take out the quotes around the username & password for your login call, like this:

    $ftp->login($utente,$password) || die $!;

      hello,

      the $password is defined I tested it with:

      if defined $password print "defined pwd";

      and it print it.
      cheers lor*
        I read through the source for Win32::NetAdmin, and it uses the Win32 API call "NetUserGetInfo". According to Microsoft's documentation, "The NetUserEnum and NetUserGetInfo functions return a NULL pointer to maintain password security."

        So, the $password is not set with a valid password. Have you tried printing out the value to see if it's correct? Maybe there's junk data in there, or maybe something else in your program is setting it by accident.