I've been woking this issue on and off for a while now having issues
connecting to an Exchange server's LDAP interface and creating mailboxes.
The current problem is that I manage 3 exchange servers in different
locations of our WAN, and the script, once connected to one server to do
maintenance for an account, connects fine and sets the properties correctly,
but immediately fails to connect to the next server for the next user in the
same script running, giving a LastError() of LDAP_SERVER_DOWN (0x8007203a).
As well, if the script needs to talk to the original server for a user
further down in the foreach loop (past other failures) the GetObject() works
and the creation works but GetObject()s to other servers continue to fail...
In the next script run (as little as 10 seconds later), the script can
connect to the server it failed previously with and continue to process the
users that previously failed without problem (except users that need to be
processed on the next server).
I have been playing with the initial GetObject calls and the
Initialize(COINIT...) values.
I've read many of the references that Jan has made regarding placement of
the Initialize() call and have done as instructed (putting it directly after
the use Win32::OLE; statement), and I've gotten 5 - 10 different errors
depending on which MSDN article I just looked at or which Mailing list
reference I modeled after with varying degrees of failure.
The latest try is below, and seems to be the most stable, but I can't
connect to multiple LDAP/Exchange servers in the same running of the script.
Is this because of my Initialize(COINIT...) selection??
Once connected to the server, the creation routine and error-check (not
included) run great for that server.
Do I need to run Uninitialize and Initialize before and after every calling
of the subroutine? What does Release do? (I thought it released the object
similar to undef?!)
running on: NT4SP6a - ADS 2.5, Win32::OLE 0.15, AS623
---------------
use Win32::OLE (HRESULT);
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
foreach $user (sort keys %create) {
create_mailbox($user,$create{$user}{'exch_server');
}
sub create_mailbox {
[snip...]
my $ADsPath =
"LDAP://$exch_server_name/cn=Recipients,ou=$exch_org_unit,o=$exch_org";
my $Recipients = Win32::OLE->new('LDAPNamespace');
if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError(),"\n";
$Recipients->Release();
return 0;
}
$Recipients = Win32::OLE->GetObject($ADsPath);
if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError(),"\n";
$Recipients->Release();
return 0;
}
[snip..]
$Recipients->Release();
return 1;
}
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users