10.18. Finding the Mandatory and Optional Attributes of a Class

Problem

You want to view the mandatory and optional attributes of a class.

Solution

Using a graphical user interface

  1. Open the Active Directory Schema snap-in.

  2. In the left pane, click on the Classes folder.

  3. In the right pane, double-click the class you want to view.

  4. Click on the Attributes tab.

Using a command-line interface

> dsquery * cn=<ClassCommonName>,cn=schema,cn=configuration,<ForestRootDN> -l[RETURN]
-scope base -attr mayContain mustContain systemMayContain systemMustContain

Using VBScript

' This code displays the mandatory and optional attributes for a class.
' ------ SCRIPT CONFIGURATION ------
' Set to common name of class to view 
strClassName = "<ClassCommonName>" ' e.g. Surname ' ------ END CONFIGURATION --------- set objRootDSE = GetObject("LDAP://RootDSE") set objClass = GetObject("LDAP://cn=" & strClassName & "," & _ objRootDSE.Get("schemaNamingContext")) WScript.Echo "Class: " & strClassName & vbCrlf ' Need to enable this so that if an attribute is not set, it won't die on error resume next WScript.Echo "mayContain:" for each strVal in objClass.Get("mayContain") WScript.Echo vbTab & strVal next WScript.Echo vbCrlf & "systemMayContain:" for each strVal in objClass.Get("systemMayContain") WScript.Echo vbTab & strVal next WScript.Echo vbCrlf & "mustContain:" for each strVal in objClass.Get("mustContain") WScript.Echo vbTab & strVal next WScript.Echo vbCrlf & "systemMustContain:" for each strVal in objClass.Get("systemMustContain") ...

Get Active Directory Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.