Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Perl NIS authentication

by NASAdave (Initiate)
on Feb 20, 2013 at 19:07 UTC ( #1019828=perlquestion: print w/ replies, xml ) Need Help??
NASAdave has asked for the wisdom of the Perl Monks concerning the following question:

So I am trying to get a script to authenticate against NIS - here is code that I am using to test:
#!/usr/bin/perl use Authen::Simple::NIS; use Net::NIS; my $default_domain = Net::NIS::yp_get_default_domain(); my %nis_hash = (); %nis_hash->{'domain'} = Net::NIS::yp_get_default_domain(); my $nis = Authen::Simple::NIS->new(%nis_hash); if ( $nis->authenticate( "user", "testpass" ) ) { print "Success\n" ; # successfull authentication } print "done\n" ;
It always returns 0 even though I know the user is valid in NIS, and doing a strace shows it using the correct NIS server and securenets looks good... - I swear I have checked everything - any ideas?

Comment on Perl NIS authentication
Download Code
Re: Perl NIS authentication
by VinsWorldcom (Priest) on Feb 20, 2013 at 19:59 UTC

    Try:

    use strict; use warnings;

    at the top of your code to see some warnings / errors with what you posted.

    I don't have a NIS server to test against, but I'm willing to bet if your credentials are correct, the following (untested) may work:

    #!/usr/bin/perl use strict; use warnings; use Net::NIS; use Authen::Simple::NIS; my $default_domain = Net::NIS::yp_get_default_domain(); my $nis = Authen::Simple::NIS->new(domain => $default_domain); if ($nis->authenticate("user", "testpass")) { print "Success\n" } print "done\n";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-12-26 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls