IADsPropertyList and IADsPropertyEntry in .NET

  • Thread starter Thread starter Mario Rodriguez
  • Start date Start date
M

Mario Rodriguez

I'm trying the following code, but never finds the IADsPropertyList and
IADsPropertyEntry interfaces, I added the System.DirectoryServices reference
but the error persists, any idea ?

foreach(string sPropName in deCurrEntry.Properties.PropertyNames)
{
ListViewItem lvItem = lsvDetails.Items.Add(sPropName);
// get the native ADSI interface, for additional information
try
{
IADsPropertyList oPropList = (deCurrEntry.NativeObject as IADsPropertyList);
IADsPropertyEntry oPropEntry = (oPropList.GetPropertyItem(sPropName,
(int)ADSTYPEENUM.ADSTYPE_UNKNOWN) as IADsPropertyEntry);
int iADsType = oPropEntry.ADsType;
lvItem.SubItems.Add(ADsTypeToString(iADsType));
lvItem.SubItems.Add(PropertyToString(deCurrEntry, oPropEntry, iADsType));
}
catch (Exception)
{
}
}
 
These are not exposed by the DirectoryServices classes, you need to set a
reference to the activeds.tlb, or run tlbimp.exe on activeds.tlb.

Willy.
 
Hi Willy, Could you be more explicit, I have no idea what is activeds.tlb or
tlbimp.exe

thanks
 
Hi Willy, Could you be more explicit, I have no idea what is activeds.tlb or
tlbimp.exe

You need to go to your solution explorer, and click on "Add
Reference". Then on the dialog box that pops up, go to the "COM" page,
and search for the "ActiveDs Type Library" and select that one.

This will "import" that COM type library into your project, and give
you access to all the "legacy" interfaces and types, such as
IADsPropertyList

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
this operation could be done if the solution where the COM will be
referenced has a strong name ?

I tried to do it, but I receive this message compiling the solution:

Assembly generation failed -- Referenced assembly 'Interop.ActiveDs' does
not have a strong name
 
I tried to do it, but I receive this message compiling the solution:
Assembly generation failed -- Referenced assembly 'Interop.ActiveDs' does
not have a strong name

Are you trying to create a new assembly which has a strong name?? In
that case, you'd have to define the "Wrapper Assembly Key File" in
your project (Solution Explorer - Your Project > Properties > Common
Properties > General, last two entries in the pane at the right).

You need to do this BEFORE you create the interop wrapper assembly. So
in your case, you might need to remove that reference, delete any
Interop.* files in your project's directories, set the Assembly
Wrapper Key File, and then do the interop game once again.

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top