Yes, you're absolutely right. Thank you very much!
"Joe Kaplan" wrote:
> Shouldn't you be passing in the byte array, meetingBlob, and not the
> structure, blob, to the DirectoryEntry?
>
> Joe K.
>
> --
> Joe Kaplan-MS MVP Directory Services Programming
> Co-author of "The .NET Developer's Guide to Directory Services Programming"
>
http://www.directoryprogramming.net > --
> "Pucca" <Pucca@discussions.microsoft.com> wrote in message
> news:847141EC-1D73-419E-95CC-1B9CE3D8E5F2@microsoft.com...
> >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.
>
>