procedure LookupUPNAndAltSecID(
   flags: DWORD,
   IncludingAltSecID: boolean,
   name: unicodestring): set of DSName

Informative summary of behavior: Returns DSNames of objects, with the given value as a value of userPrincipalName, altSecurityIdentities, or sAMAccountName.

 rt, rt1, rt2: set of DSName
 /* Try lookup by userPrincipalName and altSecurityIdentities
  * or by only userPrincipalName depending on what is
  * requested */
 if IncludingAltSecID then
   rt1 := LookupAttr(flags, userPrincipalName, name)
   rt2 := LookupAttr(flags, altSecurityIdentities, name)
   rt := rt1 + rt2
   rt := LookupAttr(flags, userPrincipalName, name)
 if rt ≠ null then
   return rt
 /* Finally, attempt to parse the name as simpleName@domain and
  * search for
  * sAMAccountName=simpleName. */
 name := UserNameFromUPN(name)
 if name ≠ null then
   rt := LookupAttr(flags, sAMAccountName, name)
 return rt