<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indented! &#187; dnsRecord</title>
	<atom:link href="http://www.indented.co.uk/index.php/tag/dnsrecord/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indented.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 10:45:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Mapping the DNSRecord attribute</title>
		<link>http://www.indented.co.uk/index.php/2009/06/18/mapping-the-dnsrecord-attribute/</link>
		<comments>http://www.indented.co.uk/index.php/2009/06/18/mapping-the-dnsrecord-attribute/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 10:44:16 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Microsoft DNS]]></category>
		<category><![CDATA[dnsRecord]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=1097</guid>
		<description><![CDATA[Microsoft DNS is able to store records in Active Directory when running on a Domain Controller. The information is stored in a Binary Large Object (BLOB) called DNSRecord. No official maps for that attribute appear to have been published. The information below is a result of reverse engineering the contents of the attribute. Michael Smith [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Microsoft DNS is able to store records in Active Directory when running on a Domain Controller. The information is stored in a Binary Large Object (BLOB) called DNSRecord. No official maps for that attribute appear to have been published. The information below is a result of reverse engineering the contents of the attribute.</p>
<p>Michael Smith has a very pretty PowerShell script which uses the structures below, and a few more, to convert the DnsRecord attribute into a human readable format on his blog, <a href='http://theessentialexchange.com/blogs/michael/archive/2009/12/22/getting-the-contents-of-an-active-directory-integrated-dns-zone-version-2.aspx'>Michael&#8217;s meanderings&#8230;</a>.</p>
<p><i>Update 02/02/2010: In December 2009, Microsoft released a (not entirely accurate) protocol specification including details of dnsRecord and dnsProperty: <a href='http://download.microsoft.com/download/9/5/E/95EF66AF-9026-4BB0-A41D-A4F81802D92C/%5BMS-DNSP%5D.pdf'>MS-DNSP.pdf</a></i><br />
<span id="more-1097"></span></p>
<h3>About the mapped structure</h3>
<p>The map created below for DNSRecord is incomplete, the remaining values seem to defy testing. While the map below is probably accurate I reserve the right to be wrong. Despite that, the structures can be used to manually construct or decode DNSRecords via LDAP rather than using the GUI, dnscmd or WMI. <i>Edit: The map is now complete</i>.</p>
<h3>About DNSRecord</h3>
<p>The dnsRecord attribute appears on dnsNode objects. The dnsRecord attribute is multi-valued. This means that each node can contain more than one record. This is most obvious for the node representing &#8220;same as parent folder&#8221; which will hold the NS records and SOA records as a minimum.</p>
<h3>Structures: DNSRecord</h3>
<p>The DNSRecord attribute is comprised of the fields described in the table below.</p>
<table>
<tr>
<th class="tableleft">Field Name</th>
<th class="tableleft">Length (Bytes)</th>
<th class="tableleft">Format</th>
<th class="tableright">Description</th>
</tr>
<tr>
<td class="tableleft">RData Length</td>
<td class="tableleft">2</td>
<td class="tableleft">Little Endian</td>
<td class="tableright">Length of the Record Data block</td>
</tr>
<tr>
<td class="tableleft">Type</td>
<td class="tableleft">2</td>
<td class="tableleft">Little Endian</td>
<td class="tableright">Record type. Matches published type values on <a href="http://www.iana.org/assignments/dns-parameters">IANA</a></td>
</tr>
<tr>
<td class="tableleft">Unknown (1)</td>
<td class="tableleft">4</td>
<td class="tableleft">N/A</td>
<td class="tableright">Predictable, but unknown.</td>
</tr>
<tr>
<td class="tableleft">UpdatedAtSerial</td>
<td class="tableleft">4</td>
<td class="tableleft">Little Endian</td>
<td class="tableright">Changes to match the serial number in the SOA whenever the record is modified</td>
</tr>
<tr>
<td class="tableleft">TTL</td>
<td class="tableleft">4</td>
<td class="tableleft">Big Endian</td>
<td class="tableright">Time To Live value for the record</td>
</tr>
<tr>
<td class="tableleft">Unknown (2)</td>
<td class="tableleft">4</td>
<td class="tableleft">N/A</td>
<td class="tableright">Always 0</td>
</tr>
<tr>
<td class="tableleft">TimeStamp</td>
<td class="tableleft">4</td>
<td class="tableleft">Little Endian</td>
<td class="tableright">TimeStamp in hours from 01/01/1601 00:00:00</td>
</tr>
<tr>
<td class="tableleft">RData</td>
<td class="tableleft">Variable</td>
<td class="tableleft">Variable</td>
<td class="tableright">The record data, formatting described below</td>
</tr>
</table>
<p>These values produce the following binary array.</p>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                 RDATA LENGTH                  |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      TYPE                     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                  UNKNOWN (1)                  |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                 UPDATEDATSERIAL               |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      TTL                      |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                  UNKNOWN (2)                  |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                   TIMESTAMP                   |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
    /                     RDATA                     /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<p>Unknown 1 is a difficult value to interpret. It may contain several separate fields, however as none appear easy to decipher they were left as a single block in the map. Testing shows that &#8220;unknown 1&#8243; has the following values:</p>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |           5           |     AdvRecordType     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |           0           |           0           |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<p><i>Edit: The structure of Unknown 1 is as follows.</i></p>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |        VERSION        |     AdvRecordType     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     FLAGS                     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<p>Modifying the first byte to any (decimal) value other than 5 will cause the record to vanish from the DNS system. It will remain in the directory, but appears to render it useless. <i>Edit: 5 is the Version number and is a static value.</i></p>
<p>The second byte, termed AdvRecordType, appears to have a number of possible values. Experimentation shows that Root Hints have the value set to decimal 8, out-of-zone records (normally Glue for NS Records) have 128, delegations within a zone have 130 and everything else has 240. A larger data set than I have available is required to draw conclusions other than those.</p>
<p><i>Edit: The values for AdvRecordType, referred to as Rank in the documentation above are represented by this Enumeration.</i></p>
<pre class="brush: csharp;">
public enum RankFlag : uint
{
  // The record came from the cache.
  CacheBit = 1,
  // The record is a preconfigured root hint.
  RootHint = 8,
  // This value is not used.
  OutsideGlue = 32,
  // The record was cached from the additional section of a
  // nonauthoritative response.
  CacheNAAdditional = 49,
  // The record was cached from the authority section of a
  // nonauthoritative response.
  CacheNAAuthority = 65,
  // The record was cached from the additional section of an
  // authoritative response.
  CacheAAdditional = 81,
  // The record was cached from the answer section of a
  // nonauthoritative response.
  CacheNAAnswer = 97,
  // The record was cached from the authority section of an
  // authoritative response.
  CacheAAuthority = 113,
  // The record is a glue record in an authoritative zone.
  Glue = 128,
  // The record is a delegation (type NS) record in an
  // authoritative zone.
  NSGlue = 130,
  // The record was cached from the answer section of an
  // authoritative response.
  CacheAAnswer = 193,
  // The record comes from an authoritative zone.
  Zone = 240
 }
</pre>
<p>The final two bytes appear to be set to 0 in all instances. <i>Edit: Referred to as Flags, the value must be 0.</i></p>
<p><i>Edit: Unknown 2 is reserved for future use and should be set to 0 in all cases.</i></p>
<h3>Structures: RDATA</h3>
<p>Each of the structures below is a minimal representation of the record data, the structures show single-label names. In each case the &#8220;Label Length&#8221; and &#8220;Data&#8221; structures repeat where multiple labels are used, this also applies to &#8220;Responsible Person&#8221; in the SOA record.</p>
<h4>A</h4>
<p>The RDATA block for the A record is a static 4 byte (32 bit) field. Each byte represents an octet in the IP address.</p>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     DATA                      |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<h4>CNAME and NS</h4>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |         LENGTH        |   NUMBER OF LABELS    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |      LABEL LENGTH     |                       |
    |--+--+--+--+--+--+--+--+                       |
    /                     DATA                      /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<h4>MX</h4>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    PRIORITY                   |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |         LENGTH        |   NUMBER OF LABELS    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |      LABEL LENGTH     |                       |
    |--+--+--+--+--+--+--+--+                       |
    /                     DATA                      /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<h4>SOA</h4>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     SERIAL                    |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    REFRESH                    |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     RETRY                     |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    EXPIRE                     |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                  MINIMUM TTL                  |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |         LENGTH        |   NUMBER OF LABELS    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |      LABEL LENGTH     |                       |
    +--+--+--+--+--+--+--+--+                       |
    /                     DATA                      /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |         LENGTH        |   NUMBER OF LABELS    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |      LABEL LENGTH     |                       |
    |--+--+--+--+--+--+--+--+                       |
    /               RESPONSIBLE PERSON              /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<h4>SRV</h4>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    PRIORITY                   |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     WEIGHT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      PORT                     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |         LENGTH        |   NUMBER OF LABELS    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |      LABEL LENGTH     |                       |
    |--+--+--+--+--+--+--+--+                       |
    /                     DATA                      /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
<h4>TXT</h4>
<pre class="brush: plain;">
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |      LENGTH           |                       |
    |--+--+--+--+--+--+--+--+                       |
    /                     DATA                      /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2009/06/18/mapping-the-dnsrecord-attribute/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
