'Returns LDAP URL depending on class attributes set.'

def unparse(self):

    if (self.attrs is None):
        attrs_str = ''
    else:
        attrs_str = ','.join(self.attrs)
    scope_str = SEARCH_SCOPE_STR[self.scope]
    if (self.filterstr is None):
        filterstr = ''
    else:
        filterstr = ldapUrlEscape(self.filterstr)
    dn = ldapUrlEscape(self.dn)
    if (self.urlscheme == 'ldapi'):
        hostport = ldapUrlEscape(self.hostport)
    else:
        hostport = self.hostport
    ldap_url = ('%s://%s/%s?%s?%s?%s' % (self.urlscheme, hostport, dn, attrs_str, scope_str, filterstr))
    if self.extensions:
        ldap_url = ((ldap_url + '?') + self.extensions.unparse())
    return ldap_url
