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
Prev Previous Post   Next Post Next
  #1  
Old November 26th 08, 08:53 AM posted to microsoft.public.outlook.program_addins
Sergeichik
external usenet poster
 
Posts: 21
Default LDAP access

I'm trying to read AD(Active directory) content from Outlook addin (C++,
MAPI) by the following way:
(AD's in Outlook are represented by LDAP, and neither I nor plugin don't
know their logins or passwords, hidden somewhere in depth of Outlook internal
data)

accessing containers:
//////////////////////////////////////////////
HRESULT hr;
CComPtrIMAPISession pSess;
hr = MAPILogonEx(0, NULL, NULL, MAPI_EXTENDED|MAPI_UNICODE, &pSess);
if(FAILED(hr))
{
errorMes = _T("MAPI Logon failed.");
return false;
}
// open address book
CComPtrIAddrBook pAddr;
hr = pSess-OpenAddressBook(0, 0, 0, &pAddr);
if(FAILED(hr))
{
pSess-Logoff(0, 0, 0);
return false;
};

LPSRowSet containers;
hr = pAddr-GetSearchPath(MAPI_UNICODE , &containers);
if (hr!=S_OK)
{
pAddr.Release();
pSess-Logoff(0, 0, 0);
return false;
}

// number of folders in address book
long cont_count = containers-cRows;
if (cont_count = 0)
{
pAddr.Release();
pSess-Logoff(0, 0, 0);
return false;
}


for (int folder_number = 0; folder_number cont_count; folder_number++)
{
WCHAR tx [30];
_itow(folder_number, tx, 10);
CAtlString f_mess = _T("Processing folder number '");
f_mess += CAtlString(tx); f_mess += _T("' from address book.");


SRow* folder_row = &containers-aRow[folder_number];
if (!folder_row)
{
continue;
}

LPSPropValue lpDN_cont =
PpropFindProp(folder_row-lpProps,folder_row-cValues,PR_ENTRYID);
if (!lpDN_cont)
{
continue;
}

_PV* ContainerEntryId = NULL;
ContainerEntryId = &lpDN_cont-Value;
if (!ContainerEntryId)
{
continue;
}
ReadContainerContents(pAddr, ContainerEntryId);
}

///////////////////////////////////////////////////////////////////////////////
// reading container ..
void ReadContainerContents(CComPtrIAddrBook& pAddr, _PV* ContainerEntryId)
{

HRESULT hr = S_OK;
ULONG ulCount = NULL;
LPSRowSet pRows = NULL;
ULONG cbeid = 0L;
LPENTRYID lpeid = NULL;
LPMAPITABLE lpMAPItbl = NULL;
LPABCONT lpGAL = NULL;


if ((pAddr == NULL)||(ContainerEntryId == NULL)) return;

// SizedSPropTagArray(2, Columns) =
// {2, {PR_ENTRYID, PR_DISPLAY_TYPE}};

LPUNKNOWN lpIUnknown = NULL;
ULONG ulObjType = NULL;

if (FAILED(pAddr-OpenEntry(ContainerEntryId-bin.cb,
(LPENTRYID)ContainerEntryId-bin.lpb, NULL, MAPI_BEST_ACCESS,
&ulObjType, (LPUNKNOWN*)&lpIUnknown)))
{
return;
}

//See if it is an address book container
// If no, return ...
if (ulObjType != MAPI_ABCONT))
{
return;
}


ULONG ulFlags = NULL;
IABContainer* lpABContainer = static_castIABContainer*(lpIUnknown);
//cast the IUnknown pointer returned from previous function to what we need
hr = lpABContainer-GetContentsTable(ulFlags, &lpMAPItbl);
// ASSERT(lpMAPItbl);
if (hr!=S_OK)
{
if (lpABContainer) lpABContainer-Release();
return;
}

ULONG ulRows; //Number of rows in the MAPI table

hr = lpMAPItbl-GetRowCount(0, &ulRows);
if (hr!=S_OK)
{
if (lpMAPItbl) lpMAPItbl-Release();
if (lpABContainer) lpABContainer-Release();
return;
}

if (ulRows = 0)
{
// MessageBox("No contacts was finded");
if (lpMAPItbl) lpMAPItbl-Release();
if (lpABContainer) lpABContainer-Release();
return;
}

// ... process here founded contacts ..

}
/////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////

But haven't any success in case of AD!!
I can read the names of AD LDAP directories(by such a way) as well as usual
local 'Address book' folders,
but if I try to read the count of contacts in them, I receive 0(zero).
Though, local folders quering return valid number of contcts (not zero) and
then I can read all of them fully.
Sure, there are some contacts in my LDAP directory exist certain and can be
viewed from the Outlook contacts book !!
And I can access them through another technology (ADO).
But need through MAPI(for example), without knowing login and password which
is already stored somewhere in Outlook and I don't authorized to know them.
Best regards, SergK.

 




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 01:36 PM
LDAP Write access? ChinaLamb Outlook - General Queries 1 June 2nd 08 04:33 AM
Write access to a LDAP server. ChinaLamb Outlook - General Queries 0 May 31st 08 02:03 AM
Cannot access LDAP address book with Outlook 2002 BadCop Outlook - General Queries 2 May 8th 06 06:36 PM
LDAP Ryan Outlook - Installation 0 March 28th 06 04:18 PM


All times are GMT +1. The time now is 12:31 PM.


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.