Hi Andy

System.DirectoryServices is just a wrapper around ADSI AFAIK. I already
have a VB6 library with classes that wrap around ADSI and while that is
well optimized, my LDAP library, so far, can read up to 7 times faster.

Also there is much more scope for other things such as multi-threading (my
library can run the same search on multiple roots at the same time) and use
of Server Controls (I have managed to get a Persistent Search working) etc.



I think I know what I want to do, but I find it difficult to work out
exactly how to do it.

My plan now is:-

Write an LDAP modification class that accepts a string[] of the new values,
uses Marshal.StringToHGlobalAuto to make a copy of them (no need to worry
about GC moving things then) and store the IntPtrs in an array (also in
HGlobal alloc'ed memory), that way I just have an IntPtr to the start of
this array to store in the structure which, I believe (hope), will be
easily marshalled and passed to the LDAP API. If I then add IDispose
functionality the class will be self-contained and relatively efficient
memory wise.

Can anyone see any problems with the above approach?

Cheers
Simon

PS It would be nice to be able to just get an IntPtr directly to the
string, which I believe is an optimization used by the Marshaler since it
is immutable, to save having to copy the string. Is this possible and what
could I do about ensuring it is pinned for the duration? Does anyone have
any insight on this?

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to