Documentation/Installation/RADIUS: rlm-ldap_getdn.patch

File rlm-ldap_getdn.patch, 1.5 kB (added by alex, 9 months ago)

patch permits you to just get the DN of an object in FreeRADIUS

  • freeradius-1.1.3src/modules/rlm_ldap/rlm_ldap.c

    old new  
    10971097        LDAPMessage *result = NULL; 
    10981098        LDAPMessage *msg = NULL; 
    10991099        char **vals; 
     1100        char *str; 
    11001101        int conn_id = -1; 
    11011102        LDAP_CONN *conn; 
    11021103 
     
    11331134                ldap_free_urldesc(ldap_url); 
    11341135                return 0; 
    11351136        } 
     1137        if ( strcmp(ldap_url->lud_attrs[0], "dn") == 0 ) { 
     1138          strncpy(ldap_url->lud_attrs[0],"1.1\0",4); 
     1139        } 
    11361140        if ((res = perform_search(inst, conn, ldap_url->lud_dn, ldap_url->lud_scope, ldap_url->lud_filter, ldap_url->lud_attrs, &result)) != RLM_MODULE_OK){ 
    11371141                if (res == RLM_MODULE_NOTFOUND){ 
    11381142                        DEBUG("rlm_ldap: Search returned not found"); 
     
    11521156                ldap_release_conn(conn_id,inst->conns); 
    11531157                return 0; 
    11541158        } 
    1155         if ((vals = ldap_get_values(conn->ld, msg, ldap_url->lud_attrs[0])) != NULL) { 
     1159        if ( strcmp(ldap_url->lud_attrs[0], "1.1") == 0 ) { 
     1160                str = ldap_get_dn(conn->ld, msg); 
     1161                ret = strlen(str); 
     1162                if (ret > freespace){ 
     1163                        DEBUG("rlm_ldap: Insufficient string space"); 
     1164                        ldap_free_urldesc(ldap_url); 
     1165                        ldap_memfree(str); 
     1166                        ldap_msgfree(result); 
     1167                        ldap_release_conn(conn_id,inst->conns); 
     1168                        return 0; 
     1169                } 
     1170                DEBUG("rlm_ldap: Adding dn as attribute, value: %s",str); 
     1171                strncpy(out,str,ret); 
     1172                ldap_memfree(str); 
     1173        } 
     1174        else if ((vals = ldap_get_values(conn->ld, msg, ldap_url->lud_attrs[0])) != NULL) { 
    11561175                ret = strlen(vals[0]); 
    11571176                if (ret > freespace){ 
    11581177                        DEBUG("rlm_ldap: Insufficient string space");