4.1.10.5.3 GetReplScope

 procedure GetReplScope(
   msgIn: DRS_MSG_GETCHGREQ_V10,
   searchFilter: LDAPString): set of DSName 

Informative summary of behavior: The GetReplScope procedure returns the set of objects considered for normal replication or for an LDAP Search request with LDAP_SERVER_DIRSYNC_OID control: the objects in the requested NC replica (msgIn.pNC^) or a subset thereof, as indicated by the request flags (msgIn.ulFlags) and the search filter (searchFilter). If the DRS_ASYNC_REP request flag is specified, the subset includes only the NC root. If the DRS_CRITICAL_ONLY request flag is specified, the subset includes only those objects with isCriticalSystemObject = true and their ancestors.

 scope: set of DSName
 ncRoot: DSName
 anc: DSName
  
 ncRoot := GetObjectNC(msgIn.pNC^)
  
 if DRS_ASYNC_REP in msgIn.ulFlags then
   if (ObjectMatchesSearchFilter(ncRoot, searchFilter) = true) then
      scope := {ncRoot}
   endif
 else if DRS_CRITICAL_ONLY in msgIn.ulFlags then
   scope := select all o from subtree-ts-included ncRoot where
     o!isCriticalSystemObject = true
   foreach o in scope
     foreach anc in Ancestors of o
       if not anc in scope then
         if (ObjectMatchesSearchFilter(anc, searchFilter) = true) then
            scope := scope + {anc}
         endif
       endif
     endif
   endfor
 else
   scope := select all o from subtree-ts-included ncRoot where true 
   foreach o in ncRoot!subRefs
     if (ObjectMatchesSearchFilter(o, searchFilter) = true) then
        scope := scope + {o}
     endif
   endfor
 endif
  
 return scope