Howdy:
I never did hear back how to suppress the net command from prompting for
a password. I think it was IBMers who contributed the Samba net
command. I was trying to create a webpage from linux/apache/net to
change passwords on an WIN2K Active Direcotory domain controller. Alas
after many attempts to expect the net command, I was able to
successfully use PERL Expect.pm.
Just wrap your CGI around here. The key for Expect.pm to work was
soft_close.
=============================================================
For the archives:
#!/usr/bin/perl -w
use Expect;
use CGI qw(param);
use CGI::Carp qw( fatalsToBrowser );
# Get your variables from CGI
$page_value = param('page_value');
$username = param('username');
$existing_password = param('existing_password');
$new_password = param('new_password');
###################################
## Begin Expect code
# debug
# $Expect::Debug=3;
# Make sure stdout doesn't spill onto console
$Expect::Log_Stdout = 0;
# spawn the expect that will do the work behind the scenes
$net=Expect->spawn("/usr/local/samba/bin/net -w mydomain -I
ads.mydomain.com --user=$username PASSWORD $username $existing_password
$new_password") || die "\n\n\nCouldn't spawn net, $!\n\n\n";
unless ($net->expect(15,"Password:")) {
die "\n\nNever got password
prompt\n".$net->exp_error()."\n";
}
# We got the prompt, so send a password.
print $net "$existing_password\r";
# run soft_close because the program net was running so quickly that the
expect wasn't able to stick in the value quick enough. This sucked to
figure out. If I only I read the Expect.pm POD before I started this
project.... http://search.cpan.org/~rgiersig/Expect-1.15/Expect.pod
$net->soft_close();
On Thu, 2004-06-10 at 16:52, dkw wrote:> Howdy:
>
> Does any have any experience changing a user password on a Active Directory
domain with the Samba 3 net command?
>
> Here is my workstation setup:
> <-> Red Hat Linux Enterprise AS 2.0
> <-> Samba Version 3.0.2a
>
> I am trying to script the event, but I keep getting a password prompt. I
have been having problems expecting around the prompt too. hmmm.
>
> /usr/local/samba/bin/net -w mydomain -I ads.mydomain.com --user=test
PASSWORD test football soccer01
>
> Thank you,
> -dkw
>
>