Skip to content

Commit 6a14b4a

Browse files
committed
Add extension parsing to LDAP map URIs
1 parent 0c94691 commit 6a14b4a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/modules/rlm_ldap/rlm_ldap.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ typedef struct {
379379
LDAPURLDesc *ldap_url;
380380
fr_ldap_query_t *query;
381381
fr_ldap_map_exp_t expanded;
382+
LDAPControl *serverctrls[LDAP_MAX_CONTROLS];
382383
} ldap_map_ctx_t;
383384

384385
typedef enum {
@@ -1310,8 +1311,13 @@ static unlang_action_t mod_map_resume(rlm_rcode_t *p_result, UNUSED int *priorit
13101311
*/
13111312
static int map_ctx_free(ldap_map_ctx_t *map_ctx)
13121313
{
1314+
int i = 0;
13131315
talloc_free(map_ctx->expanded.ctx);
13141316
ldap_free_urldesc(map_ctx->ldap_url);
1317+
while ((i < LDAP_MAX_CONTROLS) && map_ctx->serverctrls[i]) {
1318+
ldap_control_free(map_ctx->serverctrls[i]);
1319+
i++;
1320+
}
13151321
return (0);
13161322
}
13171323

@@ -1382,6 +1388,14 @@ static unlang_action_t mod_map_proc(rlm_rcode_t *p_result, void const *mod_inst,
13821388
}
13831389
ldap_url = map_ctx->ldap_url;
13841390

1391+
if (ldap_url->lud_exts) {
1392+
if (fr_ldap_parse_url_extensions(map_ctx->serverctrls, NUM_ELEMENTS(map_ctx->serverctrls),
1393+
ldap_url->lud_exts) < 0) {
1394+
RPERROR("Parsing URL extensions failed");
1395+
goto fail;
1396+
}
1397+
}
1398+
13851399
/*
13861400
* Expand the RHS of the maps to get the name of the attributes.
13871401
*/
@@ -1407,7 +1421,7 @@ static unlang_action_t mod_map_proc(rlm_rcode_t *p_result, void const *mod_inst,
14071421

14081422
return fr_ldap_trunk_search(map_ctx, &map_ctx->query, request, ttrunk, ldap_url->lud_dn,
14091423
ldap_url->lud_scope, ldap_url->lud_filter, map_ctx->expanded.attrs,
1410-
NULL, NULL);
1424+
map_ctx->serverctrls, NULL);
14111425
}
14121426

14131427
/** Perform async lookup of user DN if required for authentication

0 commit comments

Comments
 (0)