/// <summary>
 ///  The SamrGetAliasMembership method obtains the union
 ///  of all aliases that a given set of SIDs is a member
 ///  of. Opnum: 16 
 /// </summary>
 /// <param name="DomainHandle">
 ///  An RPC context handle, as specified in section , representing
 ///  a domain object.
 /// </param>
 /// <param name="SidArray">
 ///  A list of SIDs.
 /// </param>
 /// <param name="Membership">
 ///  The union of all aliases (represented by RIDs) that
 ///  all SIDs in SidArray are a member of.
 /// </param>
 /// <returns>
 /// status of the function call, for example: 0 indicates STATUS_SUCCESS
 /// </returns>
 public int SamrGetAliasMembership(System.IntPtr DomainHandle,
     _SAMPR_PSID_ARRAY SidArray,
     out _SAMPR_ULONG_ARRAY Membership)
 {
     return rpc.SamrGetAliasMembership(DomainHandle, SidArray, out Membership);
 }
 /// <summary>
 ///  The SamrLookupNamesInDomain method translates a set
 ///  of account names into a set of RIDs. Opnum: 17 
 /// </summary>
 /// <param name="DomainHandle">
 ///  An RPC context handle, as specified in section , representing
 ///  a domain object.
 /// </param>
 /// <param name="Count">
 ///  The number of elements in Names. The maximum value of
 ///  1,000 is chosen to limit the amount of memory that
 ///  the client can force the server to allocate.
 /// </param>
 /// <param name="Names">
 ///  An array of strings that are to be mapped to RIDs.
 /// </param>
 /// <param name="RelativeIds">
 ///  An array of RIDs of accounts that correspond to the
 ///  elements in Names.
 /// </param>
 /// <param name="Use">
 ///  An array of SID_NAME_USE enumeration values that describe
 ///  the type of account for each entry in RelativeIds.
 /// </param>
 /// <returns>
 /// status of the function call, for example: 0 indicates STATUS_SUCCESS
 /// </returns>
 public int SamrLookupNamesInDomain(System.IntPtr DomainHandle,
     uint Count,
     //[Length("Count")] [Size("1000")]
     _RPC_UNICODE_STRING[] Names,
     out _SAMPR_ULONG_ARRAY RelativeIds,
     out _SAMPR_ULONG_ARRAY Use)
 {
     return rpc.SamrLookupNamesInDomain(DomainHandle, Count, Names, out RelativeIds, out Use);
 }
        /// <summary>
        ///  The SamrLookupNamesInDomain method translates a set
        ///  of account names into a set of RIDs. Opnum: 17 
        /// </summary>
        /// <param name="DomainHandle">
        ///  An RPC context handle, as specified in section , representing
        ///  a domain object.
        /// </param>
        /// <param name="Count">
        ///  The number of elements in Names. The maximum value of
        ///  1,000 is chosen to limit the amount of memory that
        ///  the client can force the server to allocate.
        /// </param>
        /// <param name="Names">
        ///  An array of strings that are to be mapped to RIDs.
        /// </param>
        /// <param name="RelativeIds">
        ///  An array of RIDs of accounts that correspond to the
        ///  elements in Names.
        /// </param>
        /// <param name="Use">
        ///  An array of SID_NAME_USE enumeration values that describe
        ///  the type of account for each entry in RelativeIds.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// thrown when the pNames is null.
        /// </exception>
        /// <returns>
        /// status of the function call, for example: 0 indicates STATUS_SUCCESS
        /// </returns>
        public int SamrLookupNamesInDomain(
            IntPtr DomainHandle,
            uint Count,
            _RPC_UNICODE_STRING[] Names,
            out _SAMPR_ULONG_ARRAY RelativeIds,
            out _SAMPR_ULONG_ARRAY Use)
        {
            const ushort opnum = 17;
            Int3264[] paramList;
            int retVal = 0;

            if (Names == null)
            {
                throw new ArgumentNullException("Names");
            }

            SafeIntPtr pNames = TypeMarshal.ToIntPtr(Names);

            paramList = new Int3264[] {
                DomainHandle,
                Count,
                Marshal.ReadIntPtr(pNames),
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero
            };

            try
            {
                using (RpceInt3264Collection outParamList = RpceCall(paramList, opnum))
                {
                    RelativeIds = TypeMarshal.ToStruct<_SAMPR_ULONG_ARRAY>(outParamList[3]);
                    Use = TypeMarshal.ToStruct<_SAMPR_ULONG_ARRAY>(outParamList[4]);
                    retVal = outParamList[5].ToInt32();
                }
            }
            finally
            {
                pNames.Dispose();
            }

            return retVal;
        }
 /// <summary>
 ///  The SamrLookupIdsInDomain method translates a set of
 ///  RIDs into account names. Opnum: 18 
 /// </summary>
 /// <param name="DomainHandle">
 ///  An RPC context handle, as specified in section , representing
 ///  a domain object.
 /// </param>
 /// <param name="Count">
 ///  The number of elements in RelativeIds. The maximum value
 ///  of 1,000 is chosen to limit the amount of memory that
 ///  the client can force the server to allocate.
 /// </param>
 /// <param name="RelativeIds">
 ///  An array of RIDs that are to be mapped to account names.
 /// </param>
 /// <param name="Names">
 ///  A structure containing an array of account names that
 ///  correspond to the elements in RelativeIds.
 /// </param>
 /// <param name="Use">
 ///  A structure containing an array of SID_NAME_USE enumeration
 ///  values that describe the type of account for each entry
 ///  in RelativeIds.
 /// </param>
 /// <returns>
 /// status of the function call, for example: 0 indicates STATUS_SUCCESS
 /// </returns>
 public int SamrLookupIdsInDomain(System.IntPtr DomainHandle,
     uint Count,
     //[Length("Count")] [Size("1000")]
     uint[] RelativeIds,
     out _SAMPR_RETURNED_USTRING_ARRAY Names,
     out _SAMPR_ULONG_ARRAY Use)
 {
     return rpc.SamrLookupIdsInDomain(DomainHandle, Count, RelativeIds, out Names, out Use);
 }
        /// <summary>
        ///  The SamrGetAliasMembership method obtains the union
        ///  of all aliases that a given set of SIDs is a member
        ///  of. Opnum: 16 
        /// </summary>
        /// <param name="DomainHandle">
        ///  An RPC context handle, as specified in section , representing
        ///  a domain object.
        /// </param>
        /// <param name="SidArray">
        ///  A list of SIDs.
        /// </param>
        /// <param name="Membership">
        ///  The union of all aliases (represented by RIDs) that
        ///  all SIDs in SidArray are a member of.
        /// </param>
        /// <returns>
        /// status of the function call, for example: 0 indicates STATUS_SUCCESS
        /// </returns>
        public int SamrGetAliasMembership(
            IntPtr DomainHandle,
            _SAMPR_PSID_ARRAY SidArray,
            out _SAMPR_ULONG_ARRAY Membership)
        {
            const ushort opnum = 16;
            Int3264[] paramList;
            int retVal = 0;

            SafeIntPtr pSidArray = TypeMarshal.ToIntPtr(SidArray);

            paramList = new Int3264[] {
                DomainHandle,
                pSidArray,
                IntPtr.Zero,
                IntPtr.Zero
            };

            try
            {
                using (RpceInt3264Collection outParamList = RpceCall(paramList, opnum))
                {
                    Membership = TypeMarshal.ToStruct<_SAMPR_ULONG_ARRAY>(outParamList[2]);
                    retVal = outParamList[3].ToInt32();
                }
            }
            finally
            {
                pSidArray.Dispose();
            }

            return retVal;
        }