rlb3 has asked for the wisdom of the Perl Monks concerning the following question:

I'm try to pull some information from Active Directory using Win32::OLE. I'm using example code from the Active Directory cookbook but i'm still getting this error:

OLE exception from "Provider": <p>One or more errors occurred during processing of command.</p> Win32::OLE(0.1702) error 0x80040e14 in METHOD/PROPERTYGET "Execute" at sdomain.pl line 11
Here is the code I'm using.
my $strBase = "LDAP://dc=corp,dc=example,dc=edu;"; + # BaseDN should be the search base my $strFilter = "(&(objectclass=user)(objectcategory=Person));"; + # Valid LDAP search filter my $strAttrs = "name,mailNickname,extensionAttribute1;"; + # Comma-seperated list my $strScope = "Subtree"; + # Should be on of Subtree, Onelevel or Base use Win32::OLE; $Win32::OLE::Warn = 3; my $objConn = Win32::OLE->CreateObject("ADODB.Connection"); $objConn->{Provider} = "ADsDSOObject"; $objConn->Open("Active Directory Provider"); my $objRS = $objConn->Execute($strBase . $strFilter . $strAttrs . $str +Scope); $objRS->MoveFirst; while (not $objRS->EOF) { print $objRS->Fields(0)->Value,"\n"; $objRS->MoveNext; }

Any help would be great.

Replies are listed 'Best First'.
Re: Help using Win32::OLE
by Anonymous Monk on Mar 27, 2006 at 22:39 UTC
    The error message breaks down like this:
    OLE exception from "Provider":
    Means that the error came from your provider (Active Directory in this case).

    One or more errors occurred during processing of command
    Is the error that was returned by Active Directory.

    Win32::OLE(0.1702) error 0x80040e14 in METHOD/PROPERTYGET "Execute" at sdomain.pl line 11
    Means that Active directory generated the error when Perl called "Execute" on line 11.


    The command you're trying to execute on line 11 is
    LDAP://dc=corp,dc=example,dc=edu;(&(objectclass=user)(objectcategory=P +erson));name,mailNickname,extensionAttribute1;Subtree
    The error message from Active Directory isn't very helpful in this case. You need to change
    my $strBase = "LDAP://dc=corp,dc=example,dc=edu;";
    to
    my $strBase = "<LDAP://dc=corp,dc=example,dc=edu>;";
Re: Help using Win32::OLE
by planetscape (Chancellor) on Mar 28, 2006 at 05:42 UTC
Re: Help using Win32::OLE
by strat (Canon) on Mar 28, 2006 at 07:55 UTC
Re: Help using Win32::OLE
by monarch (Priest) on Mar 27, 2006 at 22:10 UTC
    Have you added something like
    use Win32::OLE::Const 'ADODB';
    ? Not sure if ADODB is what you want but whatever the application is there may be some constants to get before using the object?