n***@gmail.com
2006-03-03 22:27:57 UTC
Hi,
I am trying to get distinguished names of mailboxes of a exchange
mailstore. This mailstore has about 2000 mailboxes, and homeMDBBL
multivalue/list attribute has DNs of mailboxes that it holds. The
following code works if this attribute has about 50 values/DNs. It
returns 0 for col.dwNumValues for mail stores that has more than 2000
mailboxes. I have attached the code snippet. Can somebody tell me what
is wrong with this query?
// Search entire subtree from root.
SearchPrefs[0].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
SearchPrefs[0].vValue.dwType = ADSTYPE_INTEGER;
SearchPrefs[0].vValue.Integer = ADS_SCOPE_SUBTREE;
SearchPrefs[1].dwSearchPref = ADS_SEARCHPREF_PAGESIZE;
SearchPrefs[1].vValue.dwType = ADSTYPE_INTEGER;
SearchPrefs[1].vValue.Integer = 500;
// Set the search preference.
hr = spGCSearch->SetSearchPreference(SearchPrefs, 2);
if(FAILED(hr))
return hr;
// Set attributes to return.
LPWSTR rgpwszAttributes[] = {L"cn", L"homeMDBBL"};
// Execute the search.
hr = spGCSearch->ExecuteSearch( L"(objectClass=msExchPrivateMDB)",
rgpwszAttributes, 2, &hSearch);
if(FAILED(hr))
return hr;
// Get the first result row.
hr = spGCSearch->GetFirstRow(hSearch);
while(S_OK == hr)
{
ADS_SEARCH_COLUMN col;
// Enumerate the retrieved attributes.
for(DWORD i = 0; i < dwNumAttributes; i++)
{
hr = spGCSearch->GetColumn(hSearch, rgpwszAttributes[i], &col);
if(SUCCEEDED(hr))
{
switch(col.dwADsType)
{
case ADSTYPE_DN_STRING:
if (_wcsicmp(rgpwszAttributes[i], L"homeMDBBL") == 0)
{
// This line returns 0 for large multivalue column result
wprintf(L"homeMDBBL found Items: %d\n", col.dwNumValues);
CExString csTemp;
for (DWORD j = 0L; j < col.dwNumValues; j++)
{
// Exclude any SMTP or SystemMailbox mailboxes
csTemp = col.pADsValues[j].DNString;
wprintf(L"%s\n", (LPCWSTR)csTemp);
}
}
else
{
wprintf(L"%s: %s\n", rgpwszAttributes[i],
col.pADsValues[0].DNString);
}
break;
case ADSTYPE_CASE_IGNORE_STRING:
wprintf(L"%s: %s\n", rgpwszAttributes[i],
col.pADsValues[0].CaseExactString);
break;
}
// Free the column.
spGCSearch->FreeColumn(&col);
}
}
// Get the next row.
hr = spGCSearch->GetNextRow(hSearch);
}
Thanks
soma
I am trying to get distinguished names of mailboxes of a exchange
mailstore. This mailstore has about 2000 mailboxes, and homeMDBBL
multivalue/list attribute has DNs of mailboxes that it holds. The
following code works if this attribute has about 50 values/DNs. It
returns 0 for col.dwNumValues for mail stores that has more than 2000
mailboxes. I have attached the code snippet. Can somebody tell me what
is wrong with this query?
// Search entire subtree from root.
SearchPrefs[0].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
SearchPrefs[0].vValue.dwType = ADSTYPE_INTEGER;
SearchPrefs[0].vValue.Integer = ADS_SCOPE_SUBTREE;
SearchPrefs[1].dwSearchPref = ADS_SEARCHPREF_PAGESIZE;
SearchPrefs[1].vValue.dwType = ADSTYPE_INTEGER;
SearchPrefs[1].vValue.Integer = 500;
// Set the search preference.
hr = spGCSearch->SetSearchPreference(SearchPrefs, 2);
if(FAILED(hr))
return hr;
// Set attributes to return.
LPWSTR rgpwszAttributes[] = {L"cn", L"homeMDBBL"};
// Execute the search.
hr = spGCSearch->ExecuteSearch( L"(objectClass=msExchPrivateMDB)",
rgpwszAttributes, 2, &hSearch);
if(FAILED(hr))
return hr;
// Get the first result row.
hr = spGCSearch->GetFirstRow(hSearch);
while(S_OK == hr)
{
ADS_SEARCH_COLUMN col;
// Enumerate the retrieved attributes.
for(DWORD i = 0; i < dwNumAttributes; i++)
{
hr = spGCSearch->GetColumn(hSearch, rgpwszAttributes[i], &col);
if(SUCCEEDED(hr))
{
switch(col.dwADsType)
{
case ADSTYPE_DN_STRING:
if (_wcsicmp(rgpwszAttributes[i], L"homeMDBBL") == 0)
{
// This line returns 0 for large multivalue column result
wprintf(L"homeMDBBL found Items: %d\n", col.dwNumValues);
CExString csTemp;
for (DWORD j = 0L; j < col.dwNumValues; j++)
{
// Exclude any SMTP or SystemMailbox mailboxes
csTemp = col.pADsValues[j].DNString;
wprintf(L"%s\n", (LPCWSTR)csTemp);
}
}
else
{
wprintf(L"%s: %s\n", rgpwszAttributes[i],
col.pADsValues[0].DNString);
}
break;
case ADSTYPE_CASE_IGNORE_STRING:
wprintf(L"%s: %s\n", rgpwszAttributes[i],
col.pADsValues[0].CaseExactString);
break;
}
// Free the column.
spGCSearch->FreeColumn(&col);
}
}
// Get the next row.
hr = spGCSearch->GetNextRow(hSearch);
}
Thanks
soma