我正在尝试通过 Python 编辑 Active Directory dnsRecord 值。属性值是一个二进制结构 - 我在各个地方找到该结构的文档,例如 http://www.indented.co.uk/2009/06/18/mapping-the-dnsrecord-attribute/我还找到了一些用于解释值的 Perl 代码示例,例如 https://wiki.samba.org/index.php/Working_with_Active_Directory_encoded_LDAP_values
但是我没有成功使用 Python 解码值
示例值:'\x04\x00\x01\x00\x05\xf0\x00\x00R\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|i7\x00\xc0\xa8\x016' - 我知道这是一条将名称“barbel”指向 192.168.1.54 的 A 记录
有人在 Python 中使用过 dnsRecord 值吗?
最佳答案
dnsRecord 的结构似乎在 Microsoft 的 DNS 开放规范文档 (MS-DNSP) 中进行了描述。特别是对于 dnsRecord,它在第 2.3.2.2 节中进行了描述:
https://msdn.microsoft.com/en-us/library/ee898781.aspx
来自上面的链接:
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).
挑战当然是根据上述内容解码 AD 中的二进制 dnsRecord 值。因为几个部分也有自己的部分来描述它们的值。我还没有解码这些值,但希望这些信息至少能让您走上正确的道路。
关于python - 使用 Python 对 AD dnsRecord 值进行编码/解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43377036/