+ /* Does this candidate actually satisfy the search scope?
+ *
+ * Note that we don't lock access to the bei_parent pointer.
+ * Since only leaf nodes can be deleted, the parent of any
+ * node will always be a valid node. Also since we have
+ * a Read lock on the data, it cannot be renamed out of the
+ * scope while we are looking at it, and unless we're using
+ * BDB_HIER, its parents cannot be moved either.
+ */
+ switch( op->ors_scope ) {
+ case LDAP_SCOPE_BASE:
+ /* This is always true, yes? */
+ if ( id == base.e_id )
+ scopeok = 1;
+ break;
+ case LDAP_SCOPE_ONELEVEL:
+ if ( ei->bei_parent->bei_id == base.e_id )
+ scopeok = 1;
+ break;
+ case LDAP_SCOPE_SUBTREE:
+ { EntryInfo *tmp;
+ for ( tmp = BEI(e); tmp->bei_parent;
+ tmp = tmp->bei_parent ) {
+ if ( tmp->bei_id == base.e_id ) {
+ scopeok = 1;
+ break;
+ }
+ } }
+ break;
+ }
+