7 Appendix C: Active Directory Scanning Algorithm

The primary function of the Address Book Server is to scan Active Directory for users, contacts, and groups and determine which objects to include in the Address Book Server files and, for each object included, which attributes to include. The following pseudo-code example illustrates how a scanning process works.

 // This is a representation of the ABF_ATTRIBUTES Structure
 //
 extern Dictionary<String, ABF_ATTRIBUTE> attributeTable;
 adObjects = select from Active Directory where ObjectType == Group Or
                                  ObjectType == User Or
                                  ObjectType == Contact
 foreach (adObject in adObjects)
 {
   hideObject = false;
   includeAttributeSeen = false;
   requiredAttributeSeen = false;
   foreach (adAttribute in adObject.Atttributes)
   {
     if (attributeTable [adAttribute.Name].Flags &
           ABF_ATTRIBUTE_FLAGS_EXCLUDE)
     {
       // Exclude attribute seen, so bail now.
       // Not going to take this adObject.
       hideObject = true;
       break;
     }
     if (attributeTable [adAttribute.Name].Flags &
           ABF_ATTRIBUTE_FLAGS_INCLUDE)
     {
       // Include attribute seen, so assume
       // this adObject will be taken
       includeAttributeSeen = true;
     }
     if (attributeTable [adAttribute.Name].Flags &
           ABF_ATTRIBUTE_FLAGS_REQUIRED)
     {
       // Required attribute seen, so assume
       // this adObject will not be taken
       requiredAttributeSeen = true;
     }
   }
  
   If (attributeTable.HasRequiredAttributes && !requiredAttributeSeen)
   {
       // There was at least one ABF_ATTRIBUTE_FLAGS_REQUIRED attribute
       // defined in the attributeTable, but no required
       // attributes on this adObject, so hide it.
       hideObject = true;
   }
   else
   If (attributeTable.HasIncludeAttributes && !includeAttributeSeen)
   {
       // There was at least one ABF_ATTRIBUTE_FLAGS_INCLUDE attribute
       // defined in the attributeTable, but no include
       // attributes on this adObject, so hide it.
       hideObject = true;
   }
  
   if (hideObject)
   {
       // Not interested in this adObject so on to the next one.
       continue;
   }
  
   //
   // This adObject should be in address book files so process it
   //
 }