Thursday, January 27, 2011

List of Attributes in the Partial Attribute Set

In many of my previous posts, I have mentioned the set of attributes stored in the Global Catalog called the "Partial Attribute Set". While there is a standard list, an administrator of a forest can promote other attributes into the partial attribute set or some products will add attributes through a schema extension. The code listed below will display what is currently queryable via the Global Catalog about objects stored within it. Ironically, the attribute isMemberOfPartialAttributeSet is not a member of the partial attribute set. It uses Write-Output to display the resulting data so you can output it to a text file for review.
$forestInformation = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$rootDse = [ADSI]("LDAP://" + ($forestInformation.Name) + "/rootDSE")

$objectConnection = New-Object -comObject "ADODB.Connection"
$objectCommand = New-Object -comObject "ADODB.Command"
$objectConnection.Open("Provider=ADsDSOObject;")
$objectCommand.ActiveConnection = $objectConnection

$ldapBase = ("LDAP://" + ($forestInformation.SchemaRoleOwner.Name) + "/" + ($rootDse.schemaNamingContext).ToString())
$ldapAttr = "lDAPDisplayName"
$ldapScope = "subtree"
$ldapFilter = "(&(objectClass=attributeSchema)(isMemberOfPartialAttributeSet=TRUE))"
$ldapQuery= "<$ldapBase>;$ldapFilter;$ldapAttr;$ldapScope"
$objectCommand.CommandText = $ldapQuery
$objectRecordSet = $objectCommand.Execute()

$title = "Attributes in the Global Catalog"
Write-Output $title
Write-Output ("-" * $title.Length)

while(!$objectRecordSet.EOF) {
 Write-Output $objectRecordSet.Fields.Item('lDAPDisplayName').Value
 $objectRecordSet.MoveNext()
}

No comments:

Post a Comment