Fellow monks, I am experiencing some problems with a script which employs Win32::OLE to bridge the gap to Windows ADSI in a similar fashion to that described in this article on perl.com. The problem which I am running into, I am sure is permission related within the IIS (5.0) environment, however am having problems confirming this.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.