/// <summary>
 ///  The SamrSetInformationDomain method updates attributes
 ///  on a domain object. Opnum: 9 
 /// </summary>
 /// <param name="DomainHandle">
 ///  An RPC context handle, as specified in section , representing
 ///  a domain object.
 /// </param>
 /// <param name="DomainInformationClass">
 ///  An enumeration indicating which attributes to update.
 ///  See section  for a list of possible values.
 /// </param>
 /// <param name="DomainInformation">
 ///  The requested attributes and values to update. See section
 ///   for structure details.
 /// </param>
 /// <returns>
 /// status of the function call, for example: 0 indicates STATUS_SUCCESS
 /// </returns>
 public int SamrSetInformationDomain(System.IntPtr DomainHandle,
     _DOMAIN_INFORMATION_CLASS DomainInformationClass,
     //[Switch("DomainInformationClass")]
     _SAMPR_DOMAIN_INFO_BUFFER DomainInformation)
 {
     return rpc.SamrSetInformationDomain(DomainHandle, DomainInformationClass, DomainInformation);
 }
 /// <summary>
 ///  The SamrQueryInformationDomain2 method obtains attributes
 ///  from a domain object. Opnum: 46 
 /// </summary>
 /// <param name="DomainHandle">
 ///  An RPC context handle, as specified in section , representing
 ///  a domain object.
 /// </param>
 /// <param name="DomainInformationClass">
 ///  An enumeration indicating which attributes to return.
 ///  See section  for a listing of possible values.
 /// </param>
 /// <param name="Buffer">
 ///  The requested attributes on output. See section  for
 ///  structure details.
 /// </param>
 /// <returns>
 /// status of the function call, for example: 0 indicates STATUS_SUCCESS
 /// </returns>
 public int SamrQueryInformationDomain2(System.IntPtr DomainHandle,
     _DOMAIN_INFORMATION_CLASS DomainInformationClass,
     //[Switch("DomainInformationClass")]
     out _SAMPR_DOMAIN_INFO_BUFFER? Buffer)
 {
     return rpc.SamrQueryInformationDomain2(DomainHandle, DomainInformationClass, out Buffer);
 }
        /// <summary>
        ///  The SamrQueryInformationDomain2 method obtains attributes
        ///  from a domain object. Opnum: 46 
        /// </summary>
        /// <param name="DomainHandle">
        ///  An RPC context handle, as specified in section , representing
        ///  a domain object.
        /// </param>
        /// <param name="DomainInformationClass">
        ///  An enumeration indicating which attributes to return.
        ///  See section  for a listing of possible values.
        /// </param>
        /// <param name="Buffer">
        ///  The requested attributes on output. See section  for
        ///  structure details.
        /// </param>
        /// <returns>
        /// status of the function call, for example: 0 indicates STATUS_SUCCESS
        /// </returns>
        public int SamrQueryInformationDomain2(
            IntPtr DomainHandle,
            _DOMAIN_INFORMATION_CLASS DomainInformationClass,
            out _SAMPR_DOMAIN_INFO_BUFFER? Buffer)
        {
            const ushort opnum = 46;
            Int3264[] paramList;
            int retVal = 0;

            paramList = new Int3264[] {
                DomainHandle,
                (int)DomainInformationClass,
                IntPtr.Zero,
                IntPtr.Zero
            };

            using (RpceInt3264Collection outParamList = RpceCall(paramList, opnum))
            {
                Buffer = TypeMarshal.ToNullableStruct<_SAMPR_DOMAIN_INFO_BUFFER>(
                    Marshal.ReadIntPtr(outParamList[2]), DomainInformationClass, null, null);
                retVal = outParamList[3].ToInt32();
            }

            return retVal;
        }
        /// <summary>
        ///  The SamrSetInformationDomain method updates attributes
        ///  on a domain object. Opnum: 9 
        /// </summary>
        /// <param name="DomainHandle">
        ///  An RPC context handle, as specified in section , representing
        ///  a domain object.
        /// </param>
        /// <param name="DomainInformationClass">
        ///  An enumeration indicating which attributes to update.
        ///  See section  for a list of possible values.
        /// </param>
        /// <param name="DomainInformation">
        ///  The requested attributes and values to update. See section
        ///   for structure details.
        /// </param>
        /// <returns>
        /// status of the function call, for example: 0 indicates STATUS_SUCCESS
        /// </returns>
        public int SamrSetInformationDomain(
            IntPtr DomainHandle,
            _DOMAIN_INFORMATION_CLASS DomainInformationClass,
            _SAMPR_DOMAIN_INFO_BUFFER DomainInformation)
        {
            const ushort opnum = 9;
            Int3264[] paramList;
            int retVal = 0;

            SafeIntPtr pDomainInformation = TypeMarshal.ToIntPtr(
                DomainInformation,
                DomainInformationClass,
                null,
                null);

            paramList = new Int3264[] {
                DomainHandle,
                (int)DomainInformationClass,
                pDomainInformation,
                IntPtr.Zero
            };

            try
            {
                using (RpceInt3264Collection outParamList = RpceCall(paramList, opnum))
                {
                    retVal = outParamList[3].ToInt32();
                }
            }
            finally
            {
                pDomainInformation.Dispose();
            }

            return retVal;
        }
 /// <summary>
 ///  Decodes the request stub, and fills the fields of the class
 /// </summary>
 /// <param name="sessionContext">The session context of the request received</param>
 /// <param name="requestStub">The request stub got from RPCE layer</param>
 internal override void Decode(SamrServerSessionContext sessionContext, byte[] requestStub)
 {
     using (RpceInt3264Collection inParams = RpceStubDecoder.ToParamList(
    RpceStubHelper.GetPlatform(),
     SamrRpcStubFormatString.TypeFormatString,
     new RpceStubExprEval[]{
         new RpceStubExprEval(SamrRpcAdapter.samr_SAMPR_USER_LOGON_INFORMATIONExprEval_0000),
         new RpceStubExprEval(SamrRpcAdapter.samr_SAMPR_USER_LOGON_HOURS_INFORMATIONExprEval_0001),
         new RpceStubExprEval(SamrRpcAdapter.samr_SAMPR_USER_ACCOUNT_INFORMATIONExprEval_0002),
         new RpceStubExprEval(SamrRpcAdapter.samr_SAMPR_LOGON_HOURSExprEval_0003)},
     SamrRpcStubFormatString.ProcFormatString,
     SamrRpcStubFormatString.ProcFormatStringOffsetTable[(int)Opnum],
     false,
     requestStub))
     {
         DomainHandle = inParams[0].ToIntPtr();
         DomainInformationClass = (_DOMAIN_INFORMATION_CLASS)inParams[1].ToInt32();
         DomainInformation = TypeMarshal.ToStruct<_SAMPR_DOMAIN_INFO_BUFFER>(
             inParams[2].ToIntPtr(),
             DomainInformationClass, null, null);
     }
 }