Notes below.

Cheers!
Steven 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Paul Jansen
> Sent: Tuesday, April 11, 2006 7:36 AM
> To: Paul Sobey; [EMAIL PROTECTED]
> Subject: RE: exchange ldap problems using OLE
> 
> --- Paul Sobey <[EMAIL PROTECTED]> wrote:
> 
> > > I'm trying to make some LDAP queries through OLE. 
> > I
> > > don't need to supply any username or password
> > detaisl
> > > this way as it just uses the logged in user's credentials.
> > > Here's a code snippet
> > > * * * * * *
> > > use Win32::OLE qw(in);
> > > use Win32::OLE::Variant;
> > > use Win32::OLE::Const("Active DS"); #Get Constants
> > for
> > > ADS
> > > 
> > > $ldap_dc = "mydc";
> > > $ldap_query_string = "CN=Microsoft
> > >
> >
> Exchange,CN=Services,CN=Configuration,DC=mydomain,DC=local";
> > > 
> > > my $ADServer =
> > >
> >
> Win32::OLE->GetObject("LDAP://$ldap_dc/$ldap_query_string");
> > >   foreach my $element (in($ADServer)){
> > >           print "class is $element->{Class} -\n";
> > >           print "name is $element->{Name} -\n";
> > >         }
> > > }
> > > 
> > > 
> > > * * * *
> > > 
> > > Now if I use an LDAP browser to have a look at the 
> structure (as per 
> > > what I have in the $ldap_query_string variable) it shows two 
> > > elements underneath this LDAP path.  One is 'Active
> > Directory
> > > Connections' and the other is the name of a mail store.  
> When I run 
> > > the code above it shows both of these elements (prints 
> the class and 
> > > the name).
> > > The problem is that once I have the name of the
> > store
> > > I want to do another LDAP query further down into
> > it's
> > > part of the LDAP tree. It simply doesn't work.  If

I think you want is really an LDAP search (I'm guessing) for the mailbox
stores that a server has defined.

The query you were looking for initially would have been for the paths
to the organization, and a proper search scope is: 

(objectClass=msExchOrganizationContainer)

Try looking at Win32::Exchange (cpan) for _AdodbExtendedSearch as it
will help you search AD as opposed to connecting to subpaths, in order
to traverse the tree..  Searching the tree is much faster and performs
fewer method calls.

use Win32::Exchange;
if (!Win32::Exchange::_AdodbExtendedSearch("organization
name","LDAP://CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=mydomain,DC=local","(objectClas
s=msExchOrganizationContainer)","name,ADsPath",$org_name)) {
  print "error performing search\n";
}
print "orgname = ".$name."\n";

Enumming the mailbox stores could again be accomplished using the same
methodology (if that's your real intent), but a limitation in the
structure of the function prohibits it from returning the multiple
results that it finds. (technically I look through the multiple results,
but only return one with this function).  You could use the code from
the base function to return the paths you are looking for by altering it
and using it in a similar function of your own.

Similarly, using a searchpath of (homeMDBBL=*) produces a list of all
the paths that have a HomeMDBBL defined (3 places in my exchange org..
Depending on what base path you search from, you could eliminate 1 or
more of the results).

I hope this helps.

Steven 

> > I
> > > change the $ldap_query_string variable as per the
> > name
> > > of the store it doesn't return any values.
> > > Essentially I want ot query the 'homeMDBBL' value
> > of
> > > each servers listed further down the LDAP
> > structure to
> > > get the number of mailboxes on each server.
> > > Does anyone know why I can see these values using
> > an
> > > LDAP browser but can't see them using the code
> > above?
> > 
> > I'm not sure the keys lower down are readable by normal users - at 
> > least not on my Win2K3 domain. What privileges does your 
> account have?
> > 
> > Paul
> > 
> 
> Thanks for the reply.
> The account I'm running under has 'Domain Admins'
> rights.
> 
> Regards,
> PJ
> 
> 
> 
>       
> 
>       
>               
> ____________________________________________________
> On Yahoo!7
> Messenger - Make free PC-to-PC calls to your friends overseas. 
> http://au.messenger.yahoo.com 
> 
> _______________________________________________
> Perl-Win32-Admin mailing list
> Perl-Win32-Admin@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> 

_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to