Have you looked at doing this through LDAP?  

I'm not sure what docs you were looking at, but I believe the CDO model is
for Exchange 2000 (though I've never seen code to change Exchange fax and
phone numbers through MAPI).

Win32::Exchange has a working example for you to set properties in Exchange
5.5 and 2000, but you'd be talking to the Exchange Server through LDAP
instead of MAPI.  Deleting those attributes for those properties would
basically be as easy as setting them to "".

Win32::Exchange can be found on CPAN
(http://search.cpan.org/author/SMANROSS/Win32-Exchange_v0.032/) or on Dave
Roth's PPM site http://www.roth.net/perl/packages/

I'd be interested in seeing the source of your documentation on your MAPI
approach if you don't mind.

Steven

-----Original Message-----
From: Herold Heiko [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, February 18, 2003 8:14 AM
To: List Perl-Win32-Admin (E-mail)
Subject: Ole CDO woes


I'm trying to update a bunch of mailboxes in a exchange server environment
(5.5sp2) via Win32::OLE and CDO ("MAPI.Session").
For some mailboxes I need to change the existing fax and phone number
(CdoPR_BUSINESS_TELEPHONE_NUMBER and CdoPR_PRIMARY_FAX_NUMBER). Everything
working ok with this:

my $addrentries = $gal->AddressEntries;
my $addrentry = $addrentries->GetFirst;
my $fields = $addrentry->{Fields};
< match the correct addrentries by 
$fields->Item($cdoconst->{CdoPR_OBJECT_TYPE})->{Value} and 
$fields->Item($cdoconst->{CdoPR_TRANSMITABLE_DISPLAY_NAME_A})->{Value} >

$fields->Item($cdoconst->{CdoPR_BUSINESS_TELEPHONE_NUMBER})->{Value} =
$newnumber; $addrentry->Update;

For some other mailboxes I need to delete those fields. From the docs I
expected this to work:
$fields->Item($cdoconst->{CdoPR_BUSINESS_TELEPHONE_NUMBER})->Delete;
$fields->Item($cdoconst->{CdoPR_PRIMARY_FAX_NUMBER})->Delete;
$addrentry->Update;

With that I get (right after the Delete) a 
  DB<3> x Win32::OLE->LastError()
0  'OLE exception from "Collaboration Data Objects":

 [Collaboration Data Objects - [E_ACCESSDENIED(80070005)]]

Win32::OLE(0.1008) error 0x80070005: "Access is denied"
    in METHOD/PROPERTYGET "Delete"'

The account used for the (explicit) logon definitively has rights, I even
tried the service account After all changing those numbers does work, too.
On the other hand, trying to clean the fields instead of deleting them:

$fields->Item($cdoconst->{CdoPR_BUSINESS_TELEPHONE_NUMBER})->{Value} = "";
$addrentry->Update;

will give me an error in Update:

0  'OLE exception from "Collaboration Data Objects":

You do not have sufficient permission to perform this operation on this
object. [Microsoft Exchange Address Book - [E_ACCESSDENIED(80070005)]]

Win32::OLE(0.1008) error 0x80070005: "Access is denied"
    in METHOD/PROPERTYGET "Update"'

Same thing if I try to set those phone number fields to something
nonsensical like "abcd". On the other hand, from exchange administrator I
can empty those fields fine, I can even create a fresh mailbox without
anything in those fields - in that case the cdo fields collection won't even
contain a field for CdoPR_BUSINESS_TELEPHONE_NUMBER!

Any idea ?

Heiko Herold

-- 
-- PREVINET S.p.A.            [EMAIL PROTECTED]
-- Via Ferretto, 1            ph  x39-041-5907073
-- I-31021 Mogliano V.to (TV) fax x39-041-5907472
-- ITALY
_______________________________________________
Perl-Win32-Admin mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to