Article View: borland.public.cppbuilder.database.ado
Article #404Re: TADOQuery and AD multi valued properties
From: Berthold Stahn
Date: Wed, 01 Nov 2006 10:19
Date: Wed, 01 Nov 2006 10:19
57 lines
2936 bytes
2936 bytes
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" <Berthold.Stahn@teleos-web.de> schrieb im Newsbeitrag
news:44a7f9b9@newsgroups.borland.com...
> 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
Technical Details
Message-ID:
<454874cd@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<44a7f9b9@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,2a617c414ec65eb2 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Berthold Stahn" <Berthold.Stahn@teleos-web.de> From: "Berthold Stahn" <Berthold.Stahn@teleos-web.de> Newsgroups: borland.public.cppbuilder.database.ado References: <44a7f9b9@newsgroups.borland.com> Subject: Re: TADOQuery and AD multi valued properties Date: Wed, 1 Nov 2006 11:19:42 +0100 Lines: 58 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 NNTP-Posting-Host: 87.245.36.207 Message-ID: <454874cd@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1162376397 87.245.36.207 (1 Nov 2006 02:19:57 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail