Example #1
0
        /// <summary>
        /// Convert byte array to DRS_EXTENSIONS_INT
        /// </summary>
        /// <param name="data">data source</param>
        /// <returns>DRS_EXTENSIONS_INT</returns>
        public static DRS_EXTENSIONS_INT?ConvertByteToDrext(byte[] data)
        {
            DRS_EXTENSIONS_INT ret = new DRS_EXTENSIONS_INT();
            bool passed            = false;

            do
            {
                ret.cb      = (uint)data.Length;
                ret.dwFlags = BitConverter.ToUInt32(data, 4);
                byte[] tmp = new byte[16];
                Array.Copy(data, 8, tmp, 0, 16);
                ret.SiteObjGuid = new Guid(tmp);
                ret.Pid         = BitConverter.ToInt32(data, 24);
                ret.dwReplEpoch = BitConverter.ToUInt32(data, 28);
                ret.dwFlagsExt  = BitConverter.ToUInt32(data, 32);
                tmp             = new byte[16];
                Array.Copy(data, 36, tmp, 0, 16);
                ret.ConfigObjGUID = new Guid(tmp);
                passed            = true;
            }while (false);

            if (passed)
            {
                return(ret);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// Convert the DRS_EXTENSIONS_INT to DRS_EXTENSIONS
        /// </summary>
        /// <param name="extensions">the struct of DRS_EXTENSIONS</param>
        /// <returns>the general struct of DRS_EXTENSIONS_INT</returns>
        public static DRS_EXTENSIONS EncodeDrsExtensions(DRS_EXTENSIONS_INT extensions)
        {
            byte[]         extensionsBytes = TypeMarshal.ToBytes <DRS_EXTENSIONS_INT>(extensions);
            DRS_EXTENSIONS drsExtensions   = new DRS_EXTENSIONS();

            drsExtensions.cb  = extensions.cb;
            drsExtensions.rgb = new byte[drsExtensions.cb];
            Buffer.BlockCopy(extensionsBytes, Marshal.SizeOf(drsExtensions.cb),
                             drsExtensions.rgb, 0, drsExtensions.rgb.Length);
            return(drsExtensions);
        }
        public object Clone()
        {
            DrsrClientSessionContext ret = new DrsrClientSessionContext();

            ret.domainFunLevel = this.domainFunLevel;
            ret.drsHandle      = this.drsHandle;
            ret.rpcHandle      = this.rpcHandle;
            if (this.serverExtensions.HasValue)
            {
                DRS_EXTENSIONS_INT ext = new DRS_EXTENSIONS_INT();
                ext.cb               = this.serverExtensions.Value.cb;
                ext.ConfigObjGUID    = this.serverExtensions.Value.ConfigObjGUID;
                ext.dwFlags          = this.serverExtensions.Value.dwFlags;
                ext.dwFlagsExt       = this.serverExtensions.Value.dwFlagsExt;
                ext.dwReplEpoch      = this.serverExtensions.Value.dwReplEpoch;
                ext.Pid              = this.serverExtensions.Value.Pid;
                ext.SiteObjGuid      = this.serverExtensions.Value.SiteObjGuid;
                ret.serverExtensions = ext;
            }
            return(ret);
        }