Here is a real nail bitter of a problem.
The code that follows works perfects from the commandline. The variable $foo returns "1", which it should. If i change the $pword to something other than password, it returns "0", again as it should.
however, if i run this as a CGI Script $foo ALWAYS returns as "0" regardless to whether the password is correct or not.
Any thoughts on the subject would be great. The only thing i have changed in the below code is the "my" and "domain". Nothing else has been modified from what I ran locally.
#!/usr/bin/perl -w
use strict;
use CGI;
use Win32::OLE;
my $uname = "testuser";
my $pword = "password";
my $foo = &authuser($uname,$pword);
my $query = CGI::new();
print $query->header;
print "$foo \n";
sub authuser {
my($uname,$pword) = @_;
my $adpath = 'LDAP://DC=my,DC=domain,DC=edu';
my $strAttributeName = "userPrincipalName";
my $strAttributeValue = $uname;
my $ad_server = Win32::OLE->GetObject ('LDAP:') or die $!;
my $check_user = $ad_server->OpenDSObject($adpath, $uname, $pword,
+ 1);
if (!Win32::OLE->LastError()) {
return(1);
}
return(0);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.