5.6 AddSubRef

 procedure AddSubRef(childNC: DSName): DWORD

Informative summary of behavior: This procedure creates a sub-ref object to the NC named by childNC, if appropriate.

 parentNC, parentObj: DSName
 srAtt: ENTINF
 err: DWORD
  
 err:= 0
  
 /* Find the parent NC */
 parentNC := GetObjectNC(ChildNC)
  
 /* If the parent NC is not instantiated locally, return */
 if not FullReplicaExists(parentNC) and
    not PartialGCReplicaExists(parentNC) then
   return err
 endif
 /* If child does not exist, create it */
  
 if !ObjExists(childNC) then
   /* Create a subordinate reference object */
   ENTINF_SetValue(srAtt, instanceType,
     {IT_NC_HEAD | IT_UNINSTANT | IT_NC_ABOVE}, dc.prefixTable)
   ENTINF_SetValue(srAtt, objectClass, top,prefixTable)
   ENTINF_SetValue(srAtt, objectCategory,SchemaObj(top), dc.prefixTable)
   ENTINF_SetValue(srAtt, distinguishedName, childNC,prefixTable)
   err := PerformAddOperation(srAtt,childNC, dc.prefixTable, TRUE)
   if(err != 0)
     return err
   endif
 else
   if (childNC!isDeleted)
      /*The cross-ref is being undeleted. Undelete the sub-ref object also.*/
      UndeleteObject(childNC)
   endif
 endif
  
 /* Ensure that the subordinate reference object is listed in the parent's
    subRefs  attribute*/
 if (not childNC in parentNC!subRefs) then
    parentNC!subRefs := parentNC!subRefs + {childNC}
 endif
 return err