Prior to Windows Server 2008, the objectClass attribute is not indexed. This is because it has multiple values and is highly non-unique; that is, every instance of the objectClass attribute includes the top class. This means an index would be very large and ineffective. To locate objects of a given class, use the objectCategory attribute, which is single-valued and indexed.
The objectCategory attribute is a DN attribute. A typical value for an object in Active Directory might be "cn=person,cn=Schema,cn=Configuration,dc=MyDomain,dc=com". You coulld use a filter clause similar to the following:
(objectCategory=cn=person,cn=Schema,cn=Configuration,dc=MyDomain,dc=com)
However, Active Directory allows you to instead use the following shortcut:
(objectCategory=person)
The cobinations of the ObjectClass vs ObjectCategory are a little complex and not intuitive, the following table documents the result of various combinations of clauses specifying values for objectCategory and objectClass:
TABLLE | HEADINGS | |
---|---|---|
objectCategory | objectClass | Result |
person | user | user objects |
person | user and contact objects | |
person | contact | contact objects |
user | user and computer objects | |
computer | computer objects | |
user | user and contact objects | |
contact | contact objects | |
computer | computer objects | |
person | user, computer, and contact objects | |
contact | user and contact objects | |
group | group objects | |
group | group objects | |
person | organizationalPerson | user and contact objects |
organizationalPerson | user, computer, and contact objects | |
organizationalPerson | user and contact objects |
Use the filter that makes your intent most clear. Also, if you have a choice between using objectCategory and objectClass, usually is recommended that you use objectCategory. That is because objectCategory is both single valued and indexed, while objectClass is multi-valued and not indexed (except on Windows Server 2008 and above). A query using a filter with objectCategory will be more efficient than a similar filter with objectClass. Windows Server 2008 domain controllers (and above) have a special behavior that indexes the objectClass attribute.
You can take advantage of this if all of your domain controllers are Windows Server 2008, or if you specify a Windows Server 2008 domain controller in your query.