42 LDAPControl *clientctrls_out[],
43 size_t serverctrls_len,
44 size_t clientctrls_len,
46 LDAPControl *serverctrls_in[],
47 LDAPControl *clientctrls_in[])
49 size_t i, num_serverctrls = 0, num_clientctrls = 0;
53 serverctrls_out[num_serverctrls++] = serverctrls_in[i];
59 clientctrls_out[num_clientctrls++] = clientctrls_in[i];
63 for (i = 0; (i < (size_t)conn->
serverctrls_cnt) && (num_serverctrls < serverctrls_len); i++) {
67 for (i = 0; (i < (size_t)conn->
clientctrls_cnt) && (num_clientctrls < clientctrls_len); i++) {
71 serverctrls_out[num_serverctrls] = NULL;
72 clientctrls_out[num_clientctrls] = NULL;
146 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
167 static char username_oid[] = LDAP_CONTROL_X_SESSION_TRACKING_USERNAME;
168 static char acctsessionid_oid[] = LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID;
169 static char acctmultisessionid_oid[] = LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID;
173 char ipaddress[INET6_ADDRSTRLEN];
174 char *username = NULL;
175 char *acctsessionid = NULL;
176 char *acctmultisessionid = NULL;
179 LDAPControl *username_control = NULL;
180 LDAPControl *acctsessionid_control = NULL;
181 LDAPControl *acctmultisessionid_control = NULL;
182 struct berval tracking_id;
193 case PW_NAS_IP_ADDRESS:
194 case PW_NAS_IPV6_ADDRESS:
199 memcpy(&username, &vp->vp_strvalue,
sizeof(username));
202 case PW_ACCT_SESSION_ID:
203 memcpy(&acctsessionid, &vp->vp_strvalue,
sizeof(acctsessionid));
206 case PW_ACCT_MULTI_SESSION_ID:
207 memcpy(&acctmultisessionid, &vp->vp_strvalue,
sizeof(acctmultisessionid));
213 tracking_id.bv_val = username;
214 tracking_id.bv_len = talloc_array_length(username) - 1;
216 ret = ldap_create_session_tracking_control(conn->
handle, ipaddress,
221 if (ret != LDAP_SUCCESS) {
222 REDEBUG(
"Failed creating username session tracking control: %s", ldap_err2string(ret));
224 if (username_control) ldap_control_free(username_control);
225 if (acctsessionid_control) ldap_control_free(acctsessionid_control);
226 if (acctmultisessionid_control) ldap_control_free(acctmultisessionid_control);
232 tracking_id.bv_val = acctsessionid;
233 tracking_id.bv_len = talloc_array_length(acctsessionid) - 1;
235 ret = ldap_create_session_tracking_control(conn->
handle, ipaddress,
239 &acctsessionid_control);
240 if (ret != LDAP_SUCCESS) {
241 REDEBUG(
"Failed creating acctsessionid session tracking control: %s", ldap_err2string(ret));
246 if (acctmultisessionid) {
247 tracking_id.bv_val = acctmultisessionid;
248 tracking_id.bv_len = talloc_array_length(acctmultisessionid) - 1;
250 ret = ldap_create_session_tracking_control(conn->
handle, ipaddress,
252 acctmultisessionid_oid,
254 &acctmultisessionid_control);
255 if (ret != LDAP_SUCCESS) {
256 REDEBUG(
"Failed creating acctmultisessionid session tracking control: %s",
257 ldap_err2string(ret));
263 REDEBUG(
"Insufficient space to add session tracking controls");
Tracks the state of a libldap connection handle.
rlm_ldap_control_t serverctrls[LDAP_MAX_CONTROLS+1]
Server controls to use for all operations with this handle.
Main server configuration.
int rlm_ldap_control_add_server(ldap_handle_t *conn, LDAPControl *ctrl, bool freeit)
Add a serverctrl to a connection handle.
int rlm_ldap_control_add_session_tracking(ldap_handle_t *conn, REQUEST *request)
LDAPControl * control
LDAP control.
void rlm_ldap_control_merge(LDAPControl *serverctrls_out[], LDAPControl *clientctrls_out[], size_t serverctrls_len, size_t clientctrls_len, ldap_handle_t *conn, LDAPControl *serverctrls_in[], LDAPControl *clientctrls_in[])
Merge connection and call specific client and server controls.
rlm_ldap_control_t clientctrls[LDAP_MAX_CONTROLS+1]
Client controls to use for all operations with this handle.
void size_t fr_pair_value_snprint(char *out, size_t outlen, VALUE_PAIR const *vp, char quote)
Print the value of an attribute to a string.
VALUE_PAIR * vps
Result of decoding the packet into VALUE_PAIRs.
VALUE_PAIR * fr_cursor_init(vp_cursor_t *cursor, VALUE_PAIR *const *node)
Setup a cursor to iterate over attribute pairs.
static char const * hostname(char *buf, size_t buflen, uint32_t ipaddr)
char const * name
Name of the daemon, usually 'radiusd'.
int serverctrls_cnt
Number of server controls associated with the handle.
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
unsigned int attr
Attribute number.
unsigned int vendor
Vendor that defines this attribute.
Stores an attribute, a value and various bits of other data.
int rlm_ldap_control_add_client(ldap_handle_t *conn, LDAPControl *ctrl, bool freeit)
Add a clientctrl to a connection handle.
VALUE_PAIR * fr_cursor_next(vp_cursor_t *cursor)
Advanced the cursor to the next VALUE_PAIR.
RADIUS_PACKET * packet
Incoming request.
int clientctrls_cnt
Number of client controls associated with the handle.
bool freeit
Whether the control should be freed after we've finished using it.
fr_dict_attr_t const * da
Dictionary attribute defines the attribute.
#define LDAP_MAX_CONTROLS
Maximum number of client/server controls.
LDAP authorization and authentication module headers.
void rlm_ldap_control_clear(ldap_handle_t *conn)
Clear and free any controls associated with a connection.
LDAP * handle
libldap handle.