使用 LDAP 查询获取反向查找区域中 DNSNode 记录的 IP 地址

使用 LDAP 查询获取反向查找区域中 DNSNode 记录的 IP 地址

想问一个问题:如何使用 LDAP 查询反向查找区域中的 DNS 节点来获取 IP 地址?更准确地说,我想向您展示我一直在努力实现的目标:

DNSNode 的属性

在上图中,我们看到了通过运行 LDAP 查询检索到的 DNS 节点的属性。是否可以以某种方式(例如,使用某些 .NET 函数)从“dnsrecord”属性中获取节点的 IP 地址,而无需操作“distinguishedname”、“name”、“dc”属性中的字符串来实现相同的目标?

谢谢!

答案1

dsnRecord 是一个字节数组。

数据结构的示例位于以下 DNSShell PowerShell 模块中。它们本身不提供 PTR 记录,但您可能可以使用其他一些示例找出差异。请注意,TtlSeconds 是大端字节顺序。

https://archive.codeplex.com/?p=dnsshell

/// <summary>
/// https://msdn.microsoft.com/en-us/library/ee898781.aspx
/// The dnsRecord attribute is used to store DNS resource record definitions. This attribute MUST be formatted as follows:
/// 
/// DataLength (2 bytes): An unsigned binary integer containing the length, in bytes, of the Data field.
/// Type (2 bytes): The resource record's type. See DNS_RECORD_TYPE (section 2.2.2.1.1).
/// Version (1 byte): The version number associated with the resource record attribute. The value MUST be 0x05.
/// Rank (1 byte): The least-significant byte of one of the RANK* flag values. See dwFlags (section 2.2.2.2.5).
/// Flags (2 bytes): Not used. The value MUST be 0x0000.
/// Serial (4 bytes): The serial number of the SOA record of the zone containing this resource record. See DNS_RPC_RECORD_SOA (section 2.2.2.2.4.3).
/// TtlSeconds (4 bytes): See dwTtlSeconds (section 2.2.2.2.5). This field uses big-endian byte order.
/// Reserved (4 bytes): This field is reserved for future use. The value MUST be 0x00000000.
/// TimeStamp (4 bytes): See dwTimeStamp (section 2.2.2.2.5).
/// Data (variable): The resource record's data. See DNS_RPC_RECORD_DATA (section 2.2.2.2.4).
/// </summary>
/// <example>
///                                 1  1  1  1  1  1
///   0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |                 DATA LENGTH                   |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |                      TYPE                     |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |        VERSION        |         RANK          |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |                     FLAGS                     |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |                     SERIAL                    |
///  |                                               |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |                  TTLSECONDS                   |
///  |                                               |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |                    RESERVED                   |
///  |                                               |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  |                   TIMESTAMP                   |
///  |                                               |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
///  |                     DATA                      |
///  |                                               |
///  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///  </example>

相关内容