26 #include <freeradius-devel/rad_assert.h>
60 if (!value)
return -1;
62 values[(*idx)++] = value;
77 struct berval **values;
80 values = ldap_get_values_len(this->conn->handle, this->entry,
cf_pair_value(cp));
87 ldap_value_free_len(values);
108 char const **attrs = NULL;
111 int count = 0, idx = 0;
113 LDAPMessage *result = NULL;
119 LDAP_DBG(
"Loading dynamic clients");
129 attrs = talloc_array(inst,
char const *, count);
164 LDAP_INFO(
"No clients were found in the directory");
174 entry = ldap_first_entry(conn->
handle, result);
178 ldap_get_option(conn->
handle, LDAP_OPT_RESULT_CODE, &ldap_errno);
179 LDAP_ERR(
"Failed retrieving entry: %s", ldap_err2string(ldap_errno));
191 struct berval **values;
193 id = dn = ldap_get_dn(conn->
handle, entry);
197 ldap_get_option(conn->
handle, LDAP_OPT_RESULT_CODE, &ldap_errno);
198 LDAP_ERR(
"Retrieving object DN from entry failed: %s", ldap_err2string(ldap_errno));
208 ldap_value_free_len(values);
239 talloc_steal(c, client);
242 LDAP_ERR(
"Failed to add client \"%s\", possible duplicate?", dn);
248 LDAP_DBG(
"Client \"%s\" added", dn);
252 }
while ((entry = ldap_next_entry(conn->
handle, entry)));
256 if (dn) ldap_memfree(dn);
257 if (result) ldap_msgfree(result);
Tracks the state of a libldap connection handle.
Operation was successfull.
RADCLIENT * client_afrom_cs(TALLOC_CTX *ctx, CONF_SECTION *cs, bool in_server, bool with_coa)
Allocate a new client from a config section.
char const * clientobj_base_dn
DN to search for clients under.
char const * admin_identity
Identity we bind as when we need to query the LDAP directory.
char const * admin_password
Password used in administrative bind.
bool client_add(RADCLIENT_LIST *clients, RADCLIENT *client)
Add a client to a RADCLIENT_LIST.
static int _get_client_value(char **out, CONF_PAIR const *cp, void *data)
ldap_rcode_t
Codes returned by rlm_ldap internal functions.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *item)
Cast a CONF_ITEM to a CONF_SECTION.
size_t rlm_ldap_normalise_dn(char *out, char const *in)
Normalise escape sequences in a DN.
CONF_PAIR * cf_pair_find(CONF_SECTION const *, char const *name)
char const * cf_pair_value(CONF_PAIR const *pair)
struct ldap_client_data ldap_client_data_t
#define LDAP_DBG(fmt,...)
#define LDAP_INFO(fmt,...)
CONF_SECTION * cf_section_dup(CONF_SECTION *parent, CONF_SECTION const *cs, char const *name1, char const *name2, bool copy_meta)
Duplicate a configuration section.
bool cf_item_is_section(CONF_ITEM const *item)
#define LDAP_ERR(fmt,...)
bool rebound
Whether the connection has been rebound to something other than the admin user.
char const * clientobj_filter
Filter to retrieve only client objects.
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *item)
Cast a CONF_ITEM to a CONF_PAIR.
ldap_rcode_t rlm_ldap_bind(rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, char const *dn, char const *password, ldap_sasl *sasl, bool retry, LDAPControl **serverctrls, LDAPControl **clientctrls)
Bind to the LDAP directory as a user.
int cf_pair_count(CONF_SECTION const *cs)
Count the number of conf pairs beneath a section.
ldap_rcode_t rlm_ldap_search(LDAPMessage **result, rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, char const *dn, int scope, char const *filter, char const *const *attrs, LDAPControl **serverctrls, LDAPControl **clientctrls)
Search for something in the LDAP directory.
Configuration AVP similar to a VALUE_PAIR.
static int mod_conn_get(void **handle, UNUSED rlm_cache_config_t const *config, void *driver_inst, UNUSED REQUEST *request)
Get a memcached handle.
rlm_ldap_t * inst
rlm_ldap configuration.
Describes a host allowed to send packets to the server.
int clientobj_scope
Search scope.
int rlm_ldap_client_load(rlm_ldap_t const *inst, CONF_SECTION *tmpl, CONF_SECTION *map)
Load clients from LDAP on server start.
static void mod_conn_release(UNUSED rlm_cache_config_t const *config, void *driver_inst, UNUSED REQUEST *request, rlm_cache_handle_t *handle)
Release a memcached handle.
CONF_SECTION * cf_section_alloc(CONF_SECTION *parent, char const *name1, char const *name2)
Allocate a CONF_SECTION.
CONF_ITEM * cf_item_find_next(CONF_SECTION const *section, CONF_ITEM const *item)
Return the next item after a CONF_ITEM.
char * rlm_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced string.
static int rlm_ldap_client_get_attrs(char const **values, int *idx, CONF_SECTION const *cs)
Iterate over pairs in mapping section recording their values in an array.
ldap_sasl admin_sasl
SASL parameters used when binding as the admin.
LDAP authorization and authentication module headers.
int client_map_section(CONF_SECTION *out, CONF_SECTION const *map, client_value_cb_t func, void *data)
Create a client CONF_SECTION using a mapping section to map values from a result set to client attrib...
LDAP * handle
libldap handle.
void client_free(RADCLIENT *client)