def find_computer()

in ad-joining/register-computer/ad/domain.py [0:0]


    def find_computer(self, search_base_dn):
        # Search either for the specific group or in the base DN (but not its descendants)
        if search_base_dn.startswith("CN="):
            search_scope = ldap3.BASE
        else:
            search_scope = ldap3.LEVEL

        try:
            return self.__find( 
                converter=self.__to_computer, 
                search_filter="(objectClass=computer)",
                search_base_dn=search_base_dn, 
                search_scope=search_scope, 
                attributes=[
                    "distinguishedName",
                    "name",
                    ActiveDirectoryConnection.LDAP_ATTRIBUTE_PROJECT_ID,
                    ActiveDirectoryConnection.LDAP_ATTRIBUTE_ZONE,
                    ActiveDirectoryConnection.LDAP_ATTRIBUTE_INSTANCE_NAME,
                    "dNSHostName"
                ]
            )
        except ldap3.core.exceptions.LDAPNoSuchObjectResult as e:
            raise NoSuchObjectException(e)