[IronPython] A help with an Active Directory object please.

Vizcayno Tamparantan vizcaynot at gmail.com
Sat Oct 20 06:01:20 CEST 2007


Sorry for the long content!!
I am trying to recover, in date format, the "AccountExpires" attribute from
an Active Directory database.
When an account never expires, "AccountExpires" attribute can have two
possible values: zero or 9223372036854775807,
the last large value is System.Int64 but I need to convert it to
IADsLargeInteger which is an "COM Interop Type" object of Active Directory
that then, lets me convert to date format.
I have the next C# example I took from a publication that would like to
write in ipy:

using ActivedsNET;
public static IADsLargeInteger GetLargeInteger(long value)
{
    IADsLargeInteger largeInteger = new LargeInteger();
    largeInteger.HighPart = (int) (value << 32);
    largeInteger.LowPart = (int) (value & 0xFFFFFFFF);
    return largeInteger;
}

Observe that I need to have ActivedsNET which is a runtime-callable wrapper
(RCW). After some investigation to get this as an assembly, I used next SDK
command:

tlbimp.exe activeds.tlb /out:activedsNET.dll /namespace:ActivedsNET

getting next warning messages during conversion:
TlbImp : warning TI0000 : The type library importer could not convert the
signature for the member 'ADS_OCTET_STRING.lpValue'.
TlbImp : warning TI0000 : The type library importer could not convert the
signature for the member '__MIDL___MIDL_itf_ads_0000_0002.lpValue'.
.
.
.
TlbImp : warning TI0000 : At least one of the arguments for '
IDirectorySchemaMgmt.EnumAttributes' cannot be marshaled by the runtime
marshaler.  Such arguments will therefore be passed as a pointer and may
require unsafe code to manipulate.
TlbImp : warning TI0000 : At least one of the arguments for '
IDirectorySchemaMgmt.EnumClasses' cannot be marshaled by the runtime
marshaler.  Such arguments will therefore be passed as a pointer and may
require unsafe code to manipulate.
Type library imported to c:\os\ipy\src\activedsNET.dll

After getting the .dll expected, I attempted to import into ipy 2.0a4 and
ipy 2.0a5 having the next behavior:
>>> import clr
>>> clr.AddReferenceToFile("activedsNET.dll")  #Seems not be problem here
>>> dir(activedsNET)
Traceback (most recent call last):
  File , line 0, in ##245
NameError: name 'activedsNET' is not defined

>>> dir()
['__builtins__', '__doc__', '__name__', 'clr', 'sys']  #ActivedsNET is not
showed
>>>
What do you think is bad here?
Is this possible to help me with the info I gave? or do you need additional
one.
Really, thanks for your attention.
Vizcayno.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20071020/43ba07c2/attachment.html>


More information about the Ironpython-users mailing list