"SHEBERT" <SH*****@discussions.microsoft.comwrote in message
news:43**********************************@microsof t.com...
| In c#,
|
| How can I get the "accountExpires" without having to register the ACTIVEDS
| COM object on the client?
|
You don't have to register activeds on the client, activeds is part of the
system install.
| DirectoryEntry returns almost all value with the COM object except for
dates.
|
| Why MS designed .NET object returning COM object? I hoped we got rid of
the
| complexity of COM in .NET
|
Because the functionality was there and stable?
| Now it seems I have to make install program for .NET program to installed
| COM DLL only because .NET object are returning COM object.
Again, you don't have to install anything COM, activeds.tlb and activeds.dll
are already installed.
You can "late bind" to the underlying activeds.dll by using reflection, or
if that's also too complicated, you can use vb.net which supports this
out-of-the-box.
But I guess you are talking about the interop assembly, you can get rid of
it by using reflection to invoke members on the COM interface, or you can
use vb.net which supports late binding at the language level.
// say user is a DirectoryEntry representing a AD user object.
long expDate =
LongFromLargeInteger(user.Properties["accountExpires"].Value);
//Now, convert the long returned to dateTime, but beware that -1 is returned
for "account never expires", which is an invalid data!
....
private static long LongFromLargeInteger( object largeInteger )
{
System.Type type = largeInteger.GetType();
int highPart =
(int)type.InvokeMember("HighPart",BindingFlags.Get Property,
null, largeInteger, null);
int lowPart = (int)type.InvokeMember("LowPart",BindingFlags.GetP roperty,
null, largeInteger, null);
return (long)highPart << 32 | (uint)lowPart;
}
Willy.