Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
DNS_RPC_RECORD (Structures)
 
.
Summary
Header and data buffer of the structure used in Microsoft "dnsNode" (Dns-Node) LDAP records.

C# Definition:

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct DNS_RPC_RECORD_HEADER
    {
        public UInt16 wDataLength;
        public UInt16 wType;
        public UInt32 dwFlags;
        public UInt32 dwSerial;
        public UInt32 dwTtlSeconds;
        public UInt32 dwReserved; // REVERSED from MS documentation
        public UInt32 dwTimeStamp; // REVERSED from MS documentation
    }
    public struct DNS_RPC_RECORD
    {
        private DNS_RPC_RECORD_HEADER header;
        public UInt16 wDataLength { get { return header.wDataLength;}}
        public UInt16 wType { get { return header.wType;}}
        public UInt32 dwFlags { get { return header.dwFlags;}}
        public UInt32 dwSerial { get { return header.dwSerial;}}
        public UInt32 dwTtlSeconds { get { return header.dwTtlSeconds;}}
        public UInt32 dwTimeStamp { get { return header.dwTimeStamp;}}
        public UInt32 dwReserved { get { return header.dwReserved; } }
        //doesn't work, use load. [MarshalAs(UnmanagedType.ByValArray, ArraySubType=UnmanagedType.U1, SizeParamIndex=1)]
        public byte[] Buffer;
        public static DNS_RPC_RECORD Load(byte[] from)
        {
        GCHandle handle = GCHandle.Alloc(from, GCHandleType.Pinned);
        DNS_RPC_RECORD_HEADER h = (DNS_RPC_RECORD_HEADER)Marshal.PtrToStructure(
            handle.AddrOfPinnedObject(), typeof(DNS_RPC_RECORD_HEADER));
        DNS_RPC_RECORD r = new DNS_RPC_RECORD();
        r.header = h;
        r.Buffer = new byte[r.wDataLength];
        Marshal.Copy(new IntPtr(handle.AddrOfPinnedObject().ToInt64() + Marshal.SizeOf(h)), r.Buffer, 0, h.wDataLength);
        handle.Free();
        return r;
        }
    }
    internal const ushort DNS_TYPE_A = 0x1;
    internal const ushort DNS_TYPE_AAAA = 0x1c;

User-Defined Field Types:

None.

Notes:

To use this, get a byte array of the LDAP object (dnsNode)'s "dnsRecord" attribute, and call the static "Load" method.

Note there can be more than one value for the dnsRecord attribute in each LDAP object, it is an array. For example, there could be several IP addresses that correspond to this node.

The Load method is needed because there's no way (that I can find) to have Marshal automatically put the trailing bytes into the Buffer array. I have invented the "DNS_RPC_RECORD_HEADER" type so that I can use PtrToStructure to load all the constant-sized parts automatically.

There are more type constants that I'm not using; see the PDF.

WARNING
The documentation (from which I created this structure) seems to have REVERSED the fields dwTimeStamp and dwReserved. When I look at live data on the server, the field which is allegedly "dwTimeStamp" is zero, but "dwReserved" contains a value equal to the time stamp (An integer value representing the number of hours that have elapsed since midnight (00:00:00), January 1, 1601 UTC). The LDP.exe tool parses the data correctly. So I'm going to switch my struct above to reflect reality.
Documentation

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions