I got the following error:
System.ArgumentException: Value does not fall within the expected range. At
System.DirectorySservcies.Interop.UnsafeNativeMethods.IAds.PutEx(Int32
InControlCode, String bstrName, Object vProp) at
System.DirecotryServices.PropertyValueCollection.set_Value(Object value)
public struct Blob
{
public IntPtr pData;
public int nLength;//the length of the actual data in nLength and
public int nSize;//the length of the buffer for the data in nSize.
}
[DllImport("PaAsn.dll", CharSet = CharSet.Unicode)]
public static extern DE_ERRORS EncodeContextDefaults(ref IntPtr blob,
[In, Out]ContextDefaults m);
// allocate memry for the blob
IntPtr pBlob = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CDS.Blob)));
// call the function passing the pointer to the blob
byrefEncodeContextDefaults
CDS.LibWrap.EncodeContextDefaults(ref pBlob, contextDefaults);
// copy the unmanaged blob to managed struct Blob
CDS.Blob blob = (CDS.Blob)Marshal.PtrToStructure(pBlob, typeof(CDS.Blob));
// allocate byte array with size of blob.nLength
byte[] meetingBlob = new byte[blob.nLength];
// marshal the data pointed to by pData into the byte array
System.Runtime.InteropServices.Marshal.Copy(blob.pData, meetingBlob, 0,
blob.nLength);
defaultContext.Properties["meetingBlob"].Value = ((object)(blob));
defaultContext.CommitChanges();
Thank you.
Joe Kaplan - 02 Nov 2007 21:50 GMT
Shouldn't you be passing in the byte array, meetingBlob, and not the
structure, blob, to the DirectoryEntry?
Joe K.

Signature
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
>I got the following error:
> System.ArgumentException: Value does not fall within the expected range.
[quoted text clipped - 30 lines]
>
> Thank you.
Pucca - 03 Nov 2007 00:26 GMT
Yes, you're absolutely right. Thank you very much!

Signature
Thanks.
> Shouldn't you be passing in the byte array, meetingBlob, and not the
> structure, blob, to the DirectoryEntry?
[quoted text clipped - 35 lines]
> >
> > Thank you.