Problem programmatically registering event sink in C++

Problem programmatically registering event sink in C++

Post by chun cheung yi » Sun, 28 Apr 2002 09:22:51



Hi All,

I have been running into permission problem while trying
to programmatically register an event. Hopefully someone
here would be able to help.

I have no problem using the regevent script to register
the event sinks. However when I executed the ported
version of the regevent code into C++ I always
encountered the problem with the program throwing
an exception with error message suggesting "Access is
denied".

The problem seems to appear whenever the

DAV:contentclass

attribute is being included in the list of fields to be
saved.

The user (user1) that I used to run the C++ program is
having the correct group permission (as I can run the
regevent script on it and it will create the item).

Any pointers on how I might solve this problem?

Thank you all for listening.

Best Regards,

Chun Cheung

--------------------------------------------------------

_ConnectionPtr  pConnection(__uuidof(Connection));
_RecordPtr      pRecord(__uuidof(Record));

pConnection->Provider = _bstr_t("Exoledb.DataSource");

HRESULT hr = pConnection->Open
    ("file://./backofficestorage/evomail.com/mbx/user1",
    _bstr_t(""),
    _bstr_t(""), 0);

pConnection->BeginTrans();

// open item for writing
hr = pRecord->Open(
"file://./backofficestorage/evomail.com/mbx/user1/reg1",
pConnection->ConnectionString,
adModeReadWrite,
adCreateNonCollection,
adOpenRecordUnspecified,
_bstr_t(""),
_bstr_t(""));

pRecord->Fields->Item["DAV:contentclass"]->Value =
L"urn:content-class:storeeventreg";

pRecord->Fields->Item
["http://schemas.microsoft.com/exchange/events/Enabled"]-

Quote:>Value = VARIANT_TRUE;

pRecord->Fields->Item
["http://schemas.microsoft.com/exchange/events/MatchScope"]
->Value = _bstr_t("DEEP");

pRecord->Fields->Item
["http://schemas.microsoft.com/exchange/events/Priority"]-

Quote:>Value = (long)0x0000ffff;

pRecord->Fields->Item
["http://schemas.microsoft.com/exchange/events/SinkClass"]-

Quote:>Value = _bstr_t("ExchangeEvents.ItemEvent.1");

pRecord->Fields->Item
["http://schemas.microsoft.com/exchange/events/EventMethod"
]->Value = _variant_t("OnSyncSave");

hr = pRecord->Fields->Update();

pConnection->CommitTrans();

 
 
 

1. Problem registering event sinks

I tried using the WSS Explorer from Microsoft, but couldn't get the sink to
register.

Then I tried this in VB6:

Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rec As New ADODB.Record
Dim DAVhref

On Error GoTo err_click
DAVhref = "file://./backofficestorage/myDomain.com/Public
Folders/Library/rsSink"
cn.Provider = "ExOLEDB.Datasource"
cn.ConnectionString = "file://./backofficestorage/myDomain.com/Public
Folders/Library"
cn.Open

cn.BeginTrans
rec.Open DAVhref, cn, adModeReadWrite, _
    adCreateNonCollection Or adOpenIfExists, adDelayFetchFields

    rec.Fields("DAV:contentclass").Value = _
        "urn:content-class:storeeventreg"

rec.Fields("http://schemas.microsoft.com/exchange/events/EventMethod").Value
= _
        Array("OnSave", "OnDelete")

rec.Fields("http://schemas.microsoft.com/exchange/events/SinkClass").Value =
_
        "ExOLEDB.ScriptEventSink.1"
    rec.Fields("http://schemas.microsoft.com/exchange/events/Scope").Value =
_
        DAVhref

rec.Fields("http://schemas.microsoft.com/exchange/events/MatchScope").Value
= _
        "deep"

rec.Fields("http://schemas.microsoft.com/exchange/events/Criteria").Value =
_
        "WHERE ""DAV:ishidden"" = False"

rec.Fields("http://schemas.microsoft.com/exchange/events/ScriptUrl").Value =
_
        "E:\Intetpub\wwwroot\ExchProject\Scripts\BuildRS.vbs"

    rec.Fields.Update

cn.CommitTrans
cn.Close
rec.Close
Set cn = Nothing
Set rec = Nothing
Exit Sub

err_click:
MsgBox "Error: " & Err.Number & vbTab & Err.Description
Err.Clear

End Sub

It blows up trying to set the DAV:contentclass to
"urn:contentclass:storeeventreg"  If I change the value to anything else the
transaction completes.

If I strip out the transaction and set rec.Fields.Update after setting the
DAV:contentclass I get this error:
    "-2147217774 OLE DB object represented by this URL is locked by one or
more other processes."

I've assigned the username a role in COM+,  dismounted and mounted the store
, stopped and started SA and IS services, and rebooted.  I've run ESEUTIL
and ISINTEG (allacltests and allfoldertests).

Any help would be appreciated.  Wild guesses accepted with gratitude:)

John D. Ramsey, MCSE

2. Trouble with message filtering

3. Problem Registering Storage Event Sink on MBX folder

4. using Outlook Express with Exchange 4.0

5. Problem registering store-wide event sink for newsgroups

6. Duplicate Mailboxes in same Organization

7. Problem to register com Class with event sink

8. LDAP Address Book

9. Store Events (Register an event sink for INBOX, OnSave, for all users)

10. Debugging C++ event sinks

11. SMTP Event Sink with C++

12. about : HOWTO: Create an Exchange 2000 Store Event Sink in Visual C++

13. C++ event sinks