python - 使用 Python 对 AD dnsRecord 值进行编码/解码

标签 python data-structures dns active-directory ldap

我正在尝试通过 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/

相关文章:

python - 如何在 django 管理列表顶部添加链接

java - 使用 Java Streams 对嵌套对象进行分组和排序

python - 在某些 lisp 语言上,这个 Python 散列写入/访问代码的等效项是什么?

MySQL 权限被本地拒绝但可以远程连接

wpf - 在Wpf MVVM中使用非贫血症域模型

Python 在列表列表中搜索列表值

python - 从 pdf 中删除一些图像和文本对象

python - python中的XML解析(xml.etree.ElementTree)

algorithm - 我们能否在 O(1) 时间内获得 LRU(最近最少使用)页面替换算法?

amazon-s3 - 将多个子域映射到同一个 S3 存储桶