The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
base.h
Go to the documentation of this file.
1#pragma once
2/**
3 * $Id: c6a6a4d327b79f162b7ae0ae85e05021f1a91ee6 $
4 * @file lib/ldap/base.h
5 * @brief Common utility functions for interacting with LDAP directories
6 *
7 * @author Arran Cudbard-Bell (a.cudbardb@freeradius.org)
8 *
9 * @copyright 2017 The FreeRADIUS Server Project.
10 * @copyright 2017 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
11 */
12#include <freeradius-devel/server/base.h>
13#include <freeradius-devel/server/connection.h>
14#include <freeradius-devel/server/global_lib.h>
15#include <freeradius-devel/server/map.h>
16#include <freeradius-devel/server/trunk.h>
17#include <freeradius-devel/unlang/function.h>
18#include <freeradius-devel/util/dlist.h>
19
20#define LDAP_DEPRECATED 0 /* Quiet warnings about LDAP_DEPRECATED not being defined */
21
22#include <lber.h>
23#include <ldap.h>
24#include "config.h"
25
26extern LDAP *ldap_global_handle;
27
28/*
29 * Framework on OSX doesn't export the symbols but leaves
30 * the macro defined *sigh*.
31 */
32#ifndef HAVE_LDAP_CREATE_SESSION_TRACKING_CONTROL
33# undef LDAP_CONTROL_X_SESSION_TRACKING
34#endif
35
36/*
37 * There's a typo in libldap's ldap.h which was fixed by
38 * Howard Chu in 19aeb1cd. This typo had the function defined
39 * as ldap_create_session_tracking_control but declared as
40 * ldap_create_session_tracking.
41 *
42 * We fix this, by adding the correct declaration here.
43 */
44#ifdef LDAP_CONTROL_X_SESSION_TRACKING
45# if !defined(HAVE_DECL_LDAP_CREATE_SESSION_TRACKING_CONTROL) || (HAVE_DECL_LDAP_CREATE_SESSION_TRACKING_CONTROL == 0)
46LDAP_F( int )
47ldap_create_session_tracking_control LDAP_P((
48 LDAP *ld,
49 char *sessionSourceIp,
50 char *sessionSourceName,
51 char *formatOID,
52 struct berval *sessionTrackingIdentifier,
53 LDAPControl **ctrlp ));
54# endif
55#endif
56
57/*
58 * Because the LTB people define LDAP_VENDOR_VERSION_PATCH
59 * as X, which precludes its use in printf statements *sigh*
60 *
61 * Identifiers that are not macros, all evaluate to 0,
62 * which is why this works.
63 */
64#define X 0
65#if !defined(LDAP_VENDOR_VERSION_PATCH) || LDAP_VENDOR_VERSION_PATCH == 0
66# undef LDAP_VENDOR_VERSION_PATCH
67# define LDAP_VENDOR_VERSION_PATCH 0
68#endif
69#undef X
70
71/*
72 * For compatibility with other LDAP libraries
73 */
74#if !defined(LDAP_SCOPE_BASE) && defined(LDAP_SCOPE_BASEOBJECT)
75# define LDAP_SCOPE_BASE LDAP_SCOPE_BASEOBJECT
76#endif
77
78#if !defined(LDAP_SCOPE_ONE) && defined(LDAP_SCOPE_ONELEVEL)
79# define LDAP_SCOPE_ONE LDAP_SCOPE_ONELEVEL
80#endif
81
82#if !defined(LDAP_SCOPE_SUB) && defined(LDAP_SCOPE_SUBTREE)
83# define LDAP_SCOPE_SUB LDAP_SCOPE_SUBTREE
84#endif
85
86#if !defined(LDAP_OPT_RESULT_CODE) && defined(LDAP_OPT_ERROR_NUMBER)
87# define LDAP_OPT_RESULT_CODE LDAP_OPT_ERROR_NUMBER
88#endif
89
90#ifndef LDAP_CONST
91# define LDAP_CONST
92#endif
93
94#define LDAP_MAX_CONTROLS 10 //!< Maximum number of client/server controls.
95 //!< Used to allocate static arrays of control pointers.
96#define LDAP_MAX_ATTRMAP 128 //!< Maximum number of mappings between LDAP and
97 //!< FreeRADIUS attributes.
98#define LDAP_MAP_RESERVED 5 //!< Number of additional items to allocate in expanded
99 //!< attribute name arrays. Currently for enable attribute,
100 //!< group membership attribute, valuepair attribute,
101 //!< profile attribute and profile suspend attribute.
102
103#define LDAP_MAX_CACHEABLE 64 //!< Maximum number of groups we retrieve from the server for
104 //!< a given user which need resolving from name to DN or DN
105 //!< to name. If more than this require resolving, the
106 //!< module returns invalid.
107
108#define LDAP_MAX_GROUP_NAME_LEN 128 //!< Maximum name of a group name.
109#define LDAP_MAX_ATTR_STR_LEN 256 //!< Maximum length of an xlat expanded LDAP attribute.
110#define LDAP_MAX_FILTER_STR_LEN 1024 //!< Maximum length of an xlat expanded filter.
111#define LDAP_MAX_DN_STR_LEN 1024 //!< Maximum length of an xlat expanded DN.
112
113#define LDAP_VIRTUAL_DN_ATTR "dn" //!< 'Virtual' attribute which maps to the DN of the object.
114
115#define LDAP_SERVER_NOTIFICATION_OID "1.2.840.113556.1.4.528" //!< OID of Active Directory control for
116 //!< persistent search.
117#define LDAP_SERVER_SHOW_DELETED_OID "1.2.840.113556.1.4.417" //!< OID of Active Directory control which
118 //!< enables searching for deleted objects.
119#define LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803" //!< OID of bit-wise AND LDAP match rule
120#define LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804" //!< OID of bit-wise OR LDAP match rule
121
122typedef enum {
123 LDAP_EXT_UNSUPPORTED, //!< Unsupported extension.
124 LDAP_EXT_BINDNAME, //!< Specifies the user DN or name for an LDAP bind.
125 LDAP_EXT_BINDPW, //!< Specifies the password for an LDAP bind.
127
128typedef struct {
129 char const *mech; //!< SASL mech(s) to try.
130 char const *proxy; //!< Identity to proxy.
131 char const *realm; //!< Kerberos realm.
133
134typedef struct {
135 LDAPControl *control; //!< LDAP control.
136 bool freeit; //!< Whether the control should be freed after
137 //!< we've finished using it.
139
140typedef enum {
141 FR_LDAP_DIRECTORY_UNKNOWN = 0, //!< We can't determine the directory server.
142
143 FR_LDAP_DIRECTORY_ACTIVE_DIRECTORY, //!< Directory server is Active Directory.
144 FR_LDAP_DIRECTORY_EDIRECTORY, //!< Directory server is eDir.
145 FR_LDAP_DIRECTORY_IBM, //!< Directory server is IBM.
146 FR_LDAP_DIRECTORY_NETSCAPE, //!< Directory server is Netscape.
147 FR_LDAP_DIRECTORY_OPENLDAP, //!< Directory server is OpenLDAP.
148 FR_LDAP_DIRECTORY_ORACLE_INTERNET_DIRECTORY, //!< Directory server is Oracle Internet Directory.
149 FR_LDAP_DIRECTORY_ORACLE_UNIFIED_DIRECTORY, //!< Directory server is Oracle Unified Directory.
150 FR_LDAP_DIRECTORY_ORACLE_VIRTUAL_DIRECTORY, //!< Directory server is Oracle Virtual Directory.
151 FR_LDAP_DIRECTORY_SUN_ONE_DIRECTORY, //!< Directory server is Sun One Directory.
152 FR_LDAP_DIRECTORY_SIEMENS_AG, //!< Directory server is Siemens AG.
153 FR_LDAP_DIRECTORY_UNBOUND_ID, //!< Directory server is Unbound ID
154 FR_LDAP_DIRECTORY_SAMBA //!< Directory server is Samba.
156
157typedef enum {
158 FR_LDAP_SYNC_NONE = 0, //!< No support for LDAP sync
159 FR_LDAP_SYNC_RFC4533, //!< Directory supports RFC 4533
160 FR_LDAP_SYNC_ACTIVE_DIRECTORY, //!< Directory supports AD style persistent search.
161 FR_LDAP_SYNC_PERSISTENT_SEARCH //!< Directory supports persistent search
163
164/** LDAP connection handle states
165 *
166 */
167typedef enum {
168 FR_LDAP_STATE_INIT = 0, //!< Connection uninitialised.
169 FR_LDAP_STATE_START_TLS, //!< TLS is being negotiated.
170 FR_LDAP_STATE_BIND, //!< Connection is being bound.
171 FR_LDAP_STATE_DISCOVER, //!< Directory capabilities are being read from the rootDSE.
172 FR_LDAP_STATE_RUN, //!< Connection is muxing/demuxing requests.
173 FR_LDAP_STATE_ERROR //!< Connection is in an error state.
175
176/** Types of LDAP requests
177 *
178 */
179typedef enum {
180 LDAP_REQUEST_SEARCH = 1, //!< A lookup in an LDAP directory
181 LDAP_REQUEST_MODIFY, //!< A modification to an LDAP entity
182 LDAP_REQUEST_DELETE, //!< A deletion of an LDAP entity
183 LDAP_REQUEST_EXTENDED //!< An extended LDAP operation
185
186/** LDAP query result codes
187 *
188 */
189typedef enum {
190 LDAP_RESULT_PENDING = 1, //!< Result not yet returned
191 LDAP_RESULT_SUCCESS = 0, //!< Successfully got LDAP results
192 LDAP_RESULT_ERROR = -1, //!< A general error occurred
193 LDAP_RESULT_TIMEOUT = -2, //!< The query timed out
194 LDAP_RESULT_BAD_DN = -3, //!< The requested DN does not exist
195 LDAP_RESULT_NO_RESULT = -4, //!< No results returned
196 LDAP_RESULT_REFERRAL_FAIL = -5, //!< Initial results indicated a referral was needed
197 ///< but the referral could not be followed
198 LDAP_RESULT_EXCESS_REFERRALS = -6, //!< The referral chain took too many hops
199 LDAP_RESULT_MISSING_REFERRAL = -7, //!< A referral was indicated but no URL was provided
201
202typedef struct {
203 char const *vendor_str; //!< As returned from the vendorName attribute in the
204 ///< rootDSE.
205 char const *version_str; //!< As returned from the vendorVersion attribute in the
206 ///< rootDSE.
207 fr_ldap_directory_type_t type; ///< Canonical server implementation.
208
209 bool cleartext_password; //!< Whether the server will return the user's plaintext
210 ///< password.
211
212 fr_ldap_sync_type_t sync_type; //!< What kind of LDAP sync this directory supports.
213
214 char const *dn_attr; //!< Attribute to match an entry's DN in a search filter.
215 ///< Defaults to RFC 5020 entryDN, distinguishedName
216 ///< on Active Directory and Samba.
217
218 char const **naming_contexts; //!< NULL terminated array of databases
219 ///< served by this directory.
220 fr_hash_table_t *naming_contexts_ht; //!< For resolving DNs to the naming context
221 ///< containing them.
222
223 bool discovered; //!< A rootDSE response has been parsed into these fields.
225
226/** Connection configuration
227 *
228 * Must not be passed into functions except via the connection handle
229 * this avoids problems with not using the connection pool configuration.
230 */
231typedef struct {
232 char const *name; //!< Name of the module that created this connection.
233
234 char *server; //!< Initial server to bind to.
235 char const **server_str; //!< Server set in the config.
236
237 uint16_t port; //!< Port to use when binding to the server.
238
239 char const *admin_identity; //!< Identity we bind as when we need to query the LDAP
240 ///< directory.
241 char const *admin_password; //!< Password used in administrative bind.
242
243 fr_ldap_sasl_t admin_sasl; //!< SASL parameters used when binding as the admin.
244
245 const char *sasl_secprops; //!< SASL Security Properties to set.
246
247 int dereference; //!< libldap value specifying dereferencing behaviour.
248 char const *dereference_str; //!< When to dereference (never, searching, finding, always)
249
250 bool chase_referrals; //!< If the LDAP server returns a referral to another server
251 ///< or point in the tree, follow it, establishing new
252 ///< connections and binding where necessary.
253 bool chase_referrals_unset; //!< If true, use the OpenLDAP defaults for chase_referrals.
254
255 bool use_referral_credentials; //!< If true use credentials from the referral URL.
256
257 uint16_t referral_depth; //!< How many referrals to chase
258
259 bool rebind; //!< If use_referral_credentials is false, controls whether we
260 ///< bind as our admin credentials (true) or anonymously (false)
261 ///< when connecting to a different server to follow a referral
262
263 /*
264 * TLS items.
265 */
267
268 bool start_tls; //!< Send the Start TLS message to the LDAP directory
269 ///< to start encrypted communications using the standard
270 ///< LDAP port.
271
272 char const *tls_ca_file; //!< Sets the full path to a CA certificate (used to validate
273 ///< the certificate the server presents).
274
275 char const *tls_ca_path; //!< Sets the path to a directory containing CA certificates.
276
277 char const *tls_certificate_file; //!< Sets the path to the public certificate file we present
278 ///< to the servers.
279
280 char const *tls_private_key_file; //!< Sets the path to the private key for our public
281 ///< certificate.
282
283 char const *tls_require_cert_str; //!< Sets requirements for validating the certificate the
284 ///< server presents.
285
286 int tls_require_cert; //!< OpenLDAP constant representing the require cert string.
287
288 char const *tls_min_version_str; //!< Minimum TLS version
290
291 /*
292 * For keep-alives.
293 */
294 fr_time_delta_t keepalive_idle; //!< Number of seconds a connections needs to remain idle
295 //!< before TCP starts sending keepalive probes.
296
297 uint32_t keepalive_probes; //!< Number of missed timeouts before the connection is
298 ///< dropped.
299
300 fr_time_delta_t keepalive_interval; //!< Interval between keepalive probes.
301
302 /*
303 * Search timelimits
304 */
305 fr_time_delta_t srv_timelimit; //!< How long the server should spent on a single request
306 ///< (also bounded by value on the server).
307
308 fr_time_delta_t res_timeout; //!< How long we wait for results.
309
310 /*
311 * I/O timelimits.
312 */
313 fr_time_delta_t net_timeout; //!< How long we wait in blocking network calls.
314 ///< We set this in the LDAP API, even though with
315 ///< async calls, we control this using our event loop.
316 ///< This is just in case there are blocking calls which
317 ///< happen internally which we can't work around.
318
319 fr_time_delta_t tls_handshake_timeout; //!< How long we wait for the TLS handshake to complete.
320
321 fr_time_delta_t reconnection_delay; //!< How long to wait before attempting to reconnect.
322
323 fr_time_delta_t idle_timeout; //!< How long to wait before closing unused connections.
325
326/** libldap global configuration data
327 *
328 */
329typedef struct {
330 uint32_t ldap_debug; //!< LDAP debug level
331 char const *tls_random_file; //!< Path to the ramdon file if /dev/random and /dev/urandom
332 //!< are unavailable
334
336
338
339/** Tracks the state of a libldap connection handle
340 *
341 */
342typedef struct {
343 LDAP *handle; //!< libldap handle.
344
345 fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS + 1]; //!< Server controls to use for all operations
346 ///< with this handle.
347 fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS + 1]; //!< Client controls to use for all operations
348 ///< with this handle.
349 int serverctrls_cnt; //!< Number of server controls associated with the handle.
350 int clientctrls_cnt; //!< Number of client controls associated with the handle.
351
352 fr_ldap_directory_t *directory; //!< The type of directory we're connected to.
353
354 fr_ldap_config_t const *config; //!< rlm_ldap connection configuration.
355 connection_t *conn; //!< Connection state handle.
356
357 fr_ldap_state_t state; //!< LDAP connection state machine.
358
359 int fd; //!< File descriptor for this connection.
360
361 fr_rb_tree_t *queries; //!< Outstanding queries on this connection
362 fr_dlist_head_t refs; //!< Replied to queries still referencing this connection.
363
364 void *uctx; //!< User data associated with the handle.
366
367/** Result of expanding the RHS of a set of maps
368 *
369 * Used to store the array of attributes we'll be querying for.
370 */
371typedef struct {
372 map_list_t const *maps; //!< Head of list of maps we expanded the RHS of.
373 char const *attrs[LDAP_MAX_ATTRMAP + LDAP_MAP_RESERVED + 1]; //!< Reserve some space for access attributes
374 //!< and NULL termination.
375 TALLOC_CTX *ctx; //!< Context to allocate new attributes in.
376 int count; //!< Index on next free element.
378
379/** Thread specific structure to manage LDAP trunk connections.
380 *
381 */
382typedef struct {
383 fr_rb_tree_t *trunks; //!< Tree of LDAP trunks used by this thread
384 fr_ldap_config_t *config; //!< Module instance config
385 trunk_conf_t *trunk_conf; //!< Module trunk config
386 trunk_conf_t *bind_trunk_conf; //!< Trunk config for bind auth trunk
387 fr_event_list_t *el; //!< Thread event list for callbacks / timeouts
388 fr_ldap_thread_trunk_t *bind_trunk; //!< LDAP trunk used for bind auths
389 fr_rb_tree_t *binds; //!< Tree of outstanding bind auths
390 fr_pair_list_t *trigger_args; //!< Passed to trigger request for normal trunks
391 fr_pair_list_t *bind_trigger_args; //!< Passed to trigger request for bind trunks
393
394/** Thread LDAP trunk structure
395 *
396 * One fr_ldap_thread_trunk_t will be allocated for each destination a thread needs
397 * to create an LDAP trunk connection to.
398 *
399 * Used to hold config regarding the LDAP connection and associate pending queries
400 * with the trunk they are running on.
401 */
403 fr_rb_node_t node; //!< Entry in the tree of connections
404 char const *uri; //!< Server URI for this connection
405 char const *bind_dn; //!< DN connection is bound as
406 fr_ldap_config_t config; //!< Config used for this connection
407 fr_ldap_directory_t *directory; //!< The type of directory we're connected to.
408 trunk_t *trunk; //!< Connection trunk
409 fr_ldap_thread_t *t; //!< Thread this connection is associated with
410 fr_timer_t *ev; //!< Event to close the thread when it has been idle.
412
414
416
417typedef void (*fr_ldap_result_parser_t)(LDAP *handle, fr_ldap_query_t *query, LDAPMessage *head, void *rctx);
418
419/** LDAP query structure
420 *
421 * Used to hold the elements of an LDAP query and track its progress.
422 * libldap structures will be freed by the talloc destructor.
423 * The same structure is used both for search queries and modifications
424 */
426 fr_rb_node_t node; //!< Entry in the tree of outstanding queries.
427 fr_dlist_t entry; //!< Entry in the list of connection references.
428
429 LDAPURLDesc *ldap_url; //!< parsed URL for current query if the source
430 ///< of the query was a URL.
431
432 char const *dn; //!< Base DN for searches, DN for modifications.
433
434 /** Fields which are unique to each type of query
435 *
436 * @note Delete only uses the DN field, as it operates at an object level.
437 */
438 union {
439 struct {
440 char const **attrs; //!< Attributes being requested in a search.
441 int scope; //!< Search scope.
442 char const *filter; //!< Filter for search.
443 } search;
444 struct {
445 char const *reqoid; //!< OID of extended operation to perform.
446 struct berval *reqdata; //!< Data required for the request.
447 } extended;
448 LDAPMod **mods; //!< Changes to be applied if this query is a modification.
449 };
450
451 fr_ldap_request_type_t type; //!< What type of query this is.
452
453 fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS]; //!< Server controls specific to this query.
454 fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS]; //!< Client controls specific to this query.
455
456 int msgid; //!< The unique identifier for this query.
457 ///< Uniqueness is only per connection.
458
459 trunk_request_t *treq; //!< Trunk request this query is associated with
460 fr_ldap_connection_t *ldap_conn; //!< LDAP connection this query is running on.
461
462 fr_timer_t *ev; //!< Event for timing out the query
463
464 char **referral_urls; //!< Referral results to follow
465 fr_dlist_head_t referrals; //!< List of parsed referrals
466 uint16_t referral_depth; //!< How many referrals we have followed
467 fr_ldap_referral_t *referral; //!< Referral actually being followed
468
469 fr_ldap_result_parser_t parser; //!< Custom results parser.
470
471 LDAPMessage *result; //!< Head of LDAP results list.
472
473 fr_ldap_result_code_t ret; //!< Result code
474};
475
476/** Parsed LDAP referral structure
477 *
478 * When LDAP servers respond with a referral, it is parsed into one or more fr_ldap_referral_t
479 * and kept until the referral has been followed.
480 * Avoids repeated parsing of the referrals as provided by libldap.
481 */
482typedef struct fr_ldap_referral_s {
483 fr_dlist_t entry; //!< Entry in list of possible referrals
484 fr_ldap_query_t *query; //!< Query this referral relates to
485 LDAPURLDesc *referral_url; //!< URL for the referral
486 char *host_uri; //!< Host URI used for referral connection
487 char const *identity; //!< Bind identity for referral connection
488 char const *password; //!< Bind password for referral connection
489 fr_ldap_thread_trunk_t *ttrunk; //!< Trunk this referral should use
490 request_t *request; //!< Request this referral relates to
492
493/** Holds arguments for the async bind operation
494 *
495 */
496typedef struct {
497 fr_ldap_connection_t *c; //!< to bind. Only used when binding as admin user.
498 char const *bind_dn; //!< of the user, may be NULL to bind anonymously.
499 char const *password; //!< of the user, may be NULL if no password is specified.
500 LDAPControl **serverctrls; //!< Controls to pass to the server.
501 LDAPControl **clientctrls; //!< Controls to pass to the client (library).
502
503 int msgid; //!< Of the bind operation. Only used when binding as admin.
505
506/** Holds arguments for the async SASL bind operation
507 *
508 */
509typedef struct {
510 fr_ldap_connection_t *c; //!< to bind. Only used when binding as admin user.
511 char const *mechs; //!< SASL mechanisms to run
512 char const *identity; //!< of the user.
513 char const *password; //!< of the user, may be NULL if no password is specified.
514 char const *proxy; //!< Proxy identity, may be NULL in which case identity is used.
515 char const *realm; //!< SASL realm (may be NULL).
516 LDAPControl **serverctrls; //!< Controls to pass to the server.
517 LDAPControl **clientctrls; //!< Controls to pass to the client (library).
518
519 int msgid; //!< Last msgid. Only used when binding as admin user.
520 LDAPMessage *result; //!< Previous result.
521 char const *rmech; //!< Mech we're continuing with.
523
524typedef enum {
526#ifdef WITH_SASL
527 LDAP_BIND_SASL
528#endif
530
532
533/** Types of parsed LDAP filter nodes
534 */
535typedef enum {
536 LDAP_FILTER_NODE = 0, //!< The filter node is an individual one
537 //!< to be evaluated against an attribute.
538 LDAP_FILTER_GROUP //!< The filter node is a parent of a group
539 //!< which will be combined using a logical operator.
541
542/** Logical operators for use in LDAP filters
543 */
549
550/** Operators for use in LDAP filters
551 */
552typedef enum {
553 LDAP_FILTER_OP_UNSET = 0, //!< Attribute not set yet
554 LDAP_FILTER_OP_EQ, //!< Attribute equals value
555 LDAP_FILTER_OP_SUBSTR, //!< Attribute matches string with wildcards
556 LDAP_FILTER_OP_PRESENT, //!< Attribute present
557 LDAP_FILTER_OP_GE, //!< Attribute greater than or equal to value
558 LDAP_FILTER_OP_LE, //!< Attribute less than or equal to value
559 LDAP_FILTER_OP_BIT_AND, //!< Bitwise AND comparison
560 LDAP_FILTER_OP_BIT_OR //!< Bitwise OR comparison
562
563/** Structure to hold parsed details of LDAP filters
564 */
566 fr_dlist_t entry; //!< Entry in the list of filter nodes.
567 ldap_filter_type_t filter_type; //!< Type of this filter node.
568 char *orig; //!< Text representation of filter for debug messages,
569 union {
570 struct {
571 ldap_filter_logic_t logic_op; //!< Logical operator for this group.
572 fr_dlist_head_t children; //!< List of child nodes in this group.
573 };
574 struct {
575 char *attr; //!< Attribute for the filter node.
576 ldap_filter_op_t op; //!< Operator to be used for comparison.
577 fr_value_box_t *value; //!< Value to compare with.
578 };
579 };
580};
581
582/** Codes returned by fr_ldap internal functions
583 *
584 */
585typedef enum {
586 LDAP_PROC_REFERRAL = 2, //!< LDAP server returned referral URLs.
587 LDAP_PROC_CONTINUE = 1, //!< Operation is in progress.
588 LDAP_PROC_SUCCESS = 0, //!< Operation was successful.
589
590 LDAP_PROC_ERROR = -1, //!< Unrecoverable library/server error.
591
592 LDAP_PROC_BAD_CONN = -2, //!< Transitory error, caller should retry the operation
593 //!< with a new connection.
594
595 LDAP_PROC_NOT_PERMITTED = -3, //!< Operation was not permitted, either current user was
596 //!< locked out in the case of binds, or has insufficient
597 //!< access.
598
599 LDAP_PROC_REJECT = -4, //!< Bind failed, user was rejected.
600
601 LDAP_PROC_BAD_DN = -5, //!< Specified an invalid object in a bind or search DN.
602
603 LDAP_PROC_NO_RESULT = -6, //!< Got no results.
604
605 LDAP_PROC_TIMEOUT = -7, //!< Operation timed out.
606
607 LDAP_PROC_REFRESH_REQUIRED = -8 //!< Don't continue with the current refresh phase,
608 //!< exit, and retry the operation with a NULL cookie.
610
611/** Holds arguments for async bind auth requests
612 *
613 * Used when LDAP binds are being used to authenticate users, rather than admin binds.
614 * Allows tracking of multiple bind requests on a single connection.
615 */
616typedef struct {
617 fr_rb_node_t node; //!< Entry in the tree of outstanding bind requests.
618 fr_ldap_thread_t *thread; //!< This bind is being run by.
619 trunk_request_t *treq; //!< Trunk request this bind is associated with.
620 int msgid; //!< libldap msgid for this bind.
621 request_t *request; //!< this bind relates to.
622 fr_ldap_bind_type_t type; //!< type of bind.
623 union {
624 fr_ldap_bind_ctx_t *bind_ctx; //!< User data for simple binds.
625 fr_ldap_sasl_ctx_t *sasl_ctx; //!< User data for SASL binds.
626 };
627 fr_ldap_rcode_t ret; //!< Return code of bind operation.
629
630/*
631 * Tables for resolving strings to LDAP constants
632 */
635
639extern size_t fr_ldap_dereference_len;
641extern size_t fr_ldap_scope_len;
643extern size_t fr_ldap_tls_require_cert_len;
644
645/** Inline function to copy pointers from a berval to a valuebox
646 *
647 * @note This results in a shallow copy of the berval, so if the berval is freed
648 * the value box becomes invalidated.
649 *
650 * @param[out] value to write berval values to.
651 * @param[in] berval to copy pointers/lengths from.
652 */
653static inline void fr_ldap_berval_to_value_shallow(fr_value_box_t *value, struct berval *berval)
654{
655 fr_value_box_memdup_shallow(value, NULL, (uint8_t *)berval->bv_val, berval->bv_len, true);
656}
657
658/** Inline function to copy pointer from a berval to a string value box
659 *
660 * Useful for printing contents of bervals known to contain strings in DEBUG output since
661 * they are not NULL terminated.
662 *
663 * @note This results in a shallow copy of the berval, so if the berval is freed
664 * the value box becomes invalidated.
665 *
666 * @param[out] value to write berval value to.
667 * @param[in] berval top copy pointer / length from.
668 */
669static inline void fr_ldap_berval_to_value_str_shallow(fr_value_box_t *value, struct berval *berval)
670{
671 fr_value_box_bstrndup_shallow(value, NULL, berval->bv_val, berval->bv_len, true);
672}
673
674/** Compare a berval with a C string of a known length using case insensitive comparison
675 *
676 * @param[in] value berval.
677 * @param[in] str String to compare with value.
678 * @param[in] strlen Number of characters of str to compare.
679 */
680static inline int fr_ldap_berval_strncasecmp(struct berval *value, char const *str, size_t strlen)
681{
682 size_t i;
683 if (strlen != value->bv_len) return CMP(strlen, value->bv_len);
684
685 for (i = 0; i < strlen; i++) {
686 if (tolower((uint8_t)value->bv_val[i]) != tolower((uint8_t)str[i])) return CMP(value->bv_val[i], str[i]);
687 }
688
689 return 0;
690}
691
692/** Compare two ldap trunk structures on connection URI / DN
693 *
694 * @param[in] one first connection to compare.
695 * @param[in] two second connection to compare.
696 * @return CMP(one, two)
697 */
698static inline int8_t fr_ldap_trunk_cmp(void const *one, void const *two)
699{
700 fr_ldap_thread_trunk_t const *a = one, *b = two;
701 int8_t uricmp = CMP(strcmp(a->uri, b->uri), 0);
702
703 if (uricmp !=0) return uricmp;
704 if (!a->bind_dn || !b->bind_dn) return CMP(a->bind_dn, b->bind_dn);
705 return CMP(strcmp(a->bind_dn, b->bind_dn), 0);
706}
707
708/** Compare two ldap query structures on msgid
709 *
710 * @param[in] one first query to compare.
711 * @param[in] two second query to compare.
712 * @return CMP(one,two)
713 */
714static inline int8_t fr_ldap_query_cmp(void const *one, void const *two)
715{
716 fr_ldap_query_t const *a = one, *b = two;
717
718 return CMP(a->msgid, b->msgid);
719}
720
721/** Compare two ldap bind auth structures on msgid
722 *
723 * @param[in] one first bind request to compare.
724 * @param[in] two second bind request to compare.
725 * @return CMP(one,two)
726 */
727static inline int8_t fr_ldap_bind_auth_cmp(void const *one, void const *two)
728{
729 fr_ldap_bind_auth_ctx_t const *a = one, *b = two;
730
731 return CMP(a->msgid, b->msgid);
732}
733
735 char const *base_dn, int scope, char const *filter, char const * const * attrs,
736 LDAPControl **serverctrls, LDAPControl **clientctrls);
737
738fr_ldap_query_t *fr_ldap_modify_alloc(TALLOC_CTX *ctx, char const *dn,
739 LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls);
740
741fr_ldap_query_t *fr_ldap_extended_alloc(TALLOC_CTX *ctx, char const *reqiod, struct berval *reqdata,
742 LDAPControl **serverctrls, LDAPControl **clientctrls);
743
746 char const *base_dn, int scope, char const *filter, char const * const *attrs,
747 LDAPControl **serverctrls, LDAPControl **clientctrls);
748
751 char const *dn, LDAPMod *mods[],
752 LDAPControl **serverctrls, LDAPControl **clientctrls);
753
756 char const *reqoid, struct berval *reqdata,
757 LDAPControl **serverctrls, LDAPControl **clientctrls);
758
759/*
760 * base.c - Wrappers arounds OpenLDAP functions.
761 */
762void fr_ldap_timeout_debug(request_t *request, fr_ldap_connection_t const *conn,
763 fr_time_delta_t timeout, char const *prefix);
764
765size_t fr_ldap_dn_escape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
766 CC_HINT(nonnull(2,4));
767
768size_t fr_ldap_filter_escape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
769 CC_HINT(nonnull(2,4));
770
771size_t fr_ldap_uri_unescape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
772 CC_HINT(nonnull(2,4));
773
774char const *fr_ldap_error_str(fr_ldap_connection_t const *conn);
775
778 char const *dn, int scope, char const *filter, char const * const *attrs,
779 LDAPControl **serverctrls, LDAPControl **clientctrls);
780
782 char const *dn, LDAPMod *mods[],
783 LDAPControl **serverctrls, LDAPControl **clientctrls);
784
786 char const *dn,
787 LDAPControl **serverctrls, LDAPControl **clientctrls);
788
790 char const *reqiod, struct berval *reqdata);
791
792fr_ldap_rcode_t fr_ldap_error_check(LDAPControl ***ctrls, fr_ldap_connection_t const *conn,
793 LDAPMessage *msg, char const *dn);
794
795fr_ldap_rcode_t fr_ldap_result(LDAPMessage **result, LDAPControl ***ctrls,
796 fr_ldap_connection_t const *conn, int msgid, int all,
797 char const *dn,
798 fr_time_delta_t timeout);
799
801
802int fr_ldap_global_config(int debug_level, char const *tls_random_file);
803
804int fr_ldap_init(void);
805
806void fr_ldap_free(void);
807
808/*
809 * control.c - Connection based client/server controls
810 */
811void fr_ldap_control_merge(LDAPControl *serverctrls_out[],
812 LDAPControl *clientctrls_out[],
813 size_t serverctrls_len,
814 size_t clientctrls_len,
816 LDAPControl *serverctrls_in[],
817 LDAPControl *clientctrls_in[]);
818
819int fr_ldap_control_add_server(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit);
820
821int fr_ldap_control_add_client(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit);
822
824
826
827/*
828 * directory.c - Get directory capabilities from the remote server
829 */
830#define LDAP_DIRECTORY_ATTRS { "vendorname", \
831 "vendorversion", \
832 "isGlobalCatalogReady", \
833 "objectClass", \
834 "orcldirectoryversion", \
835 "supportedControl", \
836 "namingContexts", \
837 NULL }
838
840
841char const *fr_ldap_directory_common_base_find(fr_ldap_directory_t const *directory, char const * const *dn_list);
842
843int fr_ldap_directory_result_parse(fr_ldap_directory_t *directory, LDAP *handle,
844 LDAPMessage *result, char const *name);
845
847
849
850/*
851 * edir.c - Edirectory integrations
852 */
853unlang_action_t fr_ldap_edir_get_password(unlang_result_t *p_result, request_t *request, char const *dn,
854 fr_ldap_thread_trunk_t *ttrunk, fr_dict_attr_t const *password_da);
855
856char const *fr_ldap_edir_errstr(int code);
857
858
859/*
860 * map.c - Attribute mapping code.
861 */
862int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request,
863 map_t const *map, void *uctx);
864
865int fr_ldap_map_getdn(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request,
866 map_t const *map, void *uctx);
867
868int fr_ldap_map_verify(map_t *map, void *instance);
869
870int fr_ldap_map_expand(TALLOC_CTX *ctx, fr_ldap_map_exp_t *expanded, request_t *request,
871 map_list_t const *maps, char const *generic_attr, char const *check_attr,
872 char const *fallthrough_attr);
873
874int fr_ldap_map_do(request_t *request, char const *check_attr,
875 char const *valuepair_attr, fr_ldap_map_exp_t const *expanded, LDAPMessage *entry);
876
877/*
878 * connection.c - Connection configuration functions
879 */
881
882connection_state_t fr_ldap_connection_init(void **h, connection_t *conn, void *uctx);
883
885
886void fr_ldap_connection_close(fr_event_list_t *el, void *h, void *uctx);
887
889
891
893
895 char const *bind_dn, char const *bind_password,
896 request_t *request, fr_ldap_config_t const *config);
897
898trunk_state_t fr_thread_ldap_trunk_state(fr_ldap_thread_t *thread, char const *uri, char const *bind_dn);
899
901
902/*
903 * state.c - Connection state machine
904 */
906
908
909/*
910 * start_tls.c - Mostly async start_tls
911 */
913 LDAPControl **serverctrls, LDAPControl **clientctrls);
914
915/*
916 * sasl.c - Async sasl bind
917 */
918#ifdef WITH_SASL
920 char const *mechs,
921 char const *identity,
922 char const *password,
923 char const *proxy,
924 char const *realm,
925 LDAPControl **serverctrls, LDAPControl **clientctrls);
926
928 int *msgid,
929 fr_ldap_connection_t *ldap_conn);
930
932 request_t *request,
933 fr_ldap_thread_t *thread,
934 char const *mechs,
935 char const *identity,
936 char const *password,
937 char const *proxy, char const *realm);
938#endif
939
940/*
941 * bind.c - Async bind
942 */
944 char const *bind_dn, char const *password,
945 LDAPControl **serverctrls, LDAPControl **clientctrls);
946
948 char const *bind_dn, char const *password);
949
950/*
951 * uti.c - Utility functions
952 */
953size_t fr_ldap_common_dn(char const *full, char const *part);
954
955bool fr_ldap_util_is_dn(char const *in, size_t inlen);
956
957size_t fr_ldap_util_normalise_dn(char *out, char const *in);
958
959char *fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in);
960
961/** State of an in place iteration over an attribute's values
962 *
963 * fr_ldap_value_iter_init returns the first value, fr_ldap_value_iter_next
964 * each value after it, NULL ends the iteration. The caller must always
965 * release the iterator with fr_ldap_value_iter_done, whether iteration
966 * completed or not.
967 */
968typedef struct {
969 BerElement *ber; //!< Cursor over the entry.
970 char *last; //!< End marker of the value set.
971 ber_len_t len; //!< Length of the current element.
972 struct berval value; //!< Value the iterator is positioned on.
973 bool found; //!< The attribute was found in the entry.
974 bool end; //!< All values have been returned.
976
977struct berval *fr_ldap_value_iter_init(int *err, fr_ldap_value_iter_t *iter, LDAP *handle, LDAPMessage *entry,
978 char const *attr);
979
980struct berval *fr_ldap_value_iter_alloc(int *err, fr_ldap_value_iter_t **out, TALLOC_CTX *ctx,
981 LDAP *handle, LDAPMessage *entry, char const *attr);
982
983struct berval *fr_ldap_value_iter_next(int *err, fr_ldap_value_iter_t *iter);
984
986
987int fr_ldap_result_values_len(size_t *num, size_t *strings_len, LDAP *handle, LDAPMessage *result,
988 char const *attr);
989
990int fr_ldap_entry_value_find(struct berval *out, LDAP *handle, LDAPMessage *entry, char const *attr);
991
992talloc_str_list_t *fr_ldap_str_list_afrom_result(TALLOC_CTX *ctx, LDAP *handle, LDAPMessage *result,
993 char const *attr, size_t extra);
994
995uint8_t *fr_ldap_berval_to_bin(TALLOC_CTX *ctx, struct berval const *in);
996
997int fr_ldap_parse_url_extensions(LDAPControl **sss, size_t sss_len, char *extensions[]);
998
999int fr_ldap_attrs_check(char const **attrs, char const *attr);
1000
1001int fr_ldap_server_url_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION const *cs);
1002
1003int fr_ldap_server_config_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION *cs);
1004
1005char const *fr_ldap_url_err_to_str(int ldap_url_err);
1006
1007void fr_ldap_entry_dump(LDAPMessage *entry);
1008
1009int fr_ldap_dn_box_escape(fr_value_box_t *vb, UNUSED void *uctx);
1010
1012
1013char *fr_ldap_filter_afrom_dn_list(TALLOC_CTX *ctx, char const *dn_attr, char const *filter,
1014 char const * const *dn_list);
1015
1016int fr_ldap_filter_to_tmpl(TALLOC_CTX *ctx, tmpl_rules_t const *t_rules, char const **sub, size_t sublen,
1017 tmpl_t **out) CC_HINT(nonnull());
1018
1019/*
1020 * referral.c - Handle LDAP referrals
1021 */
1022fr_ldap_referral_t *fr_ldap_referral_alloc(TALLOC_CTX *ctx, request_t *request);
1023
1025
1027
1028/*
1029 * filter.c - Basic filter parsing and filtering
1030 */
1031typedef int (*filter_attr_check_t)(char const *attr, void *uctx);
1032
1033fr_slen_t fr_ldap_filter_parse(TALLOC_CTX *ctx, fr_dlist_head_t **root, fr_sbuff_t *filter,
1034 filter_attr_check_t attr_check, void *uctx);
1035
1036bool fr_ldap_filter_eval(fr_dlist_head_t *root, fr_ldap_connection_t *conn, LDAPMessage *msg);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
log_entry msg
Definition acutest.h:794
#define CMP(_a, _b)
Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.
Definition build.h:113
#define UNUSED
Definition build.h:336
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
connection_state_t
Definition connection.h:47
static fr_slen_t err
Definition dict.h:882
static fr_slen_t in
Definition dict.h:882
Test enumeration values.
Definition dict_test.h:92
Head of a doubly linked list.
Definition dlist.h:51
Entry in a doubly linked list.
Definition dlist.h:41
Structure to define how to initialise libraries with global configuration.
Definition global_lib.h:38
char const * fr_ldap_url_err_to_str(int ldap_url_err)
Translate the error code emitted from ldap_url_parse and friends into something accessible with fr_st...
Definition util.c:1174
struct berval * fr_ldap_value_iter_init(int *err, fr_ldap_value_iter_t *iter, LDAP *handle, LDAPMessage *entry, char const *attr)
Start an in place iteration over an attribute's values in an entry.
Definition util.c:556
int fr_ldap_map_verify(map_t *map, void *instance)
size_t fr_ldap_uri_unescape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg))
Converts escaped DNs and filter strings into normal.
Definition util.c:227
size_t fr_ldap_util_normalise_dn(char *out, char const *in)
Normalise escape sequences in a DN.
Definition util.c:827
int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
Callback for map_to_request.
Definition map.c:39
static void fr_ldap_berval_to_value_shallow(fr_value_box_t *value, struct berval *berval)
Inline function to copy pointers from a berval to a valuebox.
Definition base.h:653
int fr_ldap_control_add_session_tracking(fr_ldap_connection_t *conn, request_t *request)
char const * fr_ldap_directory_common_base_find(fr_ldap_directory_t const *directory, char const *const *dn_list)
Find the naming context which contains a set of DNs.
Definition directory.c:296
fr_ldap_rcode_t fr_ldap_error_check(LDAPControl ***ctrls, fr_ldap_connection_t const *conn, LDAPMessage *msg, char const *dn)
Perform basic parsing of multiple types of messages, checking for error conditions.
Definition base.c:232
fr_slen_t fr_ldap_filter_parse(TALLOC_CTX *ctx, fr_dlist_head_t **root, fr_sbuff_t *filter, filter_attr_check_t attr_check, void *uctx)
Parse an LDAP filter into its component nodes.
Definition filter.c:343
int fr_ldap_filter_to_tmpl(TALLOC_CTX *ctx, tmpl_rules_t const *t_rules, char const **sub, size_t sublen, tmpl_t **out))
Combine filters and tokenize to a tmpl.
Definition util.c:948
char const * mech
SASL mech(s) to try.
Definition base.h:129
ber_len_t len
Length of the current element.
Definition base.h:971
char const * proxy
Proxy identity, may be NULL in which case identity is used.
Definition base.h:514
fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS]
Server controls specific to this query.
Definition base.h:453
LDAP * ldap_global_handle
Hack for OpenLDAP libldap global initialisation.
Definition base.c:38
LDAPURLDesc * referral_url
URL for the referral.
Definition base.h:485
int fr_ldap_map_do(request_t *request, char const *check_attr, char const *valuepair_attr, fr_ldap_map_exp_t const *expanded, LDAPMessage *entry)
Convert attribute map into valuepairs.
Definition map.c:377
LDAPControl ** clientctrls
Controls to pass to the client (library).
Definition base.h:501
int fr_ldap_conn_directory_alloc_async(fr_ldap_connection_t *ldap_conn)
Asynchronously extract useful information from the rootDSE of the LDAP server.
Definition directory.c:442
void fr_ldap_connection_close(fr_event_list_t *el, void *h, void *uctx)
size_t fr_ldap_dereference_len
Definition base.c:92
fr_ldap_thread_t * t
Thread this connection is associated with.
Definition base.h:409
char const * tls_private_key_file
Sets the path to the private key for our public certificate.
Definition base.h:280
fr_dlist_t entry
Entry in the list of connection references.
Definition base.h:427
char const * proxy
Identity to proxy.
Definition base.h:130
fr_time_delta_t res_timeout
How long we wait for results.
Definition base.h:308
ldap_filter_logic_t
Logical operators for use in LDAP filters.
Definition base.h:544
@ LDAP_FILTER_LOGIC_NOT
Definition base.h:547
@ LDAP_FILTER_LOGIC_OR
Definition base.h:546
@ LDAP_FILTER_LOGIC_AND
Definition base.h:545
fr_ldap_rcode_t fr_ldap_search_async(int *msgid, request_t *request, fr_ldap_connection_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.
Definition base.c:529
fr_ldap_rcode_t ret
Return code of bind operation.
Definition base.h:627
char * host_uri
Host URI used for referral connection.
Definition base.h:486
char const * fr_ldap_error_str(fr_ldap_connection_t const *conn)
Return the error string associated with a handle.
Definition base.c:210
char const * admin_password
Password used in administrative bind.
Definition base.h:241
int fr_ldap_entry_value_find(struct berval *out, LDAP *handle, LDAPMessage *entry, char const *attr)
Find an attribute in an entry, returning its first value referenced in place.
Definition util.c:748
fr_ldap_state_t state
LDAP connection state machine.
Definition base.h:357
int fr_ldap_filter_box_escape(fr_value_box_t *vb, UNUSED void *uctx)
Definition util.c:183
fr_ldap_config_t * config
Module instance config.
Definition base.h:384
void fr_ldap_control_clear(fr_ldap_connection_t *conn)
Clear and free any controls associated with a connection.
Definition control.c:134
size_t fr_ldap_scope_len
Definition base.c:75
int count
Index on next free element.
Definition base.h:376
LDAP * fr_ldap_handle_thread_local(void)
Get a thread local dummy LDAP handle.
Definition base.c:1130
void fr_ldap_value_iter_done(fr_ldap_value_iter_t *iter)
Release value iteration state.
Definition util.c:507
bool chase_referrals
If the LDAP server returns a referral to another server or point in the tree, follow it,...
Definition base.h:250
fr_table_num_sorted_t const fr_ldap_supported_extensions[]
Definition base.c:60
bool fr_ldap_util_is_dn(char const *in, size_t inlen)
Check whether a string looks like a DN.
Definition util.c:275
char ** referral_urls
Referral results to follow.
Definition base.h:464
char * last
End marker of the value set.
Definition base.h:970
size_t fr_ldap_filter_escape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg))
Escape a string for use as an RFC 4515 filter assertion value.
Definition util.c:155
fr_ldap_directory_type_t
Definition base.h:140
@ FR_LDAP_DIRECTORY_ORACLE_UNIFIED_DIRECTORY
Directory server is Oracle Unified Directory.
Definition base.h:149
@ FR_LDAP_DIRECTORY_UNKNOWN
We can't determine the directory server.
Definition base.h:141
@ FR_LDAP_DIRECTORY_NETSCAPE
Directory server is Netscape.
Definition base.h:146
@ FR_LDAP_DIRECTORY_EDIRECTORY
Directory server is eDir.
Definition base.h:144
@ FR_LDAP_DIRECTORY_ORACLE_INTERNET_DIRECTORY
Directory server is Oracle Internet Directory.
Definition base.h:148
@ FR_LDAP_DIRECTORY_UNBOUND_ID
Directory server is Unbound ID.
Definition base.h:153
@ FR_LDAP_DIRECTORY_SIEMENS_AG
Directory server is Siemens AG.
Definition base.h:152
@ FR_LDAP_DIRECTORY_ORACLE_VIRTUAL_DIRECTORY
Directory server is Oracle Virtual Directory.
Definition base.h:150
@ FR_LDAP_DIRECTORY_ACTIVE_DIRECTORY
Directory server is Active Directory.
Definition base.h:143
@ FR_LDAP_DIRECTORY_OPENLDAP
Directory server is OpenLDAP.
Definition base.h:147
@ FR_LDAP_DIRECTORY_SUN_ONE_DIRECTORY
Directory server is Sun One Directory.
Definition base.h:151
@ FR_LDAP_DIRECTORY_IBM
Directory server is IBM.
Definition base.h:145
@ FR_LDAP_DIRECTORY_SAMBA
Directory server is Samba.
Definition base.h:154
int msgid
libldap msgid for this bind.
Definition base.h:620
int fr_ldap_global_config(int debug_level, char const *tls_random_file)
Change settings global to libldap.
Definition base.c:1151
map_list_t const * maps
Head of list of maps we expanded the RHS of.
Definition base.h:372
size_t fr_ldap_common_dn(char const *full, char const *part)
Find the place at which the two DN strings diverge.
Definition util.c:877
char const * tls_certificate_file
Sets the path to the public certificate file we present to the servers.
Definition base.h:277
struct berval * fr_ldap_value_iter_next(int *err, fr_ldap_value_iter_t *iter)
Return the next value of the iterated attribute.
Definition util.c:523
char * server
Initial server to bind to.
Definition base.h:234
static int8_t fr_ldap_bind_auth_cmp(void const *one, void const *two)
Compare two ldap bind auth structures on msgid.
Definition base.h:727
int dereference
libldap value specifying dereferencing behaviour.
Definition base.h:247
fr_ldap_sync_type_t sync_type
What kind of LDAP sync this directory supports.
Definition base.h:212
uint16_t referral_depth
How many referrals we have followed.
Definition base.h:466
LDAP * handle
libldap handle.
Definition base.h:343
int msgid
The unique identifier for this query.
Definition base.h:456
char const * dn
Base DN for searches, DN for modifications.
Definition base.h:432
char const * bind_dn
DN connection is bound as.
Definition base.h:405
void fr_ldap_control_merge(LDAPControl *serverctrls_out[], LDAPControl *clientctrls_out[], size_t serverctrls_len, size_t clientctrls_len, fr_ldap_connection_t *conn, LDAPControl *serverctrls_in[], LDAPControl *clientctrls_in[])
Merge connection and call specific client and server controls.
Definition control.c:48
fr_rb_node_t node
Entry in the tree of connections.
Definition base.h:403
int serverctrls_cnt
Number of server controls associated with the handle.
Definition base.h:349
fr_dlist_head_t referrals
List of parsed referrals.
Definition base.h:465
int fr_ldap_attrs_check(char const **attrs, char const *attr)
Check that a particular attribute is included in an attribute list.
Definition util.c:1010
char const * admin_identity
Identity we bind as when we need to query the LDAP directory.
Definition base.h:239
global_lib_autoinst_t fr_libldap_global_config
Definition base.c:134
fr_ldap_result_code_t ret
Result code.
Definition base.h:473
fr_ldap_result_parser_t parser
Custom results parser.
Definition base.h:469
fr_ldap_directory_t * fr_ldap_directory_alloc(TALLOC_CTX *ctx)
Allocate a directory structure with defaults.
Definition directory.c:272
uint8_t * fr_ldap_berval_to_bin(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced buffer.
Definition util.c:797
bool freeit
Whether the control should be freed after we've finished using it.
Definition base.h:136
fr_rb_tree_t * trunks
Tree of LDAP trunks used by this thread.
Definition base.h:383
request_t * request
Request this referral relates to.
Definition base.h:490
int fr_ldap_referral_follow(fr_ldap_thread_t *thread, request_t *request, fr_ldap_query_t *query)
Follow an LDAP referral.
Definition referral.c:113
trunk_conf_t * trunk_conf
Module trunk config.
Definition base.h:385
fr_rb_tree_t * queries
Outstanding queries on this connection.
Definition base.h:361
int fr_ldap_bind_async(fr_ldap_connection_t *c, char const *bind_dn, char const *password, LDAPControl **serverctrls, LDAPControl **clientctrls)
Install I/O handlers for the bind operation.
Definition bind.c:187
fr_ldap_rcode_t fr_ldap_result(LDAPMessage **result, LDAPControl ***ctrls, fr_ldap_connection_t const *conn, int msgid, int all, char const *dn, fr_time_delta_t timeout)
Parse response from LDAP server dealing with any errors.
Definition base.c:450
fr_time_delta_t keepalive_idle
Number of seconds a connections needs to remain idle before TCP starts sending keepalive probes.
Definition base.h:294
char const * dereference_str
When to dereference (never, searching, finding, always)
Definition base.h:248
fr_ldap_referral_t * fr_ldap_referral_alloc(TALLOC_CTX *ctx, request_t *request)
Allocate a new structure to handle an LDAP referral, setting the destructor.
Definition referral.c:49
int fr_ldap_connection_timeout_set(fr_ldap_connection_t const *conn, fr_time_delta_t timeout)
Definition connection.c:415
fr_ldap_directory_t * directory
The type of directory we're connected to.
Definition base.h:352
fr_ldap_state_t
LDAP connection handle states.
Definition base.h:167
@ FR_LDAP_STATE_ERROR
Connection is in an error state.
Definition base.h:173
@ FR_LDAP_STATE_BIND
Connection is being bound.
Definition base.h:170
@ FR_LDAP_STATE_START_TLS
TLS is being negotiated.
Definition base.h:169
@ FR_LDAP_STATE_RUN
Connection is muxing/demuxing requests.
Definition base.h:172
@ FR_LDAP_STATE_DISCOVER
Directory capabilities are being read from the rootDSE.
Definition base.h:171
@ FR_LDAP_STATE_INIT
Connection uninitialised.
Definition base.h:168
unlang_action_t fr_ldap_trunk_modify(TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *dn, LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls)
Run an async modification LDAP query on a trunk connection.
Definition base.c:770
char const * identity
of the user.
Definition base.h:512
trunk_request_t * treq
Trunk request this query is associated with.
Definition base.h:459
int fr_ldap_map_getdn(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
Callback for map_to_request.
Definition map.c:210
fr_rb_node_t node
Entry in the tree of outstanding queries.
Definition base.h:426
static void fr_ldap_berval_to_value_str_shallow(fr_value_box_t *value, struct berval *berval)
Inline function to copy pointer from a berval to a string value box.
Definition base.h:669
fr_dlist_head_t refs
Replied to queries still referencing this connection.
Definition base.h:362
size_t fr_ldap_dn_escape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg))
Escape a string for use as an RFC 4514 DN attribute value.
Definition util.c:69
fr_ldap_thread_trunk_t * fr_thread_ldap_trunk_get(fr_ldap_thread_t *thread, char const *uri, char const *bind_dn, char const *bind_password, request_t *request, fr_ldap_config_t const *config)
Find a thread specific LDAP connection for a specific URI / bind DN.
Definition connection.c:940
size_t fr_ldap_supported_extensions_len
Definition base.c:64
size_t fr_ldap_connection_states_len
Definition base.c:58
fr_table_num_sorted_t const fr_ldap_connection_states[]
Definition base.c:50
int fd
File descriptor for this connection.
Definition base.h:359
fr_timer_t * ev
Event to close the thread when it has been idle.
Definition base.h:410
void fr_ldap_state_error(fr_ldap_connection_t *c)
Signal that there's been an error on the connection.
Definition state.c:153
fr_dlist_t entry
Entry in list of possible referrals.
Definition base.h:483
int fr_ldap_result_values_len(size_t *num, size_t *strings_len, LDAP *handle, LDAPMessage *result, char const *attr)
Sum the lengths of an attribute's values across every entry of a result.
Definition util.c:653
bool fr_ldap_filter_eval(fr_dlist_head_t *root, fr_ldap_connection_t *conn, LDAPMessage *msg)
Evaluate an LDAP filter.
Definition filter.c:583
char const * uri
Server URI for this connection.
Definition base.h:404
int fr_ldap_server_url_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION const *cs)
Check an LDAP server entry in URL format is valid.
Definition util.c:1036
fr_dlist_t entry
Entry in the list of filter nodes.
Definition base.h:566
const char * sasl_secprops
SASL Security Properties to set.
Definition base.h:245
struct fr_ldap_referral_s fr_ldap_referral_t
Parsed LDAP referral structure.
Definition base.h:413
bool end
All values have been returned.
Definition base.h:974
ldap_filter_type_t
Types of parsed LDAP filter nodes.
Definition base.h:535
@ LDAP_FILTER_GROUP
The filter node is a parent of a group which will be combined using a logical operator.
Definition base.h:538
@ LDAP_FILTER_NODE
The filter node is an individual one to be evaluated against an attribute.
Definition base.h:536
void fr_ldap_free(void)
LDAPMessage * result
Previous result.
Definition base.h:520
fr_time_delta_t keepalive_interval
Interval between keepalive probes.
Definition base.h:300
fr_time_delta_t tls_handshake_timeout
How long we wait for the TLS handshake to complete.
Definition base.h:319
char * fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced string.
Definition util.c:778
int msgid
Of the bind operation. Only used when binding as admin.
Definition base.h:503
char const * tls_require_cert_str
Sets requirements for validating the certificate the server presents.
Definition base.h:283
fr_time_delta_t net_timeout
How long we wait in blocking network calls.
Definition base.h:313
char const * fr_ldap_edir_errstr(int code)
Definition edir.c:328
struct fr_ldap_thread_trunk_s fr_ldap_thread_trunk_t
Thread LDAP trunk structure.
Definition base.h:337
fr_ldap_config_t const * config
rlm_ldap connection configuration.
Definition base.h:354
fr_ldap_connection_t * c
to bind. Only used when binding as admin user.
Definition base.h:510
LDAPControl ** clientctrls
Controls to pass to the client (library).
Definition base.h:517
#define LDAP_MAX_ATTRMAP
Maximum number of mappings between LDAP and FreeRADIUS attributes.
Definition base.h:96
request_t * request
this bind relates to.
Definition base.h:621
fr_ldap_connection_t * c
to bind. Only used when binding as admin user.
Definition base.h:497
int fr_ldap_control_add_server(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit)
Add a serverctrl to a connection handle.
Definition control.c:93
fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS]
Client controls specific to this query.
Definition base.h:454
fr_ldap_rcode_t fr_ldap_modify_async(int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *dn, LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls)
Modify something in the LDAP directory.
Definition base.c:820
fr_ldap_bind_type_t
Definition base.h:524
@ LDAP_BIND_SIMPLE
Definition base.h:525
trunk_request_t * treq
Trunk request this bind is associated with.
Definition base.h:619
char const * tls_ca_path
Sets the path to a directory containing CA certificates.
Definition base.h:275
uint32_t keepalive_probes
Number of missed timeouts before the connection is dropped.
Definition base.h:297
char const * realm
SASL realm (may be NULL).
Definition base.h:515
bool rebind
If use_referral_credentials is false, controls whether we bind as our admin credentials (true) or ano...
Definition base.h:259
static int8_t fr_ldap_query_cmp(void const *one, void const *two)
Compare two ldap query structures on msgid.
Definition base.h:714
char const * mechs
SASL mechanisms to run.
Definition base.h:511
fr_ldap_rcode_t fr_ldap_extended_async(int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *reqiod, struct berval *reqdata)
Initiate an LDAP extended operation.
Definition base.c:949
char const * password
of the user, may be NULL if no password is specified.
Definition base.h:513
static int8_t fr_ldap_trunk_cmp(void const *one, void const *two)
Compare two ldap trunk structures on connection URI / DN.
Definition base.h:698
fr_ldap_config_t config
Config used for this connection.
Definition base.h:406
int tls_require_cert
OpenLDAP constant representing the require cert string.
Definition base.h:286
fr_table_num_sorted_t const fr_ldap_tls_require_cert[]
Definition base.c:77
char const * tls_random_file
Path to the ramdon file if /dev/random and /dev/urandom are unavailable.
Definition base.h:331
int fr_ldap_server_config_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION *cs)
Check an LDAP server config in server:port format is valid.
Definition util.c:1133
talloc_str_list_t * fr_ldap_str_list_afrom_result(TALLOC_CTX *ctx, LDAP *handle, LDAPMessage *result, char const *attr, size_t extra)
Copy an attribute's values from every entry of a result into a string list.
Definition util.c:696
int fr_ldap_dn_box_escape(fr_value_box_t *vb, UNUSED void *uctx)
Definition util.c:109
fr_ldap_state_t fr_ldap_state_next(fr_ldap_connection_t *c)
Move between LDAP connection states.
Definition state.c:50
fr_table_num_sorted_t const fr_ldap_dereference[]
Definition base.c:86
char const * identity
Bind identity for referral connection.
Definition base.h:487
bool start_tls
Send the Start TLS message to the LDAP directory to start encrypted communications using the standard...
Definition base.h:268
ldap_filter_op_t
Operators for use in LDAP filters.
Definition base.h:552
@ LDAP_FILTER_OP_BIT_AND
Bitwise AND comparison.
Definition base.h:559
@ LDAP_FILTER_OP_PRESENT
Attribute present.
Definition base.h:556
@ LDAP_FILTER_OP_SUBSTR
Attribute matches string with wildcards.
Definition base.h:555
@ LDAP_FILTER_OP_EQ
Attribute equals value.
Definition base.h:554
@ LDAP_FILTER_OP_LE
Attribute less than or equal to value.
Definition base.h:558
@ LDAP_FILTER_OP_BIT_OR
Bitwise OR comparison.
Definition base.h:560
@ LDAP_FILTER_OP_GE
Attribute greater than or equal to value.
Definition base.h:557
@ LDAP_FILTER_OP_UNSET
Attribute not set yet.
Definition base.h:553
int tls_min_version
Definition base.h:289
bool use_referral_credentials
If true use credentials from the referral URL.
Definition base.h:255
unlang_action_t fr_ldap_edir_get_password(unlang_result_t *p_result, request_t *request, char const *dn, fr_ldap_thread_trunk_t *ttrunk, fr_dict_attr_t const *password_da)
Initiate retrieval of the universal password from Novell eDirectory.
Definition edir.c:293
fr_ldap_query_t * query
Query this referral relates to.
Definition base.h:484
char const * vendor_str
As returned from the vendorName attribute in the rootDSE.
Definition base.h:203
fr_ldap_request_type_t
Types of LDAP requests.
Definition base.h:179
@ LDAP_REQUEST_MODIFY
A modification to an LDAP entity.
Definition base.h:181
@ LDAP_REQUEST_SEARCH
A lookup in an LDAP directory.
Definition base.h:180
@ LDAP_REQUEST_DELETE
A deletion of an LDAP entity.
Definition base.h:182
@ LDAP_REQUEST_EXTENDED
An extended LDAP operation.
Definition base.h:183
int clientctrls_cnt
Number of client controls associated with the handle.
Definition base.h:350
fr_pair_list_t * bind_trigger_args
Passed to trigger request for bind trunks.
Definition base.h:391
int fr_ldap_control_add_client(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit)
Add a clientctrl to a connection handle.
Definition control.c:117
fr_ldap_connection_t * ldap_conn
LDAP connection this query is running on.
Definition base.h:460
LDAPControl ** serverctrls
Controls to pass to the server.
Definition base.h:500
char const * realm
Kerberos realm.
Definition base.h:131
char * orig
Text representation of filter for debug messages,.
Definition base.h:568
fr_ldap_sasl_t admin_sasl
SASL parameters used when binding as the admin.
Definition base.h:243
fr_ldap_rcode_t fr_ldap_delete_async(int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *dn, LDAPControl **serverctrls, LDAPControl **clientctrls)
Modify something in the LDAP directory.
Definition base.c:860
fr_ldap_result_code_t
LDAP query result codes.
Definition base.h:189
@ LDAP_RESULT_EXCESS_REFERRALS
The referral chain took too many hops.
Definition base.h:198
@ LDAP_RESULT_REFERRAL_FAIL
Initial results indicated a referral was needed but the referral could not be followed.
Definition base.h:196
@ LDAP_RESULT_TIMEOUT
The query timed out.
Definition base.h:193
@ LDAP_RESULT_ERROR
A general error occurred.
Definition base.h:192
@ LDAP_RESULT_SUCCESS
Successfully got LDAP results.
Definition base.h:191
@ LDAP_RESULT_PENDING
Result not yet returned.
Definition base.h:190
@ LDAP_RESULT_NO_RESULT
No results returned.
Definition base.h:195
@ LDAP_RESULT_BAD_DN
The requested DN does not exist.
Definition base.h:194
@ LDAP_RESULT_MISSING_REFERRAL
A referral was indicated but no URL was provided.
Definition base.h:199
fr_hash_table_t * naming_contexts_ht
For resolving DNs to the naming context containing them.
Definition base.h:220
fr_ldap_query_t * fr_ldap_modify_alloc(TALLOC_CTX *ctx, char const *dn, LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls)
Allocate a new LDAP modify object.
Definition base.c:1077
bool found
The attribute was found in the entry.
Definition base.h:973
ldap_filter_type_t filter_type
Type of this filter node.
Definition base.h:567
fr_ldap_thread_trunk_t * fr_thread_ldap_bind_trunk_get(fr_ldap_thread_t *thread)
Find the thread specific trunk to use for LDAP bind auths.
int fr_ldap_directory_discover_async(fr_ldap_connection_t *c)
Send a rootDSE search on a connection being established.
Definition directory.c:404
bool cleartext_password
Whether the server will return the user's plaintext password.
Definition base.h:209
int msgid
Last msgid. Only used when binding as admin user.
Definition base.h:519
static int fr_ldap_berval_strncasecmp(struct berval *value, char const *str, size_t strlen)
Compare a berval with a C string of a known length using case insensitive comparison.
Definition base.h:680
char const * tls_ca_file
Sets the full path to a CA certificate (used to validate the certificate the server presents).
Definition base.h:272
BerElement * ber
Cursor over the entry.
Definition base.h:969
bool chase_referrals_unset
If true, use the OpenLDAP defaults for chase_referrals.
Definition base.h:253
#define LDAP_MAP_RESERVED
Number of additional items to allocate in expanded attribute name arrays.
Definition base.h:98
char const ** server_str
Server set in the config.
Definition base.h:235
int fr_ldap_map_expand(TALLOC_CTX *ctx, fr_ldap_map_exp_t *expanded, request_t *request, map_list_t const *maps, char const *generic_attr, char const *check_attr, char const *fallthrough_attr)
Expand values in an attribute map where needed.
Definition map.c:321
trunk_state_t fr_thread_ldap_trunk_state(fr_ldap_thread_t *thread, char const *uri, char const *bind_dn)
Lookup the state of a thread specific LDAP connection trunk for a specific URI / bind DN.
#define LDAP_MAX_CONTROLS
Maximum number of client/server controls.
Definition base.h:94
char const * name
Name of the module that created this connection.
Definition base.h:232
trunk_conf_t * bind_trunk_conf
Trunk config for bind auth trunk.
Definition base.h:386
fr_time_delta_t reconnection_delay
How long to wait before attempting to reconnect.
Definition base.h:321
uint16_t referral_depth
How many referrals to chase.
Definition base.h:257
int fr_ldap_directory_result_parse(fr_ldap_directory_t *directory, LDAP *handle, LDAPMessage *result, char const *name)
Definition directory.c:68
fr_time_delta_t srv_timelimit
How long the server should spent on a single request (also bounded by value on the server).
Definition base.h:305
fr_ldap_query_t * fr_ldap_search_alloc(TALLOC_CTX *ctx, char const *base_dn, int scope, char const *filter, char const *const *attrs, LDAPControl **serverctrls, LDAPControl **clientctrls)
Allocate a new search object.
Definition base.c:1051
int fr_ldap_start_tls_async(fr_ldap_connection_t *c, LDAPControl **serverctrls, LDAPControl **clientctrls)
Install I/O handlers for Start TLS negotiation.
Definition start_tls.c:223
void * uctx
User data associated with the handle.
Definition base.h:364
void fr_ldap_entry_dump(LDAPMessage *entry)
Dump out the contents of an LDAPMessage.
Definition util.c:1221
int fr_ldap_parse_url_extensions(LDAPControl **sss, size_t sss_len, char *extensions[])
Parse a subset (just server side sort and virtual list view for now) of LDAP URL extensions.
Definition util.c:373
fr_ldap_sync_type_t
Definition base.h:157
@ FR_LDAP_SYNC_NONE
No support for LDAP sync.
Definition base.h:158
@ FR_LDAP_SYNC_ACTIVE_DIRECTORY
Directory supports AD style persistent search.
Definition base.h:160
@ FR_LDAP_SYNC_PERSISTENT_SEARCH
Directory supports persistent search.
Definition base.h:161
@ FR_LDAP_SYNC_RFC4533
Directory supports RFC 4533.
Definition base.h:159
connection_state_t fr_ldap_connection_init(void **h, connection_t *conn, void *uctx)
Initialise a standalone LDAP connection.
Definition connection.c:391
unlang_action_t fr_ldap_trunk_extended(TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *reqoid, struct berval *reqdata, LDAPControl **serverctrls, LDAPControl **clientctrls)
Run an async LDAP "extended operation" query on a trunk connection.
Definition base.c:902
LDAPMessage * result
Head of LDAP results list.
Definition base.h:471
fr_event_list_t * el
Thread event list for callbacks / timeouts.
Definition base.h:387
fr_ldap_directory_t * directory
The type of directory we're connected to.
Definition base.h:407
fr_ldap_connection_t * fr_ldap_connection_alloc(TALLOC_CTX *ctx)
Allocate our ldap connection handle layer.
Definition connection.c:258
LDAPControl * control
LDAP control.
Definition base.h:135
unlang_action_t fr_ldap_trunk_search(TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *base_dn, int scope, char const *filter, char const *const *attrs, LDAPControl **serverctrls, LDAPControl **clientctrls)
Run an async search LDAP query on a trunk connection.
Definition base.c:718
char const * rmech
Mech we're continuing with.
Definition base.h:521
char const * password
Bind password for referral connection.
Definition base.h:488
char const * tls_min_version_str
Minimum TLS version.
Definition base.h:288
bool discovered
A rootDSE response has been parsed into these fields.
Definition base.h:223
LDAPControl ** serverctrls
Controls to pass to the server.
Definition base.h:516
uint16_t port
Port to use when binding to the server.
Definition base.h:237
void fr_ldap_timeout_debug(request_t *request, fr_ldap_connection_t const *conn, fr_time_delta_t timeout, char const *prefix)
Prints information to the debug log on the current timeout settings.
Definition base.c:152
fr_ldap_thread_trunk_t * bind_trunk
LDAP trunk used for bind auths.
Definition base.h:388
int fr_ldap_connection_timeout_reset(fr_ldap_connection_t const *conn)
Definition connection.c:437
char const * version_str
As returned from the vendorVersion attribute in the rootDSE.
Definition base.h:205
char const * bind_dn
of the user, may be NULL to bind anonymously.
Definition base.h:498
void(* fr_ldap_result_parser_t)(LDAP *handle, fr_ldap_query_t *query, LDAPMessage *head, void *rctx)
Definition base.h:417
trunk_t * trunk
Connection trunk.
Definition base.h:408
fr_pair_list_t * trigger_args
Passed to trigger request for normal trunks.
Definition base.h:390
fr_ldap_thread_t * thread
This bind is being run by.
Definition base.h:618
fr_ldap_thread_trunk_t * ttrunk
Trunk this referral should use.
Definition base.h:489
connection_t * conn
Connection state handle.
Definition base.h:355
fr_ldap_referral_t * referral
Referral actually being followed.
Definition base.h:467
size_t fr_ldap_tls_require_cert_len
Definition base.c:84
unlang_action_t fr_ldap_bind_auth_async(unlang_result_t *p_result, request_t *request, fr_ldap_thread_t *thread, char const *bind_dn, char const *password)
Initiate an async LDAP bind for authentication.
Definition bind.c:328
fr_timer_t * ev
Event for timing out the query.
Definition base.h:462
fr_table_num_sorted_t const fr_ldap_scope[]
Definition base.c:69
TALLOC_CTX * ctx
Context to allocate new attributes in.
Definition base.h:375
fr_rb_tree_t * binds
Tree of outstanding bind auths.
Definition base.h:389
int fr_ldap_connection_configure(fr_ldap_connection_t *c, fr_ldap_config_t const *config)
Allocate and configure a new connection.
Definition connection.c:67
struct berval * fr_ldap_value_iter_alloc(int *err, fr_ldap_value_iter_t **out, TALLOC_CTX *ctx, LDAP *handle, LDAPMessage *entry, char const *attr)
Allocate a value iterator, released when the iterator is freed.
Definition util.c:623
char const * dn_attr
Attribute to match an entry's DN in a search filter.
Definition base.h:214
uint32_t ldap_debug
LDAP debug level.
Definition base.h:330
connection_state_t fr_ldap_trunk_connection_init(void **h, connection_t *conn, void *uctx)
Initialise an LDAP trunk connection.
Definition connection.c:408
fr_ldap_query_t * fr_ldap_extended_alloc(TALLOC_CTX *ctx, char const *reqiod, struct berval *reqdata, LDAPControl **serverctrls, LDAPControl **clientctrls)
Allocate a new LDAP extended operations object.
Definition base.c:1100
int(* filter_attr_check_t)(char const *attr, void *uctx)
Definition base.h:1031
fr_rb_node_t node
Entry in the tree of outstanding bind requests.
Definition base.h:617
fr_ldap_bind_type_t type
type of bind.
Definition base.h:622
char const ** naming_contexts
NULL terminated array of databases served by this directory.
Definition base.h:218
int fr_ldap_referral_next(fr_ldap_thread_t *thread, request_t *request, fr_ldap_query_t *query)
Follow an alternative LDAP referral.
Definition referral.c:310
char const * password
of the user, may be NULL if no password is specified.
Definition base.h:499
ldap_supported_extension_t
Definition base.h:122
@ LDAP_EXT_BINDPW
Specifies the password for an LDAP bind.
Definition base.h:125
@ LDAP_EXT_UNSUPPORTED
Unsupported extension.
Definition base.h:123
@ LDAP_EXT_BINDNAME
Specifies the user DN or name for an LDAP bind.
Definition base.h:124
fr_time_delta_t idle_timeout
How long to wait before closing unused connections.
Definition base.h:323
fr_ldap_directory_type_t type
Canonical server implementation.
Definition base.h:207
fr_ldap_request_type_t type
What type of query this is.
Definition base.h:451
int fr_ldap_init(void)
Initialise libldap and check library versions.
Definition base.c:1190
fr_ldap_rcode_t
Codes returned by fr_ldap internal functions.
Definition base.h:585
@ LDAP_PROC_CONTINUE
Operation is in progress.
Definition base.h:587
@ LDAP_PROC_SUCCESS
Operation was successful.
Definition base.h:588
@ LDAP_PROC_REFERRAL
LDAP server returned referral URLs.
Definition base.h:586
@ LDAP_PROC_TIMEOUT
Operation timed out.
Definition base.h:605
@ LDAP_PROC_ERROR
Unrecoverable library/server error.
Definition base.h:590
@ LDAP_PROC_BAD_CONN
Transitory error, caller should retry the operation with a new connection.
Definition base.h:592
@ LDAP_PROC_NOT_PERMITTED
Operation was not permitted, either current user was locked out in the case of binds,...
Definition base.h:595
@ LDAP_PROC_REJECT
Bind failed, user was rejected.
Definition base.h:599
@ LDAP_PROC_REFRESH_REQUIRED
Don't continue with the current refresh phase, exit, and retry the operation with a NULL cookie.
Definition base.h:607
@ LDAP_PROC_BAD_DN
Specified an invalid object in a bind or search DN.
Definition base.h:601
@ LDAP_PROC_NO_RESULT
Got no results.
Definition base.h:603
LDAPURLDesc * ldap_url
parsed URL for current query if the source of the query was a URL.
Definition base.h:429
char * fr_ldap_filter_afrom_dn_list(TALLOC_CTX *ctx, char const *dn_attr, char const *filter, char const *const *dn_list)
Build a filter matching a set of objects by DN.
Definition util.c:909
Holds arguments for async bind auth requests.
Definition base.h:616
Holds arguments for the async bind operation.
Definition base.h:496
Connection configuration.
Definition base.h:231
Tracks the state of a libldap connection handle.
Definition base.h:342
Result of expanding the RHS of a set of maps.
Definition base.h:371
LDAP query structure.
Definition base.h:425
Parsed LDAP referral structure.
Definition base.h:482
Holds arguments for the async SASL bind operation.
Definition base.h:509
Thread specific structure to manage LDAP trunk connections.
Definition base.h:382
Thread LDAP trunk structure.
Definition base.h:402
State of an in place iteration over an attribute's values.
Definition base.h:968
libldap global configuration data
Definition base.h:329
Structure to hold parsed details of LDAP filters.
Definition base.h:565
Stores all information relating to an event list.
Definition event.c:377
unsigned short uint16_t
unsigned int uint32_t
unsigned char uint8_t
ssize_t fr_slen_t
static const conf_parser_t config[]
Definition base.c:163
The main red black tree structure.
Definition rb.h:71
static char const * name
static int attr_check(CONF_SECTION *conf, tmpl_t *tmpl, char const *name, fr_dict_attr_flags_t *flags)
unlang_action_t fr_ldap_sasl_bind_auth_async(unlang_result_t *p_result, request_t *request, fr_ldap_thread_t *thread, char const *mechs, char const *identity, char const *password, char const *proxy, char const *realm)
Initiate an async SASL LDAP bind for authentication.
Definition sasl.c:504
int fr_ldap_sasl_bind_async(fr_ldap_connection_t *c, char const *mechs, char const *identity, char const *password, char const *proxy, char const *realm, LDAPControl **serverctrls, LDAPControl **clientctrls)
Install I/O handlers for the bind operation.
Definition sasl.c:308
int fr_ldap_sasl_bind_auth_send(fr_ldap_sasl_ctx_t *sasl_ctx, int *msgid, fr_ldap_connection_t *ldap_conn)
Send a SASL LDAP auth bind.
Definition sasl.c:367
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:336
Value pair map.
Definition map.h:77
An element in a lexicographically sorted array of name to num mappings.
Definition table.h:49
A NULL terminated array of strings with an append cursor.
Definition talloc.h:253
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
A timer event.
Definition timer.c:83
Wraps a normal request.
Definition trunk.c:99
Main trunk management handle.
Definition trunk.c:215
trunk_state_t
Definition trunk.h:62
Common configuration parameters for a trunk.
Definition trunk.h:234
static fr_event_list_t * el
static fr_slen_t head
Definition xlat.h:420
void fr_value_box_memdup_shallow(fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, size_t len, bool tainted)
Assign a buffer to a box, but don't copy it.
Definition value.c:5163
void fr_value_box_bstrndup_shallow(fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, size_t len, bool tainted)
Assign a string to to a fr_value_box_t.
Definition value.c:4925
static size_t char fr_sbuff_t size_t inlen
Definition value.h:1030
int nonnull(2, 5))
static size_t char ** out
Definition value.h:1030