def get_max_id(self, object_type, role):
        """Get the highest used ID."""
        if object_type == 'user':
            objectclass = 'posixAccount'
            ldap_attr = 'uidNumber'
        elif object_type == 'group':  # pragma: no cover
            objectclass = 'posixGroup'
            ldap_attr = 'gidNumber'
        else:
            raise ldap_tools.exceptions.InvalidResult('Unknown object type')

        minID, maxID = Client.__set_id_boundary(role)

        filter = [
            "(objectclass={})".format(objectclass), "({}>={})".format(ldap_attr, minID)
        ]

        if maxID is not None:
            filter.append("({}<={})".format(ldap_attr, maxID))

        id_list = self.search(filter, [ldap_attr])

        if id_list == []:
            id = minID
        else:
            if object_type == 'user':
                id = max([i.uidNumber.value for i in id_list]) + 1
            elif object_type == 'group':
                id = max([i.gidNumber.value for i in id_list]) + 1
            else:
                raise ldap_tools.exceptions.InvalidResult('Unknown object')

        return id