Board index » cppbuilder » TADOQuery and AD multi valued properties

TADOQuery and AD multi valued properties


2006-07-03 12:51:56 AM
cppbuilder87
Hi ,
I'm trying to use ADsDSOObject provider and TADOQuery to list the members
of a security group from Active Directory. When trying to read the
property Member,
the programs responds with: Cannot convert array variant to string.
I'm using a "normal" TDBGrid to display the results. It's works fine for
single valued properties.
Any ideas ??
Thank you for helping me.
Berthold
 
 

Re:TADOQuery and AD multi valued properties

Hi ,
no answer yet - but I've some which helps me:
there are some wrappers to deal with variants and safearrays:
void __fastcall TfrmAnzeige::lvGroupsSelectItem(TObject *Sender,
TListItem *Item, bool Selected)
{
TListItem *ListItem;
TVariantT<VARIANT>varMember;
TVariantT<VARIANT>varElement;
SAFEARRAY* pSA;
TSafeArrayT<VARIANT, VT_VARIANT, 1>varArray;
if (Selected)
{
ListItem = lvMember->Items->Add();
ListItem->Caption = "***** " + Item->Caption + " *****";
cmdLDAP2->CommandText = "Select cn,adsPath,member FROM " +
QuotedStr(Item->SubItems->Strings[0]);
dsLDAP2->Recordset = cmdLDAP2->Execute();
varMember = dsLDAP2->Fields->FieldByName("member")->AsVariant;
pSA = varMember;
varArray.Attach(pSA);
for (int i=0; i < varArray.BoundsLength[0]; i++)
{
varElement = VARIANT(varArray[i]);
ListItem = lvMember->Items->Add();
ListItem->Caption = AnsiString(varElement);
}
}
}
lvMember, lvGroups are TListViews and cmdLDAP2 is TADOCommand
As the event is fired twice, I've used "if (Selected)" to perform only
when the item is selected.
"Berthold Stahn" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
Hi ,

I'm trying to use ADsDSOObject provider and TADOQuery to list the
members
of a security group from Active Directory. When trying to read the
property Member,

the programs responds with: Cannot convert array variant to string.
I'm using a "normal" TDBGrid to display the results. It's works fine for
single valued properties.

Any ideas ??


Thank you for helping me.


Berthold