Eric, with my rewrite, you can call RtlEqualPrefixSid instead of using LsapIsPrefixSid. The code should be the same
LsapIsPrefixSid