### ms-samr.idl
"""
RPC definitions for the following interfaces:
- samr (v1.0): 12345778-1234-ABCD-EF00-0123456789AC
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid

from scapy.fields import PacketListField, StrFixedLenField
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfFieldListField,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfVarFieldListField,
    NDRConfVarPacketListField,
    NDRConfVarStrLenField,
    NDRConfVarStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    NDRUnionField,
    register_dcerpc_interface,
)


class SamrConnect_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRShortField("ServerName", 0)),
        NDRIntField("DesiredAccess", 0),
    ]


class SamrConnect_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class SamrCloseHandle_Request(NDRPacket):
    fields_desc = [NDRPacketField("SamHandle", NDRContextHandle(), NDRContextHandle)]


class SamrCloseHandle_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("SamHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class PSAMPR_SR_SECURITY_DESCRIPTOR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Length", None, size_of="SecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "SecurityDescriptor", "", size_is=lambda pkt: pkt.Length
            ),
            deferred=True,
        ),
    ]


class SamrSetSecurityObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ObjectHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("SecurityInformation", 0),
        NDRPacketField(
            "SecurityDescriptor",
            PSAMPR_SR_SECURITY_DESCRIPTOR(),
            PSAMPR_SR_SECURITY_DESCRIPTOR,
        ),
    ]


class SamrSetSecurityObject_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrQuerySecurityObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ObjectHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("SecurityInformation", 0),
    ]


class SamrQuerySecurityObject_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "SecurityDescriptor",
                PSAMPR_SR_SECURITY_DESCRIPTOR(),
                PSAMPR_SR_SECURITY_DESCRIPTOR,
            )
        ),
        NDRIntField("status", 0),
    ]


class PRPC_UNICODE_STRING(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer", adjust=lambda _, x: (x * 2)),
        NDRShortField(
            "MaximumLength", None, size_of="Buffer", adjust=lambda _, x: (x * 2)
        ),
        NDRFullPointerField(
            NDRConfVarStrLenFieldUtf16(
                "Buffer",
                "",
                size_is=lambda pkt: (pkt.MaximumLength // 2),
                length_is=lambda pkt: (pkt.Length // 2),
            ),
            deferred=True,
        ),
    ]


class RPC_SID_IDENTIFIER_AUTHORITY(NDRPacket):
    fields_desc = [StrFixedLenField("Value", "", length=6)]


class PRPC_SID(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["SubAuthority"]
    fields_desc = [
        NDRByteField("Revision", 0),
        NDRByteField("SubAuthorityCount", None, size_of="SubAuthority"),
        NDRPacketField(
            "IdentifierAuthority",
            RPC_SID_IDENTIFIER_AUTHORITY(),
            RPC_SID_IDENTIFIER_AUTHORITY,
        ),
        NDRConfFieldListField(
            "SubAuthority",
            [],
            NDRIntField("", 0),
            size_is=lambda pkt: pkt.SubAuthorityCount,
            conformant_in_struct=True,
        ),
    ]


class SamrLookupDomainInSamServer_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("Name", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
    ]


class SamrLookupDomainInSamServer_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRPacketField("DomainId", PRPC_SID(), PRPC_SID)),
        NDRIntField("status", 0),
    ]


class RPC_UNICODE_STRING(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer", adjust=lambda _, x: (x * 2)),
        NDRShortField(
            "MaximumLength", None, size_of="Buffer", adjust=lambda _, x: (x * 2)
        ),
        NDRFullPointerField(
            NDRConfVarStrLenFieldUtf16(
                "Buffer",
                "",
                size_is=lambda pkt: (pkt.MaximumLength // 2),
                length_is=lambda pkt: (pkt.Length // 2),
            ),
            deferred=True,
        ),
    ]


class PSAMPR_RID_ENUMERATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("RelativeId", 0),
        NDRPacketField("Name", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class PSAMPR_ENUMERATION_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [PSAMPR_RID_ENUMERATION()],
                PSAMPR_RID_ENUMERATION,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class SamrEnumerateDomainsInSamServer_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("EnumerationContext", 0),
        NDRIntField("PreferedMaximumLength", 0),
    ]


class SamrEnumerateDomainsInSamServer_Response(NDRPacket):
    fields_desc = [
        NDRIntField("EnumerationContext", 0),
        NDRFullPointerField(
            NDRPacketField(
                "Buffer", PSAMPR_ENUMERATION_BUFFER(), PSAMPR_ENUMERATION_BUFFER
            )
        ),
        NDRIntField("CountReturned", 0),
        NDRIntField("status", 0),
    ]


class SamrOpenDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("DesiredAccess", 0),
        NDRPacketField("DomainId", PRPC_SID(), PRPC_SID),
    ]


class SamrOpenDomain_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class DOMAIN_INFORMATION_CLASS(IntEnum):
    DomainPasswordInformation = 1
    DomainGeneralInformation = 2
    DomainLogoffInformation = 3
    DomainOemInformation = 4
    DomainNameInformation = 5
    DomainReplicationInformation = 6
    DomainServerRoleInformation = 7
    DomainModifiedInformation = 8
    DomainStateInformation = 9
    DomainGeneralInformation2 = 11
    DomainLockoutInformation = 12
    DomainModifiedInformation2 = 13


class OLD_LARGE_INTEGER(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("LowPart", 0), NDRSignedIntField("HighPart", 0)]


class DOMAIN_PASSWORD_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRShortField("MinPasswordLength", 0),
        NDRShortField("PasswordHistoryLength", 0),
        NDRIntField("PasswordProperties", 0),
        NDRPacketField("MaxPasswordAge", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("MinPasswordAge", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
    ]


class SAMPR_DOMAIN_GENERAL_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("ForceLogoff", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("OemInformation", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("DomainName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField(
            "ReplicaSourceNodeName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING
        ),
        NDRPacketField("DomainModifiedCount", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRIntField("DomainServerState", 0),
        NDRIntField("DomainServerRole", 0),
        NDRByteField("UasCompatibilityRequired", 0),
        NDRIntField("UserCount", 0),
        NDRIntField("GroupCount", 0),
        NDRIntField("AliasCount", 0),
    ]


class DOMAIN_LOGOFF_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("ForceLogoff", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER)
    ]


class SAMPR_DOMAIN_OEM_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("OemInformation", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class SAMPR_DOMAIN_NAME_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("DomainName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class DOMAIN_SERVER_ROLE(IntEnum):
    DomainServerRoleBackup = 2
    DomainServerRolePrimary = 3


class DOMAIN_SERVER_ROLE_INFORMATION(NDRPacket):
    ALIGNMENT = (2, 4)
    fields_desc = [NDRInt3264EnumField("DomainServerRole", 0, DOMAIN_SERVER_ROLE)]


class PSAMPR_DOMAIN_REPLICATION_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField(
            "ReplicaSourceNodeName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING
        )
    ]


class DOMAIN_MODIFIED_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("DomainModifiedCount", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("CreationTime", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
    ]


class DOMAIN_SERVER_ENABLE_STATE(IntEnum):
    DomainServerEnabled = 1
    DomainServerDisabled = 2


class DOMAIN_STATE_INFORMATION(NDRPacket):
    ALIGNMENT = (2, 4)
    fields_desc = [
        NDRInt3264EnumField("DomainServerState", 0, DOMAIN_SERVER_ENABLE_STATE)
    ]


class LARGE_INTEGER(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRSignedLongField("QuadPart", 0)]


class SAMPR_DOMAIN_GENERAL_INFORMATION2(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField(
            "I1", SAMPR_DOMAIN_GENERAL_INFORMATION(), SAMPR_DOMAIN_GENERAL_INFORMATION
        ),
        NDRPacketField("LockoutDuration", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("LockoutObservationWindow", LARGE_INTEGER(), LARGE_INTEGER),
        NDRShortField("LockoutThreshold", 0),
    ]


class SAMPR_DOMAIN_LOCKOUT_INFORMATION(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("LockoutDuration", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("LockoutObservationWindow", LARGE_INTEGER(), LARGE_INTEGER),
        NDRShortField("LockoutThreshold", 0),
    ]


class DOMAIN_MODIFIED_INFORMATION2(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("DomainModifiedCount", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("CreationTime", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField(
            "ModifiedCountAtLastPromotion", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER
        ),
    ]


class SamrQueryInformationDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DomainInformationClass", 0, DOMAIN_INFORMATION_CLASS),
    ]


class SamrQueryInformationDomain_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRUnionField(
                [
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_PASSWORD_INFORMATION(),
                            DOMAIN_PASSWORD_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainPasswordInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainPasswordInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_GENERAL_INFORMATION(),
                            SAMPR_DOMAIN_GENERAL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_LOGOFF_INFORMATION(),
                            DOMAIN_LOGOFF_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainLogoffInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainLogoffInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_OEM_INFORMATION(),
                            SAMPR_DOMAIN_OEM_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainOemInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainOemInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_NAME_INFORMATION(),
                            SAMPR_DOMAIN_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_SERVER_ROLE_INFORMATION(),
                            DOMAIN_SERVER_ROLE_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainServerRoleInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainServerRoleInformation
                            ),
                        ),
                    ),
                    (
                        NDRFullPointerField(
                            NDRPacketField(
                                "Buffer",
                                PSAMPR_DOMAIN_REPLICATION_INFORMATION(),
                                PSAMPR_DOMAIN_REPLICATION_INFORMATION,
                            )
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainReplicationInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainReplicationInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_MODIFIED_INFORMATION(),
                            DOMAIN_MODIFIED_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_STATE_INFORMATION(),
                            DOMAIN_STATE_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainStateInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainStateInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_GENERAL_INFORMATION2(),
                            SAMPR_DOMAIN_GENERAL_INFORMATION2,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation2
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation2
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_LOCKOUT_INFORMATION(),
                            SAMPR_DOMAIN_LOCKOUT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainLockoutInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainLockoutInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_MODIFIED_INFORMATION2(),
                            DOMAIN_MODIFIED_INFORMATION2,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation2
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation2
                            ),
                        ),
                    ),
                ],
                StrFixedLenField("Buffer", "", length=0),
                align=(2, 8),
                switch_fmt=("H", "I"),
            )
        ),
        NDRIntField("status", 0),
    ]


class SamrSetInformationDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DomainInformationClass", 0, DOMAIN_INFORMATION_CLASS),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        DOMAIN_PASSWORD_INFORMATION(),
                        DOMAIN_PASSWORD_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainPasswordInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainPasswordInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_GENERAL_INFORMATION(),
                        SAMPR_DOMAIN_GENERAL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer", DOMAIN_LOGOFF_INFORMATION(), DOMAIN_LOGOFF_INFORMATION
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainLogoffInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainLogoffInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_OEM_INFORMATION(),
                        SAMPR_DOMAIN_OEM_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainOemInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainOemInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_NAME_INFORMATION(),
                        SAMPR_DOMAIN_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        DOMAIN_SERVER_ROLE_INFORMATION(),
                        DOMAIN_SERVER_ROLE_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainServerRoleInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainServerRoleInformation
                        ),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "Buffer",
                            PSAMPR_DOMAIN_REPLICATION_INFORMATION(),
                            PSAMPR_DOMAIN_REPLICATION_INFORMATION,
                        )
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainReplicationInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainReplicationInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        DOMAIN_MODIFIED_INFORMATION(),
                        DOMAIN_MODIFIED_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer", DOMAIN_STATE_INFORMATION(), DOMAIN_STATE_INFORMATION
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainStateInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainStateInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_GENERAL_INFORMATION2(),
                        SAMPR_DOMAIN_GENERAL_INFORMATION2,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation2
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation2
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_LOCKOUT_INFORMATION(),
                        SAMPR_DOMAIN_LOCKOUT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainLockoutInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainLockoutInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        DOMAIN_MODIFIED_INFORMATION2(),
                        DOMAIN_MODIFIED_INFORMATION2,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DomainInformationClass", None)
                            == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation2
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation2
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class SamrSetInformationDomain_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrCreateGroupInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("Name", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
        NDRIntField("DesiredAccess", 0),
    ]


class SamrCreateGroupInDomain_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("RelativeId", 0),
        NDRIntField("status", 0),
    ]


class SamrEnumerateGroupsInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("EnumerationContext", 0),
        NDRIntField("PreferedMaximumLength", 0),
    ]


class SamrEnumerateGroupsInDomain_Response(NDRPacket):
    fields_desc = [
        NDRIntField("EnumerationContext", 0),
        NDRFullPointerField(
            NDRPacketField(
                "Buffer", PSAMPR_ENUMERATION_BUFFER(), PSAMPR_ENUMERATION_BUFFER
            )
        ),
        NDRIntField("CountReturned", 0),
        NDRIntField("status", 0),
    ]


class SamrCreateUserInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("Name", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
        NDRIntField("DesiredAccess", 0),
    ]


class SamrCreateUserInDomain_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("RelativeId", 0),
        NDRIntField("status", 0),
    ]


class SamrEnumerateUsersInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("EnumerationContext", 0),
        NDRIntField("UserAccountControl", 0),
        NDRIntField("PreferedMaximumLength", 0),
    ]


class SamrEnumerateUsersInDomain_Response(NDRPacket):
    fields_desc = [
        NDRIntField("EnumerationContext", 0),
        NDRFullPointerField(
            NDRPacketField(
                "Buffer", PSAMPR_ENUMERATION_BUFFER(), PSAMPR_ENUMERATION_BUFFER
            )
        ),
        NDRIntField("CountReturned", 0),
        NDRIntField("status", 0),
    ]


class SamrCreateAliasInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("AccountName", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
        NDRIntField("DesiredAccess", 0),
    ]


class SamrCreateAliasInDomain_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("RelativeId", 0),
        NDRIntField("status", 0),
    ]


class SamrEnumerateAliasesInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("EnumerationContext", 0),
        NDRIntField("PreferedMaximumLength", 0),
    ]


class SamrEnumerateAliasesInDomain_Response(NDRPacket):
    fields_desc = [
        NDRIntField("EnumerationContext", 0),
        NDRFullPointerField(
            NDRPacketField(
                "Buffer", PSAMPR_ENUMERATION_BUFFER(), PSAMPR_ENUMERATION_BUFFER
            )
        ),
        NDRIntField("CountReturned", 0),
        NDRIntField("status", 0),
    ]


class PSAMPR_SID_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("SidPointer", PRPC_SID(), PRPC_SID), deferred=True
        )
    ]


class PSAMPR_PSID_ARRAY(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Count", None, size_of="Sids"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Sids",
                [PSAMPR_SID_INFORMATION()],
                PSAMPR_SID_INFORMATION,
                size_is=lambda pkt: pkt.Count,
            ),
            deferred=True,
        ),
    ]


class PSAMPR_ULONG_ARRAY(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Count", None, size_of="Element"),
        NDRFullPointerField(
            NDRConfFieldListField(
                "Element", [], NDRIntField("Element", 0), size_is=lambda pkt: pkt.Count
            ),
            deferred=True,
        ),
    ]


class SamrGetAliasMembership_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("SidArray", PSAMPR_PSID_ARRAY(), PSAMPR_PSID_ARRAY),
    ]


class SamrGetAliasMembership_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("Membership", PSAMPR_ULONG_ARRAY(), PSAMPR_ULONG_ARRAY),
        NDRIntField("status", 0),
    ]


class SamrLookupNamesInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Count", None, size_of="Names"),
        NDRConfVarPacketListField(
            "Names",
            [],
            RPC_UNICODE_STRING,
            size_is=lambda pkt: 1000,
            length_is=lambda pkt: pkt.Count,
        ),
    ]


class SamrLookupNamesInDomain_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("RelativeIds", PSAMPR_ULONG_ARRAY(), PSAMPR_ULONG_ARRAY),
        NDRPacketField("Use", PSAMPR_ULONG_ARRAY(), PSAMPR_ULONG_ARRAY),
        NDRIntField("status", 0),
    ]


class PSAMPR_RETURNED_USTRING_ARRAY(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Count", None, size_of="Element"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Element",
                [PRPC_UNICODE_STRING()],
                PRPC_UNICODE_STRING,
                size_is=lambda pkt: pkt.Count,
            ),
            deferred=True,
        ),
    ]


class SamrLookupIdsInDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Count", None, size_of="RelativeIds"),
        NDRConfVarFieldListField(
            "RelativeIds",
            [],
            NDRIntField("", 0),
            size_is=lambda pkt: 1000,
            length_is=lambda pkt: pkt.Count,
        ),
    ]


class SamrLookupIdsInDomain_Response(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "Names", PSAMPR_RETURNED_USTRING_ARRAY(), PSAMPR_RETURNED_USTRING_ARRAY
        ),
        NDRPacketField("Use", PSAMPR_ULONG_ARRAY(), PSAMPR_ULONG_ARRAY),
        NDRIntField("status", 0),
    ]


class SamrOpenGroup_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("DesiredAccess", 0),
        NDRIntField("GroupId", 0),
    ]


class SamrOpenGroup_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class GROUP_INFORMATION_CLASS(IntEnum):
    GroupGeneralInformation = 1
    GroupNameInformation = 2
    GroupAttributeInformation = 3
    GroupAdminCommentInformation = 4
    GroupReplicationInformation = 5


class SAMPR_GROUP_GENERAL_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("Name", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRIntField("Attributes", 0),
        NDRIntField("MemberCount", 0),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_GROUP_NAME_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [NDRPacketField("Name", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)]


class GROUP_ATTRIBUTE_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("Attributes", 0)]


class SAMPR_GROUP_ADM_COMMENT_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class SamrQueryInformationGroup_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("GroupInformationClass", 0, GROUP_INFORMATION_CLASS),
    ]


class SamrQueryInformationGroup_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRUnionField(
                [
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_GROUP_GENERAL_INFORMATION(),
                            SAMPR_GROUP_GENERAL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "GroupInformationClass", None)
                                == GROUP_INFORMATION_CLASS.GroupGeneralInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == GROUP_INFORMATION_CLASS.GroupGeneralInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_GROUP_NAME_INFORMATION(),
                            SAMPR_GROUP_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "GroupInformationClass", None)
                                == GROUP_INFORMATION_CLASS.GroupNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == GROUP_INFORMATION_CLASS.GroupNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            GROUP_ATTRIBUTE_INFORMATION(),
                            GROUP_ATTRIBUTE_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "GroupInformationClass", None)
                                == GROUP_INFORMATION_CLASS.GroupAttributeInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == GROUP_INFORMATION_CLASS.GroupAttributeInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_GROUP_ADM_COMMENT_INFORMATION(),
                            SAMPR_GROUP_ADM_COMMENT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "GroupInformationClass", None)
                                == GROUP_INFORMATION_CLASS.GroupAdminCommentInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == GROUP_INFORMATION_CLASS.GroupAdminCommentInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_GROUP_GENERAL_INFORMATION(),
                            SAMPR_GROUP_GENERAL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "GroupInformationClass", None)
                                == GROUP_INFORMATION_CLASS.GroupReplicationInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == GROUP_INFORMATION_CLASS.GroupReplicationInformation
                            ),
                        ),
                    ),
                ],
                StrFixedLenField("Buffer", "", length=0),
                align=(2, 8),
                switch_fmt=("H", "I"),
            )
        ),
        NDRIntField("status", 0),
    ]


class SamrSetInformationGroup_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("GroupInformationClass", 0, GROUP_INFORMATION_CLASS),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_GROUP_GENERAL_INFORMATION(),
                        SAMPR_GROUP_GENERAL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "GroupInformationClass", None)
                            == GROUP_INFORMATION_CLASS.GroupGeneralInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == GROUP_INFORMATION_CLASS.GroupGeneralInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_GROUP_NAME_INFORMATION(),
                        SAMPR_GROUP_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "GroupInformationClass", None)
                            == GROUP_INFORMATION_CLASS.GroupNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == GROUP_INFORMATION_CLASS.GroupNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        GROUP_ATTRIBUTE_INFORMATION(),
                        GROUP_ATTRIBUTE_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "GroupInformationClass", None)
                            == GROUP_INFORMATION_CLASS.GroupAttributeInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == GROUP_INFORMATION_CLASS.GroupAttributeInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_GROUP_ADM_COMMENT_INFORMATION(),
                        SAMPR_GROUP_ADM_COMMENT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "GroupInformationClass", None)
                            == GROUP_INFORMATION_CLASS.GroupAdminCommentInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == GROUP_INFORMATION_CLASS.GroupAdminCommentInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_GROUP_GENERAL_INFORMATION(),
                        SAMPR_GROUP_GENERAL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "GroupInformationClass", None)
                            == GROUP_INFORMATION_CLASS.GroupReplicationInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == GROUP_INFORMATION_CLASS.GroupReplicationInformation
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class SamrSetInformationGroup_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrAddMemberToGroup_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("MemberId", 0),
        NDRIntField("Attributes", 0),
    ]


class SamrAddMemberToGroup_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrDeleteGroup_Request(NDRPacket):
    fields_desc = [NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle)]


class SamrDeleteGroup_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class SamrRemoveMemberFromGroup_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("MemberId", 0),
    ]


class SamrRemoveMemberFromGroup_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class PSAMPR_GET_MEMBERS_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("MemberCount", None, size_of="Attributes"),
        NDRFullPointerField(
            NDRConfFieldListField(
                "Members",
                [],
                NDRIntField("Members", 0),
                size_is=lambda pkt: pkt.MemberCount,
            ),
            deferred=True,
        ),
        NDRFullPointerField(
            NDRConfFieldListField(
                "Attributes",
                [],
                NDRIntField("Attributes", 0),
                size_is=lambda pkt: pkt.MemberCount,
            ),
            deferred=True,
        ),
    ]


class SamrGetMembersInGroup_Request(NDRPacket):
    fields_desc = [NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle)]


class SamrGetMembersInGroup_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "Members", PSAMPR_GET_MEMBERS_BUFFER(), PSAMPR_GET_MEMBERS_BUFFER
            )
        ),
        NDRIntField("status", 0),
    ]


class SamrSetMemberAttributesOfGroup_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("GroupHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("MemberId", 0),
        NDRIntField("Attributes", 0),
    ]


class SamrSetMemberAttributesOfGroup_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrOpenAlias_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("DesiredAccess", 0),
        NDRIntField("AliasId", 0),
    ]


class SamrOpenAlias_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class ALIAS_INFORMATION_CLASS(IntEnum):
    AliasGeneralInformation = 1
    AliasNameInformation = 2
    AliasAdminCommentInformation = 3


class SAMPR_ALIAS_GENERAL_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("Name", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRIntField("MemberCount", 0),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_ALIAS_NAME_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [NDRPacketField("Name", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)]


class SAMPR_ALIAS_ADM_COMMENT_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class SamrQueryInformationAlias_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("AliasInformationClass", 0, ALIAS_INFORMATION_CLASS),
    ]


class SamrQueryInformationAlias_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRUnionField(
                [
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_ALIAS_GENERAL_INFORMATION(),
                            SAMPR_ALIAS_GENERAL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "AliasInformationClass", None)
                                == ALIAS_INFORMATION_CLASS.AliasGeneralInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == ALIAS_INFORMATION_CLASS.AliasGeneralInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_ALIAS_NAME_INFORMATION(),
                            SAMPR_ALIAS_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "AliasInformationClass", None)
                                == ALIAS_INFORMATION_CLASS.AliasNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == ALIAS_INFORMATION_CLASS.AliasNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_ALIAS_ADM_COMMENT_INFORMATION(),
                            SAMPR_ALIAS_ADM_COMMENT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "AliasInformationClass", None)
                                == ALIAS_INFORMATION_CLASS.AliasAdminCommentInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == ALIAS_INFORMATION_CLASS.AliasAdminCommentInformation
                            ),
                        ),
                    ),
                ],
                StrFixedLenField("Buffer", "", length=0),
                align=(2, 8),
                switch_fmt=("H", "I"),
            )
        ),
        NDRIntField("status", 0),
    ]


class SamrSetInformationAlias_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("AliasInformationClass", 0, ALIAS_INFORMATION_CLASS),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_ALIAS_GENERAL_INFORMATION(),
                        SAMPR_ALIAS_GENERAL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "AliasInformationClass", None)
                            == ALIAS_INFORMATION_CLASS.AliasGeneralInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == ALIAS_INFORMATION_CLASS.AliasGeneralInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_ALIAS_NAME_INFORMATION(),
                        SAMPR_ALIAS_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "AliasInformationClass", None)
                            == ALIAS_INFORMATION_CLASS.AliasNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == ALIAS_INFORMATION_CLASS.AliasNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_ALIAS_ADM_COMMENT_INFORMATION(),
                        SAMPR_ALIAS_ADM_COMMENT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "AliasInformationClass", None)
                            == ALIAS_INFORMATION_CLASS.AliasAdminCommentInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == ALIAS_INFORMATION_CLASS.AliasAdminCommentInformation
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class SamrSetInformationAlias_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrDeleteAlias_Request(NDRPacket):
    fields_desc = [NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle)]


class SamrDeleteAlias_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class SamrAddMemberToAlias_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("MemberId", PRPC_SID(), PRPC_SID),
    ]


class SamrAddMemberToAlias_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrRemoveMemberFromAlias_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("MemberId", PRPC_SID(), PRPC_SID),
    ]


class SamrRemoveMemberFromAlias_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class PSAMPR_PSID_ARRAY_OUT(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Count", None, size_of="Sids"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Sids",
                [PSAMPR_SID_INFORMATION()],
                PSAMPR_SID_INFORMATION,
                size_is=lambda pkt: pkt.Count,
            ),
            deferred=True,
        ),
    ]


class SamrGetMembersInAlias_Request(NDRPacket):
    fields_desc = [NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle)]


class SamrGetMembersInAlias_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("Members", PSAMPR_PSID_ARRAY_OUT(), PSAMPR_PSID_ARRAY_OUT),
        NDRIntField("status", 0),
    ]


class SamrOpenUser_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("DesiredAccess", 0),
        NDRIntField("UserId", 0),
    ]


class SamrOpenUser_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class SamrDeleteUser_Request(NDRPacket):
    fields_desc = [NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle)]


class SamrDeleteUser_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class USER_INFORMATION_CLASS(IntEnum):
    UserGeneralInformation = 1
    UserPreferencesInformation = 2
    UserLogonInformation = 3
    UserLogonHoursInformation = 4
    UserAccountInformation = 5
    UserNameInformation = 6
    UserAccountNameInformation = 7
    UserFullNameInformation = 8
    UserPrimaryGroupInformation = 9
    UserHomeInformation = 10
    UserScriptInformation = 11
    UserProfileInformation = 12
    UserAdminCommentInformation = 13
    UserWorkStationsInformation = 14
    UserControlInformation = 16
    UserExpiresInformation = 17
    UserInternal1Information = 18
    UserParametersInformation = 20
    UserAllInformation = 21
    UserInternal4Information = 23
    UserInternal5Information = 24
    UserInternal4InformationNew = 25
    UserInternal5InformationNew = 26
    UserInternal7Information = 31
    UserInternal8Information = 32


class SAMPR_USER_GENERAL_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("UserName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("FullName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRIntField("PrimaryGroupId", 0),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("UserComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_USER_PREFERENCES_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("UserComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("Reserved1", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRShortField("CountryCode", 0),
        NDRShortField("CodePage", 0),
    ]


class SAMPR_LOGON_HOURS(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField(
            "UnitsPerWeek",
            None,
            size_of="LogonHours",
            adjust=lambda _, x: ((x * 8) - 7),
        ),
        NDRFullPointerField(
            NDRConfVarStrLenField(
                "LogonHours",
                "",
                size_is=lambda pkt: 1260,
                length_is=lambda pkt: ((pkt.UnitsPerWeek + 7) // 8),
            ),
            deferred=True,
        ),
    ]


class SAMPR_USER_LOGON_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("UserName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("FullName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRIntField("UserId", 0),
        NDRIntField("PrimaryGroupId", 0),
        NDRPacketField("HomeDirectory", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("HomeDirectoryDrive", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("ScriptPath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("ProfilePath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("WorkStations", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("LastLogon", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("LastLogoff", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("PasswordLastSet", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("PasswordCanChange", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("PasswordMustChange", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("LogonHours", SAMPR_LOGON_HOURS(), SAMPR_LOGON_HOURS),
        NDRShortField("BadPasswordCount", 0),
        NDRShortField("LogonCount", 0),
        NDRIntField("UserAccountControl", 0),
    ]


class SAMPR_USER_LOGON_HOURS_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [NDRPacketField("LogonHours", SAMPR_LOGON_HOURS(), SAMPR_LOGON_HOURS)]


class SAMPR_USER_ACCOUNT_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("UserName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("FullName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRIntField("UserId", 0),
        NDRIntField("PrimaryGroupId", 0),
        NDRPacketField("HomeDirectory", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("HomeDirectoryDrive", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("ScriptPath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("ProfilePath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("WorkStations", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("LastLogon", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("LastLogoff", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("LogonHours", SAMPR_LOGON_HOURS(), SAMPR_LOGON_HOURS),
        NDRShortField("BadPasswordCount", 0),
        NDRShortField("LogonCount", 0),
        NDRPacketField("PasswordLastSet", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("AccountExpires", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRIntField("UserAccountControl", 0),
    ]


class SAMPR_USER_NAME_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("UserName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("FullName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_USER_A_NAME_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [NDRPacketField("UserName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)]


class SAMPR_USER_F_NAME_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [NDRPacketField("FullName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)]


class USER_PRIMARY_GROUP_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("PrimaryGroupId", 0)]


class SAMPR_USER_HOME_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("HomeDirectory", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("HomeDirectoryDrive", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_USER_SCRIPT_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("ScriptPath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class SAMPR_USER_PROFILE_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("ProfilePath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class SAMPR_USER_ADMIN_COMMENT_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class SAMPR_USER_WORKSTATIONS_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("WorkStations", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class USER_CONTROL_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("UserAccountControl", 0)]


class USER_EXPIRES_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("AccountExpires", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER)
    ]


class ENCRYPTED_NT_OWF_PASSWORD(NDRPacket):
    fields_desc = [StrFixedLenField("data", "", length=16)]


class ENCRYPTED_LM_OWF_PASSWORD(NDRPacket):
    fields_desc = [StrFixedLenField("data", "", length=16)]


class SAMPR_USER_INTERNAL1_INFORMATION(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "EncryptedNtOwfPassword",
            ENCRYPTED_NT_OWF_PASSWORD(),
            ENCRYPTED_NT_OWF_PASSWORD,
        ),
        NDRPacketField(
            "EncryptedLmOwfPassword",
            ENCRYPTED_LM_OWF_PASSWORD(),
            ENCRYPTED_LM_OWF_PASSWORD,
        ),
        NDRByteField("NtPasswordPresent", 0),
        NDRByteField("LmPasswordPresent", 0),
        NDRByteField("PasswordExpired", 0),
    ]


class SAMPR_USER_PARAMETERS_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("Parameters", RPC_UNICODE_STRING(), RPC_UNICODE_STRING)
    ]


class RPC_SHORT_BLOB(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer", adjust=lambda _, x: (x * 2)),
        NDRShortField(
            "MaximumLength", None, size_of="Buffer", adjust=lambda _, x: (x * 2)
        ),
        NDRFullPointerField(
            NDRConfVarStrLenFieldUtf16(
                "Buffer",
                "",
                size_is=lambda pkt: (pkt.MaximumLength // 2),
                length_is=lambda pkt: (pkt.Length // 2),
            ),
            deferred=True,
        ),
    ]


class SAMPR_SR_SECURITY_DESCRIPTOR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Length", None, size_of="SecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "SecurityDescriptor", "", size_is=lambda pkt: pkt.Length
            ),
            deferred=True,
        ),
    ]


class SAMPR_USER_ALL_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("LastLogon", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("LastLogoff", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("PasswordLastSet", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("AccountExpires", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("PasswordCanChange", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("PasswordMustChange", OLD_LARGE_INTEGER(), OLD_LARGE_INTEGER),
        NDRPacketField("UserName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("FullName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("HomeDirectory", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("HomeDirectoryDrive", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("ScriptPath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("ProfilePath", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("WorkStations", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("UserComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("Parameters", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("LmOwfPassword", RPC_SHORT_BLOB(), RPC_SHORT_BLOB),
        NDRPacketField("NtOwfPassword", RPC_SHORT_BLOB(), RPC_SHORT_BLOB),
        NDRPacketField("PrivateData", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField(
            "SecurityDescriptor",
            SAMPR_SR_SECURITY_DESCRIPTOR(),
            SAMPR_SR_SECURITY_DESCRIPTOR,
        ),
        NDRIntField("UserId", 0),
        NDRIntField("PrimaryGroupId", 0),
        NDRIntField("UserAccountControl", 0),
        NDRIntField("WhichFields", 0),
        NDRPacketField("LogonHours", SAMPR_LOGON_HOURS(), SAMPR_LOGON_HOURS),
        NDRShortField("BadPasswordCount", 0),
        NDRShortField("LogonCount", 0),
        NDRShortField("CountryCode", 0),
        NDRShortField("CodePage", 0),
        NDRByteField("LmPasswordPresent", 0),
        NDRByteField("NtPasswordPresent", 0),
        NDRByteField("PasswordExpired", 0),
        NDRByteField("PrivateDataSensitive", 0),
    ]


class SAMPR_ENCRYPTED_USER_PASSWORD(NDRPacket):
    fields_desc = [StrFixedLenField("Buffer", "", length=((256 * 2) + 4))]


class SAMPR_USER_INTERNAL4_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("I1", SAMPR_USER_ALL_INFORMATION(), SAMPR_USER_ALL_INFORMATION),
        NDRPacketField(
            "UserPassword",
            SAMPR_ENCRYPTED_USER_PASSWORD(),
            SAMPR_ENCRYPTED_USER_PASSWORD,
        ),
    ]


class SAMPR_USER_INTERNAL5_INFORMATION(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "UserPassword",
            SAMPR_ENCRYPTED_USER_PASSWORD(),
            SAMPR_ENCRYPTED_USER_PASSWORD,
        ),
        NDRByteField("PasswordExpired", 0),
    ]


class SAMPR_ENCRYPTED_USER_PASSWORD_NEW(NDRPacket):
    fields_desc = [StrFixedLenField("Buffer", "", length=(((256 * 2) + 4) + 16))]


class SAMPR_USER_INTERNAL4_INFORMATION_NEW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("I1", SAMPR_USER_ALL_INFORMATION(), SAMPR_USER_ALL_INFORMATION),
        NDRPacketField(
            "UserPassword",
            SAMPR_ENCRYPTED_USER_PASSWORD_NEW(),
            SAMPR_ENCRYPTED_USER_PASSWORD_NEW,
        ),
    ]


class SAMPR_USER_INTERNAL5_INFORMATION_NEW(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "UserPassword",
            SAMPR_ENCRYPTED_USER_PASSWORD_NEW(),
            SAMPR_ENCRYPTED_USER_PASSWORD_NEW,
        ),
        NDRByteField("PasswordExpired", 0),
    ]


class SAMPR_ENCRYPTED_PASSWORD_AES(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        StrFixedLenField("AuthData", "", length=64),
        StrFixedLenField("Salt", "", length=16),
        NDRIntField("cbCipher", None, size_of="Cipher"),
        NDRFullPointerField(
            NDRConfStrLenField("Cipher", "", size_is=lambda pkt: pkt.cbCipher),
            deferred=True,
        ),
        NDRLongField("PBKDF2Iterations", 0),
    ]


class SAMPR_USER_INTERNAL7_INFORMATION(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField(
            "UserPassword", SAMPR_ENCRYPTED_PASSWORD_AES(), SAMPR_ENCRYPTED_PASSWORD_AES
        ),
        NDRByteField("PasswordExpired", 0),
    ]


class SAMPR_USER_INTERNAL8_INFORMATION(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("I1", SAMPR_USER_ALL_INFORMATION(), SAMPR_USER_ALL_INFORMATION),
        NDRPacketField(
            "UserPassword", SAMPR_ENCRYPTED_PASSWORD_AES(), SAMPR_ENCRYPTED_PASSWORD_AES
        ),
    ]


class SamrQueryInformationUser_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("UserInformationClass", 0, USER_INFORMATION_CLASS),
    ]


class SamrQueryInformationUser_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRUnionField(
                [
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_GENERAL_INFORMATION(),
                            SAMPR_USER_GENERAL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserGeneralInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserGeneralInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_PREFERENCES_INFORMATION(),
                            SAMPR_USER_PREFERENCES_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserPreferencesInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserPreferencesInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_LOGON_INFORMATION(),
                            SAMPR_USER_LOGON_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserLogonInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserLogonInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_LOGON_HOURS_INFORMATION(),
                            SAMPR_USER_LOGON_HOURS_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserLogonHoursInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserLogonHoursInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_ACCOUNT_INFORMATION(),
                            SAMPR_USER_ACCOUNT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAccountInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAccountInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_NAME_INFORMATION(),
                            SAMPR_USER_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_A_NAME_INFORMATION(),
                            SAMPR_USER_A_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAccountNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAccountNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_F_NAME_INFORMATION(),
                            SAMPR_USER_F_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserFullNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserFullNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            USER_PRIMARY_GROUP_INFORMATION(),
                            USER_PRIMARY_GROUP_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_HOME_INFORMATION(),
                            SAMPR_USER_HOME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserHomeInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserHomeInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_SCRIPT_INFORMATION(),
                            SAMPR_USER_SCRIPT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserScriptInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserScriptInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_PROFILE_INFORMATION(),
                            SAMPR_USER_PROFILE_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserProfileInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserProfileInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_ADMIN_COMMENT_INFORMATION(),
                            SAMPR_USER_ADMIN_COMMENT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAdminCommentInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAdminCommentInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_WORKSTATIONS_INFORMATION(),
                            SAMPR_USER_WORKSTATIONS_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserWorkStationsInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserWorkStationsInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            USER_CONTROL_INFORMATION(),
                            USER_CONTROL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserControlInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserControlInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            USER_EXPIRES_INFORMATION(),
                            USER_EXPIRES_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserExpiresInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserExpiresInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL1_INFORMATION(),
                            SAMPR_USER_INTERNAL1_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal1Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal1Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_PARAMETERS_INFORMATION(),
                            SAMPR_USER_PARAMETERS_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserParametersInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserParametersInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_ALL_INFORMATION(),
                            SAMPR_USER_ALL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAllInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAllInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL4_INFORMATION(),
                            SAMPR_USER_INTERNAL4_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal4Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal4Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL5_INFORMATION(),
                            SAMPR_USER_INTERNAL5_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal5Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal5Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL4_INFORMATION_NEW(),
                            SAMPR_USER_INTERNAL4_INFORMATION_NEW,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal4InformationNew
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal4InformationNew
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL5_INFORMATION_NEW(),
                            SAMPR_USER_INTERNAL5_INFORMATION_NEW,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal5InformationNew
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal5InformationNew
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL7_INFORMATION(),
                            SAMPR_USER_INTERNAL7_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal7Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal7Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL8_INFORMATION(),
                            SAMPR_USER_INTERNAL8_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal8Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal8Information
                            ),
                        ),
                    ),
                ],
                StrFixedLenField("Buffer", "", length=0),
                align=(2, 8),
                switch_fmt=("H", "I"),
            )
        ),
        NDRIntField("status", 0),
    ]


class SamrSetInformationUser_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("UserInformationClass", 0, USER_INFORMATION_CLASS),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_GENERAL_INFORMATION(),
                        SAMPR_USER_GENERAL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserGeneralInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserGeneralInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_PREFERENCES_INFORMATION(),
                        SAMPR_USER_PREFERENCES_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserPreferencesInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserPreferencesInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_LOGON_INFORMATION(),
                        SAMPR_USER_LOGON_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserLogonInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserLogonInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_LOGON_HOURS_INFORMATION(),
                        SAMPR_USER_LOGON_HOURS_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserLogonHoursInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserLogonHoursInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_ACCOUNT_INFORMATION(),
                        SAMPR_USER_ACCOUNT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAccountInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAccountInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_NAME_INFORMATION(),
                        SAMPR_USER_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_A_NAME_INFORMATION(),
                        SAMPR_USER_A_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAccountNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAccountNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_F_NAME_INFORMATION(),
                        SAMPR_USER_F_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserFullNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserFullNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        USER_PRIMARY_GROUP_INFORMATION(),
                        USER_PRIMARY_GROUP_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_HOME_INFORMATION(),
                        SAMPR_USER_HOME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserHomeInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserHomeInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_SCRIPT_INFORMATION(),
                        SAMPR_USER_SCRIPT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserScriptInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserScriptInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_PROFILE_INFORMATION(),
                        SAMPR_USER_PROFILE_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserProfileInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserProfileInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_ADMIN_COMMENT_INFORMATION(),
                        SAMPR_USER_ADMIN_COMMENT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAdminCommentInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAdminCommentInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_WORKSTATIONS_INFORMATION(),
                        SAMPR_USER_WORKSTATIONS_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserWorkStationsInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserWorkStationsInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer", USER_CONTROL_INFORMATION(), USER_CONTROL_INFORMATION
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserControlInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserControlInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer", USER_EXPIRES_INFORMATION(), USER_EXPIRES_INFORMATION
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserExpiresInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserExpiresInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL1_INFORMATION(),
                        SAMPR_USER_INTERNAL1_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal1Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal1Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_PARAMETERS_INFORMATION(),
                        SAMPR_USER_PARAMETERS_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserParametersInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserParametersInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_ALL_INFORMATION(),
                        SAMPR_USER_ALL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAllInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAllInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL4_INFORMATION(),
                        SAMPR_USER_INTERNAL4_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal4Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal4Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL5_INFORMATION(),
                        SAMPR_USER_INTERNAL5_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal5Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal5Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL4_INFORMATION_NEW(),
                        SAMPR_USER_INTERNAL4_INFORMATION_NEW,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal4InformationNew
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal4InformationNew
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL5_INFORMATION_NEW(),
                        SAMPR_USER_INTERNAL5_INFORMATION_NEW,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal5InformationNew
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal5InformationNew
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL7_INFORMATION(),
                        SAMPR_USER_INTERNAL7_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal7Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal7Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL8_INFORMATION(),
                        SAMPR_USER_INTERNAL8_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal8Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal8Information
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class SamrSetInformationUser_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class PENCRYPTED_LM_OWF_PASSWORD(NDRPacket):
    fields_desc = [StrFixedLenField("data", "", length=16)]


class PENCRYPTED_NT_OWF_PASSWORD(NDRPacket):
    fields_desc = [StrFixedLenField("data", "", length=16)]


class SamrChangePasswordUser_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRByteField("LmPresent", 0),
        NDRFullPointerField(
            NDRPacketField(
                "OldLmEncryptedWithNewLm",
                PENCRYPTED_LM_OWF_PASSWORD(),
                PENCRYPTED_LM_OWF_PASSWORD,
            )
        ),
        NDRFullPointerField(
            NDRPacketField(
                "NewLmEncryptedWithOldLm",
                PENCRYPTED_LM_OWF_PASSWORD(),
                PENCRYPTED_LM_OWF_PASSWORD,
            )
        ),
        NDRByteField("NtPresent", 0),
        NDRFullPointerField(
            NDRPacketField(
                "OldNtEncryptedWithNewNt",
                PENCRYPTED_NT_OWF_PASSWORD(),
                PENCRYPTED_NT_OWF_PASSWORD,
            )
        ),
        NDRFullPointerField(
            NDRPacketField(
                "NewNtEncryptedWithOldNt",
                PENCRYPTED_NT_OWF_PASSWORD(),
                PENCRYPTED_NT_OWF_PASSWORD,
            )
        ),
        NDRByteField("NtCrossEncryptionPresent", 0),
        NDRFullPointerField(
            NDRPacketField(
                "NewNtEncryptedWithNewLm",
                PENCRYPTED_NT_OWF_PASSWORD(),
                PENCRYPTED_NT_OWF_PASSWORD,
            )
        ),
        NDRByteField("LmCrossEncryptionPresent", 0),
        NDRFullPointerField(
            NDRPacketField(
                "NewLmEncryptedWithNewNt",
                PENCRYPTED_LM_OWF_PASSWORD(),
                PENCRYPTED_LM_OWF_PASSWORD,
            )
        ),
    ]


class SamrChangePasswordUser_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class PGROUP_MEMBERSHIP(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("RelativeId", 0), NDRIntField("Attributes", 0)]


class PSAMPR_GET_GROUPS_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("MembershipCount", None, size_of="Groups"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Groups",
                [PGROUP_MEMBERSHIP()],
                PGROUP_MEMBERSHIP,
                size_is=lambda pkt: pkt.MembershipCount,
            ),
            deferred=True,
        ),
    ]


class SamrGetGroupsForUser_Request(NDRPacket):
    fields_desc = [NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle)]


class SamrGetGroupsForUser_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "Groups", PSAMPR_GET_GROUPS_BUFFER(), PSAMPR_GET_GROUPS_BUFFER
            )
        ),
        NDRIntField("status", 0),
    ]


class DOMAIN_DISPLAY_INFORMATION(IntEnum):
    DomainDisplayUser = 1
    DomainDisplayMachine = 2
    DomainDisplayGroup = 3
    DomainDisplayOemUser = 4
    DomainDisplayOemGroup = 5


class PSAMPR_DOMAIN_DISPLAY_USER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Index", 0),
        NDRIntField("Rid", 0),
        NDRIntField("AccountControl", 0),
        NDRPacketField("AccountName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("FullName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_DOMAIN_DISPLAY_USER_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [PSAMPR_DOMAIN_DISPLAY_USER()],
                PSAMPR_DOMAIN_DISPLAY_USER,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class PSAMPR_DOMAIN_DISPLAY_MACHINE(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Index", 0),
        NDRIntField("Rid", 0),
        NDRIntField("AccountControl", 0),
        NDRPacketField("AccountName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_DOMAIN_DISPLAY_MACHINE_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [PSAMPR_DOMAIN_DISPLAY_MACHINE()],
                PSAMPR_DOMAIN_DISPLAY_MACHINE,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class PSAMPR_DOMAIN_DISPLAY_GROUP(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Index", 0),
        NDRIntField("Rid", 0),
        NDRIntField("Attributes", 0),
        NDRPacketField("AccountName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("AdminComment", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
    ]


class SAMPR_DOMAIN_DISPLAY_GROUP_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [PSAMPR_DOMAIN_DISPLAY_GROUP()],
                PSAMPR_DOMAIN_DISPLAY_GROUP,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class RPC_STRING(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer"),
        NDRShortField("MaximumLength", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfVarStrLenField(
                "Buffer",
                "",
                size_is=lambda pkt: pkt.MaximumLength,
                length_is=lambda pkt: pkt.Length,
            ),
            deferred=True,
        ),
    ]


class PSAMPR_DOMAIN_DISPLAY_OEM_USER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Index", 0),
        NDRPacketField("OemAccountName", RPC_STRING(), RPC_STRING),
    ]


class SAMPR_DOMAIN_DISPLAY_OEM_USER_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [PSAMPR_DOMAIN_DISPLAY_OEM_USER()],
                PSAMPR_DOMAIN_DISPLAY_OEM_USER,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class PSAMPR_DOMAIN_DISPLAY_OEM_GROUP(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Index", 0),
        NDRPacketField("OemAccountName", RPC_STRING(), RPC_STRING),
    ]


class SAMPR_DOMAIN_DISPLAY_OEM_GROUP_BUFFER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [PSAMPR_DOMAIN_DISPLAY_OEM_GROUP()],
                PSAMPR_DOMAIN_DISPLAY_OEM_GROUP,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class SamrQueryDisplayInformation_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DisplayInformationClass", 0, DOMAIN_DISPLAY_INFORMATION),
        NDRIntField("Index", 0),
        NDRIntField("EntryCount", 0),
        NDRIntField("PreferredMaximumLength", 0),
    ]


class SamrQueryDisplayInformation_Response(NDRPacket):
    fields_desc = [
        NDRIntField("TotalAvailable", 0),
        NDRIntField("TotalReturned", 0),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_USER_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_USER_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayUser
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayUser
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_MACHINE_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_MACHINE_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayMachine
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayMachine
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_GROUP_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_GROUP_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayGroup
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayGroup
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_OEM_USER_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_OEM_USER_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemUser
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemUser
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_OEM_GROUP_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_OEM_GROUP_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemGroup
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemGroup
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
        NDRIntField("status", 0),
    ]


class SamrGetDisplayEnumerationIndex_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DisplayInformationClass", 0, DOMAIN_DISPLAY_INFORMATION),
        NDRPacketField("Prefix", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
    ]


class SamrGetDisplayEnumerationIndex_Response(NDRPacket):
    fields_desc = [NDRIntField("Index", 0), NDRIntField("status", 0)]


class PUSER_DOMAIN_PASSWORD_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRShortField("MinPasswordLength", 0),
        NDRIntField("PasswordProperties", 0),
    ]


class SamrGetUserDomainPasswordInformation_Request(NDRPacket):
    fields_desc = [NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle)]


class SamrGetUserDomainPasswordInformation_Response(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "PasswordInformation",
            PUSER_DOMAIN_PASSWORD_INFORMATION(),
            PUSER_DOMAIN_PASSWORD_INFORMATION,
        ),
        NDRIntField("status", 0),
    ]


class SamrRemoveMemberFromForeignDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("MemberSid", PRPC_SID(), PRPC_SID),
    ]


class SamrRemoveMemberFromForeignDomain_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrQueryInformationDomain2_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DomainInformationClass", 0, DOMAIN_INFORMATION_CLASS),
    ]


class SamrQueryInformationDomain2_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRUnionField(
                [
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_PASSWORD_INFORMATION(),
                            DOMAIN_PASSWORD_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainPasswordInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainPasswordInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_GENERAL_INFORMATION(),
                            SAMPR_DOMAIN_GENERAL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_LOGOFF_INFORMATION(),
                            DOMAIN_LOGOFF_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainLogoffInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainLogoffInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_OEM_INFORMATION(),
                            SAMPR_DOMAIN_OEM_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainOemInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainOemInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_NAME_INFORMATION(),
                            SAMPR_DOMAIN_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_SERVER_ROLE_INFORMATION(),
                            DOMAIN_SERVER_ROLE_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainServerRoleInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainServerRoleInformation
                            ),
                        ),
                    ),
                    (
                        NDRFullPointerField(
                            NDRPacketField(
                                "Buffer",
                                PSAMPR_DOMAIN_REPLICATION_INFORMATION(),
                                PSAMPR_DOMAIN_REPLICATION_INFORMATION,
                            )
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainReplicationInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainReplicationInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_MODIFIED_INFORMATION(),
                            DOMAIN_MODIFIED_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_STATE_INFORMATION(),
                            DOMAIN_STATE_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainStateInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainStateInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_GENERAL_INFORMATION2(),
                            SAMPR_DOMAIN_GENERAL_INFORMATION2,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation2
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainGeneralInformation2
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_DOMAIN_LOCKOUT_INFORMATION(),
                            SAMPR_DOMAIN_LOCKOUT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainLockoutInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainLockoutInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            DOMAIN_MODIFIED_INFORMATION2(),
                            DOMAIN_MODIFIED_INFORMATION2,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "DomainInformationClass", None)
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation2
                            ),
                            (
                                lambda _, val: val.tag
                                == DOMAIN_INFORMATION_CLASS.DomainModifiedInformation2
                            ),
                        ),
                    ),
                ],
                StrFixedLenField("Buffer", "", length=0),
                align=(2, 8),
                switch_fmt=("H", "I"),
            )
        ),
        NDRIntField("status", 0),
    ]


class SamrQueryInformationUser2_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("UserInformationClass", 0, USER_INFORMATION_CLASS),
    ]


class SamrQueryInformationUser2_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRUnionField(
                [
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_GENERAL_INFORMATION(),
                            SAMPR_USER_GENERAL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserGeneralInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserGeneralInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_PREFERENCES_INFORMATION(),
                            SAMPR_USER_PREFERENCES_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserPreferencesInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserPreferencesInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_LOGON_INFORMATION(),
                            SAMPR_USER_LOGON_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserLogonInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserLogonInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_LOGON_HOURS_INFORMATION(),
                            SAMPR_USER_LOGON_HOURS_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserLogonHoursInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserLogonHoursInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_ACCOUNT_INFORMATION(),
                            SAMPR_USER_ACCOUNT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAccountInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAccountInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_NAME_INFORMATION(),
                            SAMPR_USER_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_A_NAME_INFORMATION(),
                            SAMPR_USER_A_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAccountNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAccountNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_F_NAME_INFORMATION(),
                            SAMPR_USER_F_NAME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserFullNameInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserFullNameInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            USER_PRIMARY_GROUP_INFORMATION(),
                            USER_PRIMARY_GROUP_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_HOME_INFORMATION(),
                            SAMPR_USER_HOME_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserHomeInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserHomeInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_SCRIPT_INFORMATION(),
                            SAMPR_USER_SCRIPT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserScriptInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserScriptInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_PROFILE_INFORMATION(),
                            SAMPR_USER_PROFILE_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserProfileInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserProfileInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_ADMIN_COMMENT_INFORMATION(),
                            SAMPR_USER_ADMIN_COMMENT_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAdminCommentInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAdminCommentInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_WORKSTATIONS_INFORMATION(),
                            SAMPR_USER_WORKSTATIONS_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserWorkStationsInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserWorkStationsInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            USER_CONTROL_INFORMATION(),
                            USER_CONTROL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserControlInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserControlInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            USER_EXPIRES_INFORMATION(),
                            USER_EXPIRES_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserExpiresInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserExpiresInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL1_INFORMATION(),
                            SAMPR_USER_INTERNAL1_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal1Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal1Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_PARAMETERS_INFORMATION(),
                            SAMPR_USER_PARAMETERS_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserParametersInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserParametersInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_ALL_INFORMATION(),
                            SAMPR_USER_ALL_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserAllInformation
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserAllInformation
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL4_INFORMATION(),
                            SAMPR_USER_INTERNAL4_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal4Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal4Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL5_INFORMATION(),
                            SAMPR_USER_INTERNAL5_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal5Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal5Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL4_INFORMATION_NEW(),
                            SAMPR_USER_INTERNAL4_INFORMATION_NEW,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal4InformationNew
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal4InformationNew
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL5_INFORMATION_NEW(),
                            SAMPR_USER_INTERNAL5_INFORMATION_NEW,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal5InformationNew
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal5InformationNew
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL7_INFORMATION(),
                            SAMPR_USER_INTERNAL7_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal7Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal7Information
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "Buffer",
                            SAMPR_USER_INTERNAL8_INFORMATION(),
                            SAMPR_USER_INTERNAL8_INFORMATION,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "UserInformationClass", None)
                                == USER_INFORMATION_CLASS.UserInternal8Information
                            ),
                            (
                                lambda _, val: val.tag
                                == USER_INFORMATION_CLASS.UserInternal8Information
                            ),
                        ),
                    ),
                ],
                StrFixedLenField("Buffer", "", length=0),
                align=(2, 8),
                switch_fmt=("H", "I"),
            )
        ),
        NDRIntField("status", 0),
    ]


class SamrQueryDisplayInformation2_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DisplayInformationClass", 0, DOMAIN_DISPLAY_INFORMATION),
        NDRIntField("Index", 0),
        NDRIntField("EntryCount", 0),
        NDRIntField("PreferredMaximumLength", 0),
    ]


class SamrQueryDisplayInformation2_Response(NDRPacket):
    fields_desc = [
        NDRIntField("TotalAvailable", 0),
        NDRIntField("TotalReturned", 0),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_USER_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_USER_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayUser
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayUser
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_MACHINE_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_MACHINE_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayMachine
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayMachine
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_GROUP_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_GROUP_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayGroup
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayGroup
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_OEM_USER_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_OEM_USER_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemUser
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemUser
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_OEM_GROUP_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_OEM_GROUP_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemGroup
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemGroup
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
        NDRIntField("status", 0),
    ]


class SamrGetDisplayEnumerationIndex2_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DisplayInformationClass", 0, DOMAIN_DISPLAY_INFORMATION),
        NDRPacketField("Prefix", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
    ]


class SamrGetDisplayEnumerationIndex2_Response(NDRPacket):
    fields_desc = [NDRIntField("Index", 0), NDRIntField("status", 0)]


class SamrCreateUser2InDomain_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("Name", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
        NDRIntField("AccountType", 0),
        NDRIntField("DesiredAccess", 0),
    ]


class SamrCreateUser2InDomain_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("GrantedAccess", 0),
        NDRIntField("RelativeId", 0),
        NDRIntField("status", 0),
    ]


class SamrQueryDisplayInformation3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DomainHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("DisplayInformationClass", 0, DOMAIN_DISPLAY_INFORMATION),
        NDRIntField("Index", 0),
        NDRIntField("EntryCount", 0),
        NDRIntField("PreferredMaximumLength", 0),
    ]


class SamrQueryDisplayInformation3_Response(NDRPacket):
    fields_desc = [
        NDRIntField("TotalAvailable", 0),
        NDRIntField("TotalReturned", 0),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_USER_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_USER_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayUser
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayUser
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_MACHINE_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_MACHINE_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayMachine
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayMachine
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_GROUP_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_GROUP_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayGroup
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayGroup
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_OEM_USER_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_OEM_USER_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemUser
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemUser
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_DOMAIN_DISPLAY_OEM_GROUP_BUFFER(),
                        SAMPR_DOMAIN_DISPLAY_OEM_GROUP_BUFFER,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "DisplayInformationClass", None)
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemGroup
                        ),
                        (
                            lambda _, val: val.tag
                            == DOMAIN_DISPLAY_INFORMATION.DomainDisplayOemGroup
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
        NDRIntField("status", 0),
    ]


class SamrAddMultipleMembersToAlias_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("MembersBuffer", PSAMPR_PSID_ARRAY(), PSAMPR_PSID_ARRAY),
    ]


class SamrAddMultipleMembersToAlias_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrRemoveMultipleMembersFromAlias_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("AliasHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("MembersBuffer", PSAMPR_PSID_ARRAY(), PSAMPR_PSID_ARRAY),
    ]


class SamrRemoveMultipleMembersFromAlias_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class PRPC_STRING(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer"),
        NDRShortField("MaximumLength", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfVarStrLenField(
                "Buffer",
                "",
                size_is=lambda pkt: pkt.MaximumLength,
                length_is=lambda pkt: pkt.Length,
            ),
            deferred=True,
        ),
    ]


class PSAMPR_ENCRYPTED_USER_PASSWORD(NDRPacket):
    fields_desc = [StrFixedLenField("Buffer", "", length=((256 * 2) + 4))]


class SamrOemChangePasswordUser2_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRPacketField("ServerName", PRPC_STRING(), PRPC_STRING)),
        NDRPacketField("UserName", PRPC_STRING(), PRPC_STRING),
        NDRFullPointerField(
            NDRPacketField(
                "NewPasswordEncryptedWithOldLm",
                PSAMPR_ENCRYPTED_USER_PASSWORD(),
                PSAMPR_ENCRYPTED_USER_PASSWORD,
            )
        ),
        NDRFullPointerField(
            NDRPacketField(
                "OldLmOwfPasswordEncryptedWithNewLm",
                PENCRYPTED_LM_OWF_PASSWORD(),
                PENCRYPTED_LM_OWF_PASSWORD,
            )
        ),
    ]


class SamrOemChangePasswordUser2_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrUnicodeChangePasswordUser2_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ServerName", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING)
        ),
        NDRPacketField("UserName", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
        NDRFullPointerField(
            NDRPacketField(
                "NewPasswordEncryptedWithOldNt",
                PSAMPR_ENCRYPTED_USER_PASSWORD(),
                PSAMPR_ENCRYPTED_USER_PASSWORD,
            )
        ),
        NDRFullPointerField(
            NDRPacketField(
                "OldNtOwfPasswordEncryptedWithNewNt",
                PENCRYPTED_NT_OWF_PASSWORD(),
                PENCRYPTED_NT_OWF_PASSWORD,
            )
        ),
        NDRByteField("LmPresent", 0),
        NDRFullPointerField(
            NDRPacketField(
                "NewPasswordEncryptedWithOldLm",
                PSAMPR_ENCRYPTED_USER_PASSWORD(),
                PSAMPR_ENCRYPTED_USER_PASSWORD,
            )
        ),
        NDRFullPointerField(
            NDRPacketField(
                "OldLmOwfPasswordEncryptedWithNewNt",
                PENCRYPTED_LM_OWF_PASSWORD(),
                PENCRYPTED_LM_OWF_PASSWORD,
            )
        ),
    ]


class SamrUnicodeChangePasswordUser2_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrGetDomainPasswordInformation_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("Unused", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING)
        )
    ]


class SamrGetDomainPasswordInformation_Response(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "PasswordInformation",
            PUSER_DOMAIN_PASSWORD_INFORMATION(),
            PUSER_DOMAIN_PASSWORD_INFORMATION,
        ),
        NDRIntField("status", 0),
    ]


class SamrConnect2_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRIntField("DesiredAccess", 0),
    ]


class SamrConnect2_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class SamrSetInformationUser2_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("UserHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("UserInformationClass", 0, USER_INFORMATION_CLASS),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_GENERAL_INFORMATION(),
                        SAMPR_USER_GENERAL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserGeneralInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserGeneralInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_PREFERENCES_INFORMATION(),
                        SAMPR_USER_PREFERENCES_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserPreferencesInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserPreferencesInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_LOGON_INFORMATION(),
                        SAMPR_USER_LOGON_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserLogonInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserLogonInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_LOGON_HOURS_INFORMATION(),
                        SAMPR_USER_LOGON_HOURS_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserLogonHoursInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserLogonHoursInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_ACCOUNT_INFORMATION(),
                        SAMPR_USER_ACCOUNT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAccountInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAccountInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_NAME_INFORMATION(),
                        SAMPR_USER_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_A_NAME_INFORMATION(),
                        SAMPR_USER_A_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAccountNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAccountNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_F_NAME_INFORMATION(),
                        SAMPR_USER_F_NAME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserFullNameInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserFullNameInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        USER_PRIMARY_GROUP_INFORMATION(),
                        USER_PRIMARY_GROUP_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserPrimaryGroupInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_HOME_INFORMATION(),
                        SAMPR_USER_HOME_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserHomeInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserHomeInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_SCRIPT_INFORMATION(),
                        SAMPR_USER_SCRIPT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserScriptInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserScriptInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_PROFILE_INFORMATION(),
                        SAMPR_USER_PROFILE_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserProfileInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserProfileInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_ADMIN_COMMENT_INFORMATION(),
                        SAMPR_USER_ADMIN_COMMENT_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAdminCommentInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAdminCommentInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_WORKSTATIONS_INFORMATION(),
                        SAMPR_USER_WORKSTATIONS_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserWorkStationsInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserWorkStationsInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer", USER_CONTROL_INFORMATION(), USER_CONTROL_INFORMATION
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserControlInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserControlInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer", USER_EXPIRES_INFORMATION(), USER_EXPIRES_INFORMATION
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserExpiresInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserExpiresInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL1_INFORMATION(),
                        SAMPR_USER_INTERNAL1_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal1Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal1Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_PARAMETERS_INFORMATION(),
                        SAMPR_USER_PARAMETERS_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserParametersInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserParametersInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_ALL_INFORMATION(),
                        SAMPR_USER_ALL_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserAllInformation
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserAllInformation
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL4_INFORMATION(),
                        SAMPR_USER_INTERNAL4_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal4Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal4Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL5_INFORMATION(),
                        SAMPR_USER_INTERNAL5_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal5Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal5Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL4_INFORMATION_NEW(),
                        SAMPR_USER_INTERNAL4_INFORMATION_NEW,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal4InformationNew
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal4InformationNew
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL5_INFORMATION_NEW(),
                        SAMPR_USER_INTERNAL5_INFORMATION_NEW,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal5InformationNew
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal5InformationNew
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL7_INFORMATION(),
                        SAMPR_USER_INTERNAL7_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal7Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal7Information
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "Buffer",
                        SAMPR_USER_INTERNAL8_INFORMATION(),
                        SAMPR_USER_INTERNAL8_INFORMATION,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "UserInformationClass", None)
                            == USER_INFORMATION_CLASS.UserInternal8Information
                        ),
                        (
                            lambda _, val: val.tag
                            == USER_INFORMATION_CLASS.UserInternal8Information
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Buffer", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class SamrSetInformationUser2_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class SamrConnect4_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRIntField("ClientRevision", 0),
        NDRIntField("DesiredAccess", 0),
    ]


class SamrConnect4_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class SAMPR_REVISION_INFO_V1(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("Revision", 0), NDRIntField("SupportedFeatures", 0)]


class SamrConnect5_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRIntField("DesiredAccess", 0),
        NDRIntField("InVersion", 0),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "OutRevisionInfo",
                        SAMPR_REVISION_INFO_V1(),
                        SAMPR_REVISION_INFO_V1,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "InVersion", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                )
            ],
            StrFixedLenField("OutRevisionInfo", "", length=0),
            align=(4, 4),
            switch_fmt=("L", "L"),
        ),
    ]


class SamrConnect5_Response(NDRPacket):
    fields_desc = [
        NDRIntField("OutVersion", 0),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "OutRevisionInfo",
                        SAMPR_REVISION_INFO_V1(),
                        SAMPR_REVISION_INFO_V1,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "OutVersion", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                )
            ],
            StrFixedLenField("OutRevisionInfo", "", length=0),
            align=(4, 4),
            switch_fmt=("L", "L"),
        ),
        NDRPacketField("ServerHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class SamrRidToSid_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ObjectHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Rid", 0),
    ]


class SamrRidToSid_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRPacketField("Sid", PRPC_SID(), PRPC_SID)),
        NDRIntField("status", 0),
    ]


class SamrSetDSRMPassword_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("Unused", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING)
        ),
        NDRIntField("UserId", 0),
        NDRFullPointerField(
            NDRPacketField(
                "EncryptedNtOwfPassword",
                PENCRYPTED_NT_OWF_PASSWORD(),
                PENCRYPTED_NT_OWF_PASSWORD,
            )
        ),
    ]


class SamrSetDSRMPassword_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class PASSWORD_POLICY_VALIDATION_TYPE(IntEnum):
    SamValidateAuthentication = 1
    SamValidatePasswordChange = 2
    SamValidatePasswordReset = 3


class PSAM_VALIDATE_PASSWORD_HASH(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Length", None, size_of="Hash"),
        NDRFullPointerField(
            NDRConfStrLenField("Hash", "", size_is=lambda pkt: pkt.Length),
            deferred=True,
        ),
    ]


class SAM_VALIDATE_PERSISTED_FIELDS(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("PresentFields", 0),
        NDRPacketField("PasswordLastSet", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("BadPasswordTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("LockoutTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRIntField("BadPasswordCount", 0),
        NDRIntField("PasswordHistoryLength", None, size_of="PasswordHistory"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "PasswordHistory",
                [PSAM_VALIDATE_PASSWORD_HASH()],
                PSAM_VALIDATE_PASSWORD_HASH,
                size_is=lambda pkt: pkt.PasswordHistoryLength,
            ),
            deferred=True,
        ),
    ]


class SAM_VALIDATE_AUTHENTICATION_INPUT_ARG(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField(
            "InputPersistedFields",
            SAM_VALIDATE_PERSISTED_FIELDS(),
            SAM_VALIDATE_PERSISTED_FIELDS,
        ),
        NDRByteField("PasswordMatched", 0),
    ]


class SAM_VALIDATE_PASSWORD_HASH(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Length", None, size_of="Hash"),
        NDRFullPointerField(
            NDRConfStrLenField("Hash", "", size_is=lambda pkt: pkt.Length),
            deferred=True,
        ),
    ]


class SAM_VALIDATE_PASSWORD_CHANGE_INPUT_ARG(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField(
            "InputPersistedFields",
            SAM_VALIDATE_PERSISTED_FIELDS(),
            SAM_VALIDATE_PERSISTED_FIELDS,
        ),
        NDRPacketField("ClearPassword", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("UserAccountName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField(
            "HashedPassword", SAM_VALIDATE_PASSWORD_HASH(), SAM_VALIDATE_PASSWORD_HASH
        ),
        NDRByteField("PasswordMatch", 0),
    ]


class SAM_VALIDATE_PASSWORD_RESET_INPUT_ARG(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField(
            "InputPersistedFields",
            SAM_VALIDATE_PERSISTED_FIELDS(),
            SAM_VALIDATE_PERSISTED_FIELDS,
        ),
        NDRPacketField("ClearPassword", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField("UserAccountName", RPC_UNICODE_STRING(), RPC_UNICODE_STRING),
        NDRPacketField(
            "HashedPassword", SAM_VALIDATE_PASSWORD_HASH(), SAM_VALIDATE_PASSWORD_HASH
        ),
        NDRByteField("PasswordMustChangeAtNextLogon", 0),
        NDRByteField("ClearLockout", 0),
    ]


class SAM_VALIDATE_VALIDATION_STATUS(IntEnum):
    SamValidateSuccess = 0
    SamValidatePasswordMustChange = 1
    SamValidateAccountLockedOut = 2
    SamValidatePasswordExpired = 3
    SamValidatePasswordIncorrect = 4
    SamValidatePasswordIsInHistory = 5
    SamValidatePasswordTooShort = 6
    SamValidatePasswordTooLong = 7
    SamValidatePasswordNotComplexEnough = 8
    SamValidatePasswordTooRecent = 9
    SamValidatePasswordFilterError = 10


class SAM_VALIDATE_STANDARD_OUTPUT_ARG(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField(
            "ChangedPersistedFields",
            SAM_VALIDATE_PERSISTED_FIELDS(),
            SAM_VALIDATE_PERSISTED_FIELDS,
        ),
        NDRInt3264EnumField("ValidationStatus", 0, SAM_VALIDATE_VALIDATION_STATUS),
    ]


class SamrValidatePassword_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("ValidationType", 0, PASSWORD_POLICY_VALIDATION_TYPE),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "InputArg",
                        SAM_VALIDATE_AUTHENTICATION_INPUT_ARG(),
                        SAM_VALIDATE_AUTHENTICATION_INPUT_ARG,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ValidationType", None)
                            == PASSWORD_POLICY_VALIDATION_TYPE.SamValidateAuthentication
                        ),
                        (
                            lambda _, val: val.tag
                            == PASSWORD_POLICY_VALIDATION_TYPE.SamValidateAuthentication
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "InputArg",
                        SAM_VALIDATE_PASSWORD_CHANGE_INPUT_ARG(),
                        SAM_VALIDATE_PASSWORD_CHANGE_INPUT_ARG,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ValidationType", None)
                            == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordChange
                        ),
                        (
                            lambda _, val: val.tag
                            == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordChange
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "InputArg",
                        SAM_VALIDATE_PASSWORD_RESET_INPUT_ARG(),
                        SAM_VALIDATE_PASSWORD_RESET_INPUT_ARG,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ValidationType", None)
                            == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordReset
                        ),
                        (
                            lambda _, val: val.tag
                            == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordReset
                        ),
                    ),
                ),
            ],
            StrFixedLenField("InputArg", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class SamrValidatePassword_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRUnionField(
                [
                    (
                        NDRPacketField(
                            "OutputArg",
                            SAM_VALIDATE_STANDARD_OUTPUT_ARG(),
                            SAM_VALIDATE_STANDARD_OUTPUT_ARG,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "ValidationType", None)
                                == PASSWORD_POLICY_VALIDATION_TYPE.SamValidateAuthentication
                            ),
                            (
                                lambda _, val: val.tag
                                == PASSWORD_POLICY_VALIDATION_TYPE.SamValidateAuthentication
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "OutputArg",
                            SAM_VALIDATE_STANDARD_OUTPUT_ARG(),
                            SAM_VALIDATE_STANDARD_OUTPUT_ARG,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "ValidationType", None)
                                == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordChange
                            ),
                            (
                                lambda _, val: val.tag
                                == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordChange
                            ),
                        ),
                    ),
                    (
                        NDRPacketField(
                            "OutputArg",
                            SAM_VALIDATE_STANDARD_OUTPUT_ARG(),
                            SAM_VALIDATE_STANDARD_OUTPUT_ARG,
                        ),
                        (
                            (
                                lambda pkt: getattr(pkt, "ValidationType", None)
                                == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordReset
                            ),
                            (
                                lambda _, val: val.tag
                                == PASSWORD_POLICY_VALIDATION_TYPE.SamValidatePasswordReset
                            ),
                        ),
                    ),
                ],
                StrFixedLenField("OutputArg", "", length=0),
                align=(2, 8),
                switch_fmt=("H", "I"),
            )
        ),
        NDRIntField("status", 0),
    ]


class PSAMPR_ENCRYPTED_PASSWORD_AES(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        StrFixedLenField("AuthData", "", length=64),
        StrFixedLenField("Salt", "", length=16),
        NDRIntField("cbCipher", None, size_of="Cipher"),
        NDRFullPointerField(
            NDRConfStrLenField("Cipher", "", size_is=lambda pkt: pkt.cbCipher),
            deferred=True,
        ),
        NDRLongField("PBKDF2Iterations", 0),
    ]


class SamrUnicodeChangePasswordUser4_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ServerName", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING)
        ),
        NDRPacketField("UserName", PRPC_UNICODE_STRING(), PRPC_UNICODE_STRING),
        NDRPacketField(
            "EncryptedPassword",
            PSAMPR_ENCRYPTED_PASSWORD_AES(),
            PSAMPR_ENCRYPTED_PASSWORD_AES,
        ),
    ]


class SamrUnicodeChangePasswordUser4_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


SAMR_OPNUMS = {
    0: DceRpcOp(SamrConnect_Request, SamrConnect_Response),
    1: DceRpcOp(SamrCloseHandle_Request, SamrCloseHandle_Response),
    2: DceRpcOp(SamrSetSecurityObject_Request, SamrSetSecurityObject_Response),
    3: DceRpcOp(SamrQuerySecurityObject_Request, SamrQuerySecurityObject_Response),
    # 4: Opnum4NotUsedOnWire,
    5: DceRpcOp(
        SamrLookupDomainInSamServer_Request, SamrLookupDomainInSamServer_Response
    ),
    6: DceRpcOp(
        SamrEnumerateDomainsInSamServer_Request,
        SamrEnumerateDomainsInSamServer_Response,
    ),
    7: DceRpcOp(SamrOpenDomain_Request, SamrOpenDomain_Response),
    8: DceRpcOp(
        SamrQueryInformationDomain_Request, SamrQueryInformationDomain_Response
    ),
    9: DceRpcOp(SamrSetInformationDomain_Request, SamrSetInformationDomain_Response),
    10: DceRpcOp(SamrCreateGroupInDomain_Request, SamrCreateGroupInDomain_Response),
    11: DceRpcOp(
        SamrEnumerateGroupsInDomain_Request, SamrEnumerateGroupsInDomain_Response
    ),
    12: DceRpcOp(SamrCreateUserInDomain_Request, SamrCreateUserInDomain_Response),
    13: DceRpcOp(
        SamrEnumerateUsersInDomain_Request, SamrEnumerateUsersInDomain_Response
    ),
    14: DceRpcOp(SamrCreateAliasInDomain_Request, SamrCreateAliasInDomain_Response),
    15: DceRpcOp(
        SamrEnumerateAliasesInDomain_Request, SamrEnumerateAliasesInDomain_Response
    ),
    16: DceRpcOp(SamrGetAliasMembership_Request, SamrGetAliasMembership_Response),
    17: DceRpcOp(SamrLookupNamesInDomain_Request, SamrLookupNamesInDomain_Response),
    18: DceRpcOp(SamrLookupIdsInDomain_Request, SamrLookupIdsInDomain_Response),
    19: DceRpcOp(SamrOpenGroup_Request, SamrOpenGroup_Response),
    20: DceRpcOp(SamrQueryInformationGroup_Request, SamrQueryInformationGroup_Response),
    21: DceRpcOp(SamrSetInformationGroup_Request, SamrSetInformationGroup_Response),
    22: DceRpcOp(SamrAddMemberToGroup_Request, SamrAddMemberToGroup_Response),
    23: DceRpcOp(SamrDeleteGroup_Request, SamrDeleteGroup_Response),
    24: DceRpcOp(SamrRemoveMemberFromGroup_Request, SamrRemoveMemberFromGroup_Response),
    25: DceRpcOp(SamrGetMembersInGroup_Request, SamrGetMembersInGroup_Response),
    26: DceRpcOp(
        SamrSetMemberAttributesOfGroup_Request, SamrSetMemberAttributesOfGroup_Response
    ),
    27: DceRpcOp(SamrOpenAlias_Request, SamrOpenAlias_Response),
    28: DceRpcOp(SamrQueryInformationAlias_Request, SamrQueryInformationAlias_Response),
    29: DceRpcOp(SamrSetInformationAlias_Request, SamrSetInformationAlias_Response),
    30: DceRpcOp(SamrDeleteAlias_Request, SamrDeleteAlias_Response),
    31: DceRpcOp(SamrAddMemberToAlias_Request, SamrAddMemberToAlias_Response),
    32: DceRpcOp(SamrRemoveMemberFromAlias_Request, SamrRemoveMemberFromAlias_Response),
    33: DceRpcOp(SamrGetMembersInAlias_Request, SamrGetMembersInAlias_Response),
    34: DceRpcOp(SamrOpenUser_Request, SamrOpenUser_Response),
    35: DceRpcOp(SamrDeleteUser_Request, SamrDeleteUser_Response),
    36: DceRpcOp(SamrQueryInformationUser_Request, SamrQueryInformationUser_Response),
    37: DceRpcOp(SamrSetInformationUser_Request, SamrSetInformationUser_Response),
    38: DceRpcOp(SamrChangePasswordUser_Request, SamrChangePasswordUser_Response),
    39: DceRpcOp(SamrGetGroupsForUser_Request, SamrGetGroupsForUser_Response),
    40: DceRpcOp(
        SamrQueryDisplayInformation_Request, SamrQueryDisplayInformation_Response
    ),
    41: DceRpcOp(
        SamrGetDisplayEnumerationIndex_Request, SamrGetDisplayEnumerationIndex_Response
    ),
    # 42: Opnum42NotUsedOnWire,
    # 43: Opnum43NotUsedOnWire,
    44: DceRpcOp(
        SamrGetUserDomainPasswordInformation_Request,
        SamrGetUserDomainPasswordInformation_Response,
    ),
    45: DceRpcOp(
        SamrRemoveMemberFromForeignDomain_Request,
        SamrRemoveMemberFromForeignDomain_Response,
    ),
    46: DceRpcOp(
        SamrQueryInformationDomain2_Request, SamrQueryInformationDomain2_Response
    ),
    47: DceRpcOp(SamrQueryInformationUser2_Request, SamrQueryInformationUser2_Response),
    48: DceRpcOp(
        SamrQueryDisplayInformation2_Request, SamrQueryDisplayInformation2_Response
    ),
    49: DceRpcOp(
        SamrGetDisplayEnumerationIndex2_Request,
        SamrGetDisplayEnumerationIndex2_Response,
    ),
    50: DceRpcOp(SamrCreateUser2InDomain_Request, SamrCreateUser2InDomain_Response),
    51: DceRpcOp(
        SamrQueryDisplayInformation3_Request, SamrQueryDisplayInformation3_Response
    ),
    52: DceRpcOp(
        SamrAddMultipleMembersToAlias_Request, SamrAddMultipleMembersToAlias_Response
    ),
    53: DceRpcOp(
        SamrRemoveMultipleMembersFromAlias_Request,
        SamrRemoveMultipleMembersFromAlias_Response,
    ),
    54: DceRpcOp(
        SamrOemChangePasswordUser2_Request, SamrOemChangePasswordUser2_Response
    ),
    55: DceRpcOp(
        SamrUnicodeChangePasswordUser2_Request, SamrUnicodeChangePasswordUser2_Response
    ),
    56: DceRpcOp(
        SamrGetDomainPasswordInformation_Request,
        SamrGetDomainPasswordInformation_Response,
    ),
    57: DceRpcOp(SamrConnect2_Request, SamrConnect2_Response),
    58: DceRpcOp(SamrSetInformationUser2_Request, SamrSetInformationUser2_Response),
    # 59: Opnum59NotUsedOnWire,
    # 60: Opnum60NotUsedOnWire,
    # 61: Opnum61NotUsedOnWire,
    62: DceRpcOp(SamrConnect4_Request, SamrConnect4_Response),
    # 63: Opnum63NotUsedOnWire,
    64: DceRpcOp(SamrConnect5_Request, SamrConnect5_Response),
    65: DceRpcOp(SamrRidToSid_Request, SamrRidToSid_Response),
    66: DceRpcOp(SamrSetDSRMPassword_Request, SamrSetDSRMPassword_Response),
    67: DceRpcOp(SamrValidatePassword_Request, SamrValidatePassword_Response),
    # 68: Opnum68NotUsedOnWire,
    # 69: Opnum69NotUsedOnWire,
    # 70: Opnum70NotUsedOnWire,
    # 71: Opnum71NotUsedOnWire,
    # 72: Opnum72NotUsedOnWire,
    73: DceRpcOp(
        SamrUnicodeChangePasswordUser4_Request, SamrUnicodeChangePasswordUser4_Response
    ),
}
register_dcerpc_interface(
    name="samr",
    uuid=uuid.UUID("12345778-1234-ABCD-EF00-0123456789AC"),
    version="1.0",
    opnums=SAMR_OPNUMS,
)
