Viewing Object Metadata






Viewing Object Metadata

Problem

You want to view metadata for an object. The object's replPropertyMetaData attribute stores metadata information about the most recent updates to every attribute that has been set on the object.

Solution

Using a graphical user interface
  1. Open LDP.

  2. From the menu, select Connection Connect.

  3. For Server, enter the name of a domain controller or domain that contains the object.

  4. For Port, enter 389.

  5. Click OK.

  6. From the menu, select Connection Bind.

  7. Enter credentials (if necessary) of a user that can view the object.

  8. Click OK.

  9. From the menu, select Browse Replication View Metadata.

  10. For Object DN, type the distinguished name of the object you want to view.

  11. Click OK.

Using a command-line interface

In the following command, replace <ObjectDN> with the distinguished name of the object for which you want to view metadata:

	> repadmin /showobjmeta <DomainControllerName> <ObjectDN>

This command was called /showmeta in the Windows 2000 version of repadmin. Also, the parameters were switched in that version; <ObjectDN> came before <DomainControllerName>.

Using VBScript
	' This code displays the metadata for the specified object.
	' ------ SCRIPT CONFIGURATION -----
	strObjectDN = "<ObjectDN>"       ' e.g. dc=rallencorp,dc=com
	strDC = "<DomainControllerName>" ' e.g. dc1
	' ------ END CONFIGURATION --------

	set objIadsTools = CreateObject("IADsTools.DCFunctions")
	intRes = objIadsTools. 
GetMetaData(Cstr(strDC),Cstr(strObjectDN),0)

	if intRes = -1 then
	   Wscript.Echo objIadsTools.LastErrorText
	   WScript.Quit
	end if

	for count = 1 to intRes
	   WScript.Echo count & ". " & objIadsTools.MetaDataName(count)
	   WScript.Echo vbTab & " Version: " & _
	                              objIadsTools.MetaDataVersionNumber(count)
	   WScript.Echo vbTab & " Last Write: " & _
	                              objIadsTools.MetaDataLastWriteTime(count)
	   WScript.Echo vbTab & " Local USN: " & _
	                              objIadsTools.MetaDataLocalUSN(count)
	   WScript.Echo vbTab & " Source USN: " & _
	                              objIadsTools.MetaDataSourceUSN(count)
	   WScript.Echo vbTab & " Server: " & _
	                              objIadsTools.MetaDataServerName(count)
	next

Discussion

Object metadata can be an invaluable source of information when you need to troubleshoot replication problems or find out the last time an attribute was set for a particular object. In fact, a quick way to determine if two domain controllers have the same copy of an object is to look at the metadata for the object on both servers. If they both have the same metadata, then they have the same version of the object.

Unfortunately, the replPropertyMetaData attribute is stored as an octet string, so in Windows 2000, you could not simply read the attribute to view all of the metadata information. In the VBScript solution, the IADsTools GetMetaData method is a wrapper around the DsReplicaGetInfo method call. This method understands the format of the replPropertyMetaData attribute and can return it into a readable format. The following data is stored for each attribute that has been set on the object:


Attribute ID

Attribute that was updated.


Attribute version

Number of originating writes to the property.


Local USN

USN of the property on the local DC. This will be the same as the originating DC if the originating DC and local DC are the same.


Originating USN

USN stored with the property when the update was made on the originating DC.


Originating DC

DC that the originating write was made on.


Time/Date

Time and date that the property was changed in UTC.

In Windows Server 2003 and ADAM, you also have access to the msDS-ReplAttributeMetaData and msDS-ReplValueMetaData attributes, which provide much object metadata in XML-formatted output, as shown through this AdFind query:

	> adfind -default -rb cn=administrator,cn=users msds-replattributemetadata

	Using server: dc2.rallencorp.com:389
	Directory: Windows Server 2003
	Base DN: cn=administrator,cn=users,DC=rallencorp,DC=com

	dn:CN=Administrator,CN=Users,DC=rallencorp,DC=com
	>msDS-ReplAttributeMetaData: <DS_REPL_ATTR_META_DATA>
	     <pszAttributeName>isCriticalSystemObject</pszAttributeName>
	     <dwVersion>1</dwVersion>
	     <ftimeLastOriginatingChange>2006-02-26T14:24:08Z</ftimeLastOriginatingChange>
	     <uuidLastOriginatingDsaInvocationID>e197616c-7465-43f2-a502-
	bac90df20b09</uuidLastOriginatingDsaInvocationID>
	     <usnOriginatingChange>8194</usnOriginatingChange>
	     <usnLocalChange>7298</usnLocalChange>
	     <pszLastOriginatingDsaDN>CN=NTDS Settings,CN=DC1,CN=Servers,CN=Default-First-
	Site-Name,CN=Sites,CN=Configuration,DC=rallencorp,DC=com</pszLastOriginatingDsaDN>
	</DS_REPL_ATTR_META_DATA>
	>msDS-ReplAttributeMetaData: <DS_REPL_ATTR_META_DATA>
	    <pszAttributeName>objectCategory</pszAttributeName>
	    <dwVersion>1</dwVersion>
	    <ftimeLastOriginatingChange>2006-02-26T14:24:08Z</ftimeLastOriginatingChange>
	    <uuidLastOriginatingDsaInvocationID>e197616c-7465-43f2-a502-
	bac90df20b09</uuidLastOriginatingDsaInvocationID>
	    <usnOriginatingChange>8194</usnOriginatingChange>
	    <usnLocalChange>7298</usnLocalChange>
	    <pszLastOriginatingDsaDN>CN=NTDS Settings,CN=DC1,CN=Servers,CN=Default-First-
	Site-Name,CN=Sites,CN=Configuration,DC=rallencorp,DC=com</pszLastOriginatingDsaDN>
	</DS_REPL_ATTR_META_DATA>

See Also

IadsTools.doc in the Support Tools for more information on the IADsTools interface



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows