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 » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

LDAP access from Outlook addin



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 25th 08, 07:18 PM posted to microsoft.public.outlook
Sergeichik
external usenet poster
 
Posts: 21
Default LDAP access from Outlook addin

I'm trying to read AD(Active directory) contence 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.
  #2  
Old December 2nd 08, 12:01 AM posted to microsoft.public.outlook
Brian Tillman [MVP - Outlook]
external usenet poster
 
Posts: 4,874
Default LDAP access from Outlook addin

"Sergeichik" wrote in message
...

I'm trying to read AD(Active directory) contence 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)


You're better off asking in microsoft.public.outlook.program_addins
--
Brian Tillman [MVP-Outlook]

  #3  
Old December 5th 08, 12:09 PM posted to microsoft.public.outlook
Sergeichik
external usenet poster
 
Posts: 21
Default LDAP access from Outlook addin



"Brian Tillman [MVP - Outlook]" wrote:


You're better off asking in microsoft.public.outlook.program_addins
--
Brian Tillman [MVP-Outlook]




Why ? I have a bad english ?
  #4  
Old December 5th 08, 02:36 PM posted to microsoft.public.outlook
Brian Tillman [MVP - Outlook]
external usenet poster
 
Posts: 4,874
Default LDAP access from Outlook addin

"Sergeichik" wrote in message
...

Why ? I have a bad english ?


No, because .program_addins is where the add-in programmers visit and you're
more likely to get good advice there.
--
Brian Tillman [MVP-Outlook]

 




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 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
Outlook, LDAP contacts from AD Martin Červenka Outlook - General Queries 0 March 3rd 08 10:26 AM
VB6 Outlook Com Addin cant access registry or utilize shell execute [email protected] Add-ins for Outlook 5 September 28th 07 03:15 PM
Cannot access LDAP address book with Outlook 2002 BadCop Outlook - General Queries 2 May 8th 06 07:36 PM


All times are GMT +1. The time now is 01:12 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.