My shortest test-case code is as follows ...
#!d:/Perl/bin/Perl.exe use CGI; use CGI::Carp; use Win32::OLE; use strict; my $cgi = CGI->new; print STDOUT $cgi->header; my ($username, $password) = ('myusername', 'mypassword'); my $objNameSpace = Win32::OLE->GetObject('LDAP:') or croak( 'Cannot create LDAP object - ', $! ); my $objObjSec = $objNameSpace->OpenDSObject( 'LDAP://DC=mydomain,DC=com', $username, $password, 1 ); if (Win32::OLE->LastError() == 0) { print STDOUT "Success!\n"; $objObjSec->close; } else { print STDOUT "Failure!\n"; } $objNameSpace->close; exit 0;
The objective of this code is to take username and password details supplied and authenticate them against the Windows 2000 Active Directory. When run from the command line, this code executes without errors or warnings, yet when executed from within the IIS environment, the authentication lookup fails, despite accurate username and password details having been supplied.
Digging deeper into this problem, I have found that the OpenDSObject call is returning a HRESULT error code of 0x8007202 - I have not however been able to determine the cause of this error message as per the instructions on the MSDN site here.
This failure of execution within the IIS environment, but success from the command line very much suggests to my mind that this is a permission problem of sorts, however I am at a loss as to where to look next to resolve this problem.
In reply to Problems with Win32::OLE and ADSI by rob_au
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |