NTSTATUS
RtlpLengthInheritedAce(
  IN  PACE_HEADER Ace,
  IN  BOOLEAN IsDirectoryObject,
  IN  PSID ClientOwnerSid,
  IN  PSID ClientGroupSid,
  IN  PSID ServerOwnerSid OPTIONAL,
  IN  PSID ServerGroupSid OPTIONAL,
  IN  PGENERIC_MAPPING GenericMapping,
  IN  PULONG NewAceLength
  );

Routine Description:

    This is a private routine that calculates the number of bytes needed
    to allow for the inheritance of the specified ACE.  If the ACE is not
    inheritable, or its AccessMask ends up with no accesses, then the
    size may be returned as zero.

Arguments:

    Ace - Supplies the ace being checked

    IsDirectoryObject - Specifies if the new ace is for a directory

    ClientOwnerSid - Pointer to Sid to be assigned as the new owner.

    ClientGroupSid - Points to SID to be assigned as the new primary group.

    ServerOwnerSid - Provides the SID of a server to substitute into
        compound ACEs (if any that require editing are encountered).
        If this parameter is not provided, the SID passed for ClientOwnerSid
        will be used.

    ServerGroupSid - Provides the SID of a client to substitute into
        compound ACEs (if any that require editing are encountered).
        If this parameter is not provided, the SID passed for ClientGroupSid
        will be used.

    GenericMapping - Specifies the generic mapping to use.

    NewAceLength - Receives the length (number of bytes) needed to allow for
        the inheritance of the specified ACE.  This might be zero.

Return Value:

    STATUS_SUCCESS - The length needed has been calculated.

    STATUS_BAD_INHERITANCE_ACL - Indicates inheritance of the ace would
        result in an invalid ACL structure.  For example, an SID substitution
        for a known ACE type which has a CreatorOwner SID might exceed the
        length limits of an ACE.

    STATUS_INVALID_PARAMETER - An optional parameter was required, but not
        provided.