A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

LDAP access



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 5th 08, 04:01 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 24
Default LDAP access

On Dec 2, 11:19šam, Sergeichik
wrote:
I have write:

bool ReadAD()
{

// Initialize MAPI.
HRESULT hRes = S_OK;

if (FAILED(hRes = MAPIInitialize(NULL)))
{
š š š š return false;

}

HRESULT hr;
LPMAPISESSION pSess;
hr = MAPILogonEx(0, NULL, NULL, MAPI_EXTENDED, &pSess);
if(FAILED(hr))
{
š š š š MAPIUninitialize();
š š š š return false;

}

// open address book
LPADRBOOK pAddr;
hr = pSess-OpenAddressBook(0, 0, 0, &pAddr);
if(FAILED(hr))
{
š š š š pSess-Logoff(0, 0, 0);
š š š š MAPIUninitialize();
š š š š return false;

};

// open root container by passing a NULL entry ID
ULONG obj_type;
LPMAPICONTAINER rootContainer = NULL;
hr = pAddr-OpenEntry( 0, NULL, NULL, 0, &obj_type,
(LPUNKNOWN*)&rootContainer);

//Get าierarchy table
LPMAPITABLE hierh_table;
hr = rootContainer-GetHierarchyTable(0, &hierh_table);

//The rest is actual code:
SizedSPropTagArray( 1, columns) = { 1, PR_ENTRYID};

SPropValue criteria[ 2];
SRestriction restrictions[ 2];
SRestriction andNode;

criteria[ 0].ulPropTag = PR_AB_PROVIDER_ID;
criteria[ 0].Value.bin.cb = 16;
const BYTE muid[] = MUIDEMSAB;
criteria[ 0].Value.bin.lpb = (BYTE *) muid;
restrictions[ 0].rt = RES_PROPERTY;
restrictions[ 0].res.resProperty.relop = RELOP_EQ;
restrictions[ 0].res.resProperty.ulPropTag = PR_AB_PROVIDER_ID;
restrictions[ 0].res.resProperty.lpProp = &criteria[ 0];

criteria[ 1].ulPropTag = PR_EMS_AB_CONTAINERID;
criteria[ 1].Value.l = 0;
restrictions[ 1].rt = RES_PROPERTY;
restrictions[ 1].res.resProperty.relop = RELOP_EQ;
restrictions[ 1].res.resProperty.ulPropTag = PR_EMS_AB_CONTAINERID;
restrictions[ 1].res.resProperty.lpProp = &criteria[ 1];

andNode.rt = RES_AND;
andNode.res.resAnd.cRes = 2;
andNode.res.resAnd.lpRes = &restrictions[ 0];

LPSRowSet rows = NULL;

if( SUCCEEDED( HrQueryAllRows( hierh_table,
š (LPSPropTagArray) &columns, &andNode, NULL, 0, &rows)))
{
š š š š if( rows-cRows)
š š š š {
š š š š š š int rows_count = rows-cRows;
š š š š }
š š š š FreeProws( rows);

}

if (hierh_table) hierh_table-Release();
if (rootContainer) rootContainer-Release();
if (pAddr) pAddr-Release();
if (pSess) pSess-Release();

MAPIUninitialize();

return true;

}

But rows_count is 0, although Outlook have connected AD with several
contacts in it.

What's wrong ?


Look through your address book containers using OutlookSpy/MFCMAPI or
else take out the restriction and dump those properties for all the
rows and see what's not matching up. You're looking for a container
which is probably called "Global Address List", but querying by name
is unwise.
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LDAP access from Outlook addin Sergeichik Outlook - General Queries 3 December 5th 08 02:36 PM
LDAP Write access? ChinaLamb Outlook - General Queries 1 June 2nd 08 05:33 AM
Write access to a LDAP server. ChinaLamb Outlook - General Queries 0 May 31st 08 03:03 AM
Cannot access LDAP address book with Outlook 2002 BadCop Outlook - General Queries 2 May 8th 06 07:36 PM
LDAP Ryan Outlook - Installation 0 March 28th 06 05:18 PM


All times are GMT +1. The time now is 09:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ฉ2004-2025 Outlook Banter.
The comments are property of their posters.