Ignore:
Timestamp:
Jun 17, 2009, 2:19:52 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.3 branch to 3.3.5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/lib/smbldap.c

    r221 r274  
    334334}
    335335
     336 char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry,
     337                                          const char *attribute,
     338                                          TALLOC_CTX *mem_ctx)
     339{
     340        char **values;
     341        char *result;
     342        size_t converted_size;
     343        int i, num_values;
     344
     345        if (attribute == NULL) {
     346                return NULL;
     347        }
     348
     349        values = ldap_get_values(ldap_struct, entry, attribute);
     350
     351        if (values == NULL) {
     352                DEBUG(10, ("attribute %s does not exist\n", attribute));
     353                return NULL;
     354        }
     355
     356        if (!pull_utf8_talloc(mem_ctx, &result, values[0], &converted_size)) {
     357                DEBUG(10, ("pull_utf8_talloc failed\n"));
     358                ldap_value_free(values);
     359                return NULL;
     360        }
     361
     362        num_values = ldap_count_values(values);
     363
     364        for (i=1; i<num_values; i++) {
     365                char *tmp;
     366
     367                if (!pull_utf8_talloc(mem_ctx, &tmp, values[i],
     368                                      &converted_size)) {
     369                        DEBUG(10, ("pull_utf8_talloc failed\n"));
     370                        TALLOC_FREE(result);
     371                        ldap_value_free(values);
     372                        return NULL;
     373                }
     374
     375                if (StrCaseCmp(tmp, result) < 0) {
     376                        TALLOC_FREE(result);
     377                        result = tmp;
     378                } else {
     379                        TALLOC_FREE(tmp);
     380                }
     381        }
     382
     383        ldap_value_free(values);
     384
     385#ifdef DEBUG_PASSWORDS
     386        DEBUG (100, ("smbldap_get_single_attribute: [%s] = [%s]\n",
     387                     attribute, result));
     388#endif
     389        return result;
     390}
     391
     392 char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry,
     393                                          const char *attribute,
     394                                          TALLOC_CTX *mem_ctx)
     395{
     396        char **values;
     397        char *result;
     398        size_t converted_size;
     399        int i, num_values;
     400
     401        if (attribute == NULL) {
     402                return NULL;
     403        }
     404
     405        values = ldap_get_values(ldap_struct, entry, attribute);
     406
     407        if (values == NULL) {
     408                DEBUG(10, ("attribute %s does not exist\n", attribute));
     409                return NULL;
     410        }
     411
     412        if (!pull_utf8_talloc(mem_ctx, &result, values[0], &converted_size)) {
     413                DEBUG(10, ("pull_utf8_talloc failed\n"));
     414                ldap_value_free(values);
     415                return NULL;
     416        }
     417
     418        num_values = ldap_count_values(values);
     419
     420        for (i=1; i<num_values; i++) {
     421                char *tmp;
     422
     423                if (!pull_utf8_talloc(mem_ctx, &tmp, values[i],
     424                                      &converted_size)) {
     425                        DEBUG(10, ("pull_utf8_talloc failed\n"));
     426                        TALLOC_FREE(result);
     427                        ldap_value_free(values);
     428                        return NULL;
     429                }
     430
     431                if (StrCaseCmp(tmp, result) < 0) {
     432                        TALLOC_FREE(result);
     433                        result = tmp;
     434                } else {
     435                        TALLOC_FREE(tmp);
     436                }
     437        }
     438
     439        ldap_value_free(values);
     440
     441#ifdef DEBUG_PASSWORDS
     442        DEBUG (100, ("smbldap_get_single_attribute: [%s] = [%s]\n",
     443                     attribute, result));
     444#endif
     445        return result;
     446}
     447
    336448 static int ldapmsg_destructor(LDAPMessage **result) {
    337449        ldap_msgfree(*result);
Note: See TracChangeset for help on using the changeset viewer.