def dnResolver(self, identity, objtype=None):
        """
        Return the DN for the object based on the parameters identity
        Args:
            identity: sAMAccountName, DN, GUID or SID of the user
            objtype: None is default or GPO
        """

        async def asyncDnResolver(identity, objtype=None):
            if "dc=" in identity.lower():
                # identity is a DN, return as is
                # We do not try to validate it because it could be from another trusted domain
                return identity

            if "s-1-" in identity.lower():
                # We assume identity is an SID
                ldap_filter = f"(objectSid={identity})"
            elif "{" in identity:
                if objtype == "GPO":
                    ldap_filter = (
                        f"(&(objectClass=groupPolicyContainer)(name={identity}))"
                    )
                else:
                    # We assume identity is a GUID
                    ldap_filter = f"(objectGUID={identity})"
            else:
                # By default, we assume identity is a sam account name
                ldap_filter = f"(sAMAccountName={identity})"

            dn = ""
            entries = self.pagedsearch(
                ldap_filter, ["distinguishedName"], tree=self.domainNC
            )
            async for entry, err in entries:
                if err:
                    raise err
                if dn:
                    raise TooManyResultsError(self.domainNC, ldap_filter, entries)
                dn = entry["attributes"]["distinguishedName"]

            if not dn:
                raise NoResultError(self.domainNC, ldap_filter)

            return dn

        return asyncio.run_coroutine_threadsafe(
            asyncDnResolver(identity, objtype), self.loop
        ).result()

        Return the DN for the object based on the parameters identity
        Args:
            identity: sAMAccountName, DN, GUID or SID of the user
            objtype: None is default or GPO
        
bloodyAD/network/ldap.py