The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
base.h
Go to the documentation of this file.
1#pragma once
2/**
3 * $Id: dc5ea33a2901246dc9b59174ae7c0ff565955ad2 $
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_ATTR_STR_LEN 256 //!< Maximum length of an xlat expanded LDAP attribute.
109#define LDAP_MAX_FILTER_STR_LEN 1024 //!< Maximum length of an xlat expanded filter.
110#define LDAP_MAX_DN_STR_LEN 1024 //!< Maximum length of an xlat expanded DN.
111
112#define LDAP_VIRTUAL_DN_ATTR "dn" //!< 'Virtual' attribute which maps to the DN of the object.
113
114#define LDAP_SERVER_NOTIFICATION_OID "1.2.840.113556.1.4.528" //!< OID of Active Directory control for
115 //!< persistent search.
116#define LDAP_SERVER_SHOW_DELETED_OID "1.2.840.113556.1.4.417" //!< OID of Active Directory control which
117 //!< enables searching for deleted objects.
118#define LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803" //!< OID of bit-wise AND LDAP match rule
119#define LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804" //!< OID of bit-wise OR LDAP match rule
120
121typedef enum : uint8_t {
122 LDAP_EXT_UNSUPPORTED, //!< Unsupported extension.
123 LDAP_EXT_BINDNAME, //!< Specifies the user DN or name for an LDAP bind.
124 LDAP_EXT_BINDPW, //!< Specifies the password for an LDAP bind.
126
127typedef struct {
128 char const *mech; //!< SASL mech(s) to try.
129 char const *proxy; //!< Identity to proxy.
130 char const *realm; //!< Kerberos realm.
132
133typedef struct {
134 LDAPControl *control; //!< LDAP control.
135 bool freeit; //!< Whether the control should be freed after
136 //!< we've finished using it.
138
139typedef enum : uint8_t {
140 FR_LDAP_DIRECTORY_UNKNOWN = 0, //!< We can't determine the directory server.
141
142 FR_LDAP_DIRECTORY_ACTIVE_DIRECTORY, //!< Directory server is Active Directory.
143 FR_LDAP_DIRECTORY_EDIRECTORY, //!< Directory server is eDir.
144 FR_LDAP_DIRECTORY_IBM, //!< Directory server is IBM.
145 FR_LDAP_DIRECTORY_NETSCAPE, //!< Directory server is Netscape.
146 FR_LDAP_DIRECTORY_OPENLDAP, //!< Directory server is OpenLDAP.
147 FR_LDAP_DIRECTORY_ORACLE_INTERNET_DIRECTORY, //!< Directory server is Oracle Internet Directory.
148 FR_LDAP_DIRECTORY_ORACLE_UNIFIED_DIRECTORY, //!< Directory server is Oracle Unified Directory.
149 FR_LDAP_DIRECTORY_ORACLE_VIRTUAL_DIRECTORY, //!< Directory server is Oracle Virtual Directory.
150 FR_LDAP_DIRECTORY_SUN_ONE_DIRECTORY, //!< Directory server is Sun One Directory.
151 FR_LDAP_DIRECTORY_SIEMENS_AG, //!< Directory server is Siemens AG.
152 FR_LDAP_DIRECTORY_UNBOUND_ID, //!< Directory server is Unbound ID
153 FR_LDAP_DIRECTORY_SAMBA //!< Directory server is Samba.
155
156typedef enum : uint8_t {
157 FR_LDAP_SYNC_NONE = 0, //!< No support for LDAP sync
158 FR_LDAP_SYNC_RFC4533, //!< Directory supports RFC 4533
159 FR_LDAP_SYNC_ACTIVE_DIRECTORY, //!< Directory supports AD style persistent search.
160 FR_LDAP_SYNC_PERSISTENT_SEARCH //!< Directory supports persistent search
162
163/** LDAP connection handle states
164 *
165 */
166typedef enum : uint8_t {
167 FR_LDAP_STATE_INIT = 0, //!< Connection uninitialised.
168 FR_LDAP_STATE_START_TLS, //!< TLS is being negotiated.
169 FR_LDAP_STATE_BIND, //!< Connection is being bound.
170 FR_LDAP_STATE_DISCOVER, //!< Directory capabilities are being read from the rootDSE.
171 FR_LDAP_STATE_RUN, //!< Connection is muxing/demuxing requests.
172 FR_LDAP_STATE_ERROR //!< Connection is in an error state.
174
175/** Types of LDAP requests
176 *
177 */
178typedef enum : uint8_t {
179 LDAP_REQUEST_SEARCH = 1, //!< A lookup in an LDAP directory
180 LDAP_REQUEST_MODIFY, //!< A modification to an LDAP entity
181 LDAP_REQUEST_DELETE, //!< A deletion of an LDAP entity
182 LDAP_REQUEST_EXTENDED //!< An extended LDAP operation
184
185/** LDAP query result codes
186 *
187 */
188typedef enum : int8_t {
189 LDAP_RESULT_PENDING = 1, //!< Result not yet returned
190 LDAP_RESULT_SUCCESS = 0, //!< Successfully got LDAP results
191 LDAP_RESULT_ERROR = -1, //!< A general error occurred
192 LDAP_RESULT_TIMEOUT = -2, //!< The query timed out
193 LDAP_RESULT_BAD_DN = -3, //!< The requested DN does not exist
194 LDAP_RESULT_NO_RESULT = -4, //!< No results returned
195 LDAP_RESULT_REFERRAL_FAIL = -5, //!< Initial results indicated a referral was needed
196 ///< but the referral could not be followed
197 LDAP_RESULT_EXCESS_REFERRALS = -6, //!< The referral chain took too many hops
198 LDAP_RESULT_MISSING_REFERRAL = -7, //!< A referral was indicated but no URL was provided
200
201typedef struct {
202 char const *vendor_str; //!< As returned from the vendorName attribute in the
203 ///< rootDSE.
204 char const *version_str; //!< As returned from the vendorVersion attribute in the
205 ///< rootDSE.
206 fr_ldap_directory_type_t type; ///< Canonical server implementation.
207
208 bool cleartext_password; //!< Whether the server will return the user's plaintext
209 ///< password.
210
211 fr_ldap_sync_type_t sync_type; //!< What kind of LDAP sync this directory supports.
212
213 char const *dn_attr; //!< Attribute to match an entry's DN in a search filter.
214 ///< Defaults to RFC 5020 entryDN, distinguishedName
215 ///< on Active Directory and Samba.
216
217 char const **naming_contexts; //!< NULL terminated array of databases
218 ///< served by this directory.
219 fr_hash_table_t *naming_contexts_ht; //!< For resolving DNs to the naming context
220 ///< containing them.
221
222 bool discovered; //!< A rootDSE response has been parsed into these fields.
224
225/** Connection configuration
226 *
227 * Must not be passed into functions except via the connection handle
228 * this avoids problems with not using the connection pool configuration.
229 */
230typedef struct {
231 char const *name; //!< Name of the module that created this connection.
232
233 char *server; //!< Initial server to bind to.
234 char const **server_str; //!< Server set in the config.
235
236 uint16_t port; //!< Port to use when binding to the server.
237
238 char const *admin_identity; //!< Identity we bind as when we need to query the LDAP
239 ///< directory.
240 char const *admin_password; //!< Password used in administrative bind.
241
242 fr_ldap_sasl_t admin_sasl; //!< SASL parameters used when binding as the admin.
243
244 const char *sasl_secprops; //!< SASL Security Properties to set.
245
246 int dereference; //!< libldap value specifying dereferencing behaviour.
247 char const *dereference_str; //!< When to dereference (never, searching, finding, always)
248
249 bool chase_referrals; //!< If the LDAP server returns a referral to another server
250 ///< or point in the tree, follow it, establishing new
251 ///< connections and binding where necessary.
252 bool chase_referrals_unset; //!< If true, use the OpenLDAP defaults for chase_referrals.
253
254 bool use_referral_credentials; //!< If true use credentials from the referral URL.
255
256 uint16_t referral_depth; //!< How many referrals to chase
257
258 bool rebind; //!< If use_referral_credentials is false, controls whether we
259 ///< bind as our admin credentials (true) or anonymously (false)
260 ///< when connecting to a different server to follow a referral
261
262 /*
263 * TLS items.
264 */
266
267 bool start_tls; //!< Send the Start TLS message to the LDAP directory
268 ///< to start encrypted communications using the standard
269 ///< LDAP port.
270
271 char const *tls_ca_file; //!< Sets the full path to a CA certificate (used to validate
272 ///< the certificate the server presents).
273
274 char const *tls_ca_path; //!< Sets the path to a directory containing CA certificates.
275
276 char const *tls_certificate_file; //!< Sets the path to the public certificate file we present
277 ///< to the servers.
278
279 char const *tls_private_key_file; //!< Sets the path to the private key for our public
280 ///< certificate.
281
282 char const *tls_require_cert_str; //!< Sets requirements for validating the certificate the
283 ///< server presents.
284
285 int tls_require_cert; //!< OpenLDAP constant representing the require cert string.
286
287 char const *tls_min_version_str; //!< Minimum TLS version
289
290 /*
291 * For keep-alives.
292 */
293 fr_time_delta_t keepalive_idle; //!< Number of seconds a connections needs to remain idle
294 //!< before TCP starts sending keepalive probes.
295
296 uint32_t keepalive_probes; //!< Number of missed timeouts before the connection is
297 ///< dropped.
298
299 fr_time_delta_t keepalive_interval; //!< Interval between keepalive probes.
300
301 /*
302 * Search timelimits
303 */
304 fr_time_delta_t srv_timelimit; //!< How long the server should spent on a single request
305 ///< (also bounded by value on the server).
306
307 fr_time_delta_t idle_timeout; //!< How long to wait before closing unused connections.
309
310/** libldap global configuration data
311 *
312 */
313typedef struct {
314 uint32_t ldap_debug; //!< LDAP debug level
315 char const *tls_random_file; //!< Path to the ramdon file if /dev/random and /dev/urandom
316 //!< are unavailable
318
320
322
323/** Tracks the state of a libldap connection handle
324 *
325 */
326typedef struct {
327 LDAP *handle; //!< libldap handle.
328
329 fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS + 1]; //!< Server controls to use for all operations
330 ///< with this handle.
331 fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS + 1]; //!< Client controls to use for all operations
332 ///< with this handle.
333 int serverctrls_cnt; //!< Number of server controls associated with the handle.
334 int clientctrls_cnt; //!< Number of client controls associated with the handle.
335
336 fr_ldap_directory_t *directory; //!< The type of directory we're connected to.
337
338 fr_ldap_config_t const *config; //!< rlm_ldap connection configuration.
339 connection_t *conn; //!< Connection state handle.
340
341 fr_ldap_state_t state; //!< LDAP connection state machine.
342
343 int fd; //!< File descriptor for this connection.
344
345 fr_rb_tree_t *queries; //!< Outstanding queries on this connection
346 fr_dlist_head_t refs; //!< Replied to queries still referencing this connection.
347
348 void *uctx; //!< User data associated with the handle.
350
351/** Result of expanding the RHS of a set of maps
352 *
353 * Used to store the array of attributes we'll be querying for.
354 */
355typedef struct {
356 map_list_t const *maps; //!< Head of list of maps we expanded the RHS of.
357 char const *attrs[LDAP_MAX_ATTRMAP + LDAP_MAP_RESERVED + 1]; //!< Reserve some space for access attributes
358 //!< and NULL termination.
359 TALLOC_CTX *ctx; //!< Context to allocate new attributes in.
360 int count; //!< Index on next free element.
362
363/** Thread specific structure to manage LDAP trunk connections.
364 *
365 */
366typedef struct {
367 fr_rb_tree_t *trunks; //!< Tree of LDAP trunks used by this thread
368 fr_ldap_config_t *config; //!< Module instance config
369 trunk_conf_t *trunk_conf; //!< Module trunk config
370 trunk_conf_t *bind_trunk_conf; //!< Trunk config for bind auth trunk
371 fr_event_list_t *el; //!< Thread event list for callbacks / timeouts
372 fr_ldap_thread_trunk_t *bind_trunk; //!< LDAP trunk used for bind auths
373 fr_rb_tree_t *binds; //!< Tree of outstanding bind auths
374 fr_pair_list_t *trigger_args; //!< Passed to trigger request for normal trunks
375 fr_pair_list_t *bind_trigger_args; //!< Passed to trigger request for bind trunks
377
378/** Thread LDAP trunk structure
379 *
380 * One fr_ldap_thread_trunk_t will be allocated for each destination a thread needs
381 * to create an LDAP trunk connection to.
382 *
383 * Used to hold config regarding the LDAP connection and associate pending queries
384 * with the trunk they are running on.
385 */
387 fr_rb_node_t node; //!< Entry in the tree of connections
388 char const *uri; //!< Server URI for this connection
389 char const *bind_dn; //!< DN connection is bound as
390 fr_ldap_config_t config; //!< Config used for this connection
391 fr_ldap_directory_t *directory; //!< The type of directory we're connected to.
392 trunk_t *trunk; //!< Connection trunk
393 fr_ldap_thread_t *t; //!< Thread this connection is associated with
394 fr_timer_t *ev; //!< Event to close the thread when it has been idle.
396
398
400
401typedef void (*fr_ldap_result_parser_t)(LDAP *handle, fr_ldap_query_t *query, LDAPMessage *head, void *rctx);
402
403/** LDAP query structure
404 *
405 * Used to hold the elements of an LDAP query and track its progress.
406 * libldap structures will be freed by the talloc destructor.
407 * The same structure is used both for search queries and modifications
408 */
410 fr_rb_node_t node; //!< Entry in the tree of outstanding queries.
411 fr_dlist_t entry; //!< Entry in the list of connection references.
412
413 LDAPURLDesc *ldap_url; //!< parsed URL for current query if the source
414 ///< of the query was a URL.
415
416 char const *dn; //!< Base DN for searches, DN for modifications.
417
418 /** Fields which are unique to each type of query
419 *
420 * @note Delete only uses the DN field, as it operates at an object level.
421 */
422 union {
423 struct {
424 char const **attrs; //!< Attributes being requested in a search.
425 int scope; //!< Search scope.
426 char const *filter; //!< Filter for search.
427 } search;
428 struct {
429 char const *reqoid; //!< OID of extended operation to perform.
430 struct berval *reqdata; //!< Data required for the request.
431 } extended;
432 LDAPMod **mods; //!< Changes to be applied if this query is a modification.
433 };
434
435 fr_ldap_request_type_t type; //!< What type of query this is.
436
437 fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS]; //!< Server controls specific to this query.
438 fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS]; //!< Client controls specific to this query.
439
440 int msgid; //!< The unique identifier for this query.
441 ///< Uniqueness is only per connection.
442
443 trunk_request_t *treq; //!< Trunk request this query is associated with
444 fr_ldap_connection_t *ldap_conn; //!< LDAP connection this query is running on.
445
446 char **referral_urls; //!< Referral results to follow
447 fr_dlist_head_t referrals; //!< List of parsed referrals
448 uint16_t referral_depth; //!< How many referrals we have followed
449 fr_ldap_referral_t *referral; //!< Referral actually being followed
450
451 fr_ldap_result_parser_t parser; //!< Custom results parser.
452
453 LDAPMessage *result; //!< Head of LDAP results list.
454
455 fr_ldap_result_code_t ret; //!< Result code
456};
457
458/** Parsed LDAP referral structure
459 *
460 * When LDAP servers respond with a referral, it is parsed into one or more fr_ldap_referral_t
461 * and kept until the referral has been followed.
462 * Avoids repeated parsing of the referrals as provided by libldap.
463 */
464typedef struct fr_ldap_referral_s {
465 fr_dlist_t entry; //!< Entry in list of possible referrals
466 fr_ldap_query_t *query; //!< Query this referral relates to
467 LDAPURLDesc *referral_url; //!< URL for the referral
468 char *host_uri; //!< Host URI used for referral connection
469 char const *identity; //!< Bind identity for referral connection
470 char const *password; //!< Bind password for referral connection
471 fr_ldap_thread_trunk_t *ttrunk; //!< Trunk this referral should use
472 request_t *request; //!< Request this referral relates to
474
475/** Holds arguments for the async bind operation
476 *
477 */
478typedef struct {
479 fr_ldap_connection_t *c; //!< to bind. Only used when binding as admin user.
480 char const *bind_dn; //!< of the user, may be NULL to bind anonymously.
481 char const *password; //!< of the user, may be NULL if no password is specified.
482 LDAPControl **serverctrls; //!< Controls to pass to the server.
483 LDAPControl **clientctrls; //!< Controls to pass to the client (library).
484
485 int msgid; //!< Of the bind operation. Only used when binding as admin.
487
488/** Holds arguments for the async SASL bind operation
489 *
490 */
491typedef struct {
492 fr_ldap_connection_t *c; //!< to bind. Only used when binding as admin user.
493 char const *mechs; //!< SASL mechanisms to run
494 char const *identity; //!< of the user.
495 char const *password; //!< of the user, may be NULL if no password is specified.
496 char const *proxy; //!< Proxy identity, may be NULL in which case identity is used.
497 char const *realm; //!< SASL realm (may be NULL).
498 LDAPControl **serverctrls; //!< Controls to pass to the server.
499 LDAPControl **clientctrls; //!< Controls to pass to the client (library).
500
501 int msgid; //!< Last msgid. Only used when binding as admin user.
502 LDAPMessage *result; //!< Previous result.
503 char const *rmech; //!< Mech we're continuing with.
505
506typedef enum : uint8_t {
508#ifdef WITH_SASL
509 LDAP_BIND_SASL
510#endif
512
514
515/** Types of parsed LDAP filter nodes
516 */
517typedef enum : uint8_t {
518 LDAP_FILTER_NODE = 0, //!< The filter node is an individual one
519 //!< to be evaluated against an attribute.
520 LDAP_FILTER_GROUP //!< The filter node is a parent of a group
521 //!< which will be combined using a logical operator.
523
524/** Logical operators for use in LDAP filters
525 */
531
532/** Operators for use in LDAP filters
533 */
534typedef enum : uint8_t {
535 LDAP_FILTER_OP_UNSET = 0, //!< Attribute not set yet
536 LDAP_FILTER_OP_EQ, //!< Attribute equals value
537 LDAP_FILTER_OP_SUBSTR, //!< Attribute matches string with wildcards
538 LDAP_FILTER_OP_PRESENT, //!< Attribute present
539 LDAP_FILTER_OP_GE, //!< Attribute greater than or equal to value
540 LDAP_FILTER_OP_LE, //!< Attribute less than or equal to value
541 LDAP_FILTER_OP_BIT_AND, //!< Bitwise AND comparison
542 LDAP_FILTER_OP_BIT_OR //!< Bitwise OR comparison
544
545/** Structure to hold parsed details of LDAP filters
546 */
548 fr_dlist_t entry; //!< Entry in the list of filter nodes.
549 ldap_filter_type_t filter_type; //!< Type of this filter node.
550 char *orig; //!< Text representation of filter for debug messages,
551 union {
552 struct {
553 ldap_filter_logic_t logic_op; //!< Logical operator for this group.
554 fr_dlist_head_t children; //!< List of child nodes in this group.
555 };
556 struct {
557 char *attr; //!< Attribute for the filter node.
558 ldap_filter_op_t op; //!< Operator to be used for comparison.
559 fr_value_box_t *value; //!< Value to compare with.
560 };
561 };
562};
563
564/** Codes returned by fr_ldap internal functions
565 *
566 */
567typedef enum : int8_t {
568 LDAP_PROC_PENDING = 3, //!< fr_ldap_result() was polling and hasn't read the final message
569 //!< yet. Call it again when the fd is next readable.
570 LDAP_PROC_REFERRAL = 2, //!< LDAP server returned referral URLs.
571 LDAP_PROC_CONTINUE = 1, //!< Operation is in progress.
572 LDAP_PROC_SUCCESS = 0, //!< Operation was successful.
573
574 LDAP_PROC_ERROR = -1, //!< Unrecoverable library/server error.
575
576 LDAP_PROC_BAD_CONN = -2, //!< Transitory error, caller should retry the operation
577 //!< with a new connection.
578
579 LDAP_PROC_NOT_PERMITTED = -3, //!< Operation was not permitted, either current user was
580 //!< locked out in the case of binds, or has insufficient
581 //!< access.
582
583 LDAP_PROC_REJECT = -4, //!< Bind failed, user was rejected.
584
585 LDAP_PROC_BAD_DN = -5, //!< Specified an invalid object in a bind or search DN.
586
587 LDAP_PROC_NO_RESULT = -6, //!< Got no results.
588
589 LDAP_PROC_TIMEOUT = -7, //!< Operation timed out.
590
591 LDAP_PROC_REFRESH_REQUIRED = -8 //!< Don't continue with the current refresh phase,
592 //!< exit, and retry the operation with a NULL cookie.
594
595/** Holds arguments for async bind auth requests
596 *
597 * Used when LDAP binds are being used to authenticate users, rather than admin binds.
598 * Allows tracking of multiple bind requests on a single connection.
599 */
600typedef struct {
601 fr_rb_node_t node; //!< Entry in the tree of outstanding bind requests.
602 fr_ldap_thread_t *thread; //!< This bind is being run by.
603 trunk_request_t *treq; //!< Trunk request this bind is associated with.
604 int msgid; //!< libldap msgid for this bind.
605 request_t *request; //!< this bind relates to.
606 fr_ldap_bind_type_t type; //!< type of bind.
607 union {
608 fr_ldap_bind_ctx_t *bind_ctx; //!< User data for simple binds.
609 fr_ldap_sasl_ctx_t *sasl_ctx; //!< User data for SASL binds.
610 };
611 fr_ldap_rcode_t ret; //!< Return code of bind operation.
613
614/*
615 * Tables for resolving strings to LDAP constants
616 */
619
623extern size_t fr_ldap_dereference_len;
625extern size_t fr_ldap_scope_len;
627extern size_t fr_ldap_tls_require_cert_len;
628
629/** Inline function to copy pointers from a berval to a valuebox
630 *
631 * @note This results in a shallow copy of the berval, so if the berval is freed
632 * the value box becomes invalidated.
633 *
634 * @param[out] value to write berval values to.
635 * @param[in] berval to copy pointers/lengths from.
636 */
637static inline void fr_ldap_berval_to_value_shallow(fr_value_box_t *value, struct berval *berval)
638{
639 fr_value_box_memdup_shallow(value, NULL, (uint8_t *)berval->bv_val, berval->bv_len, true);
640}
641
642/** Inline function to copy pointer from a berval to a string value box
643 *
644 * Useful for printing contents of bervals known to contain strings in DEBUG output since
645 * they are not NULL terminated.
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 value to.
651 * @param[in] berval top copy pointer / length from.
652 */
653static inline void fr_ldap_berval_to_value_str_shallow(fr_value_box_t *value, struct berval *berval)
654{
655 fr_value_box_bstrndup_shallow(value, NULL, berval->bv_val, berval->bv_len, true);
656}
657
658/** Compare a berval with a C string of a known length using case insensitive comparison
659 *
660 * @param[in] value berval.
661 * @param[in] str String to compare with value.
662 * @param[in] strlen Number of characters of str to compare.
663 */
664static inline int fr_ldap_berval_strncasecmp(struct berval *value, char const *str, size_t strlen)
665{
666 size_t i;
667 if (strlen != value->bv_len) return CMP(strlen, value->bv_len);
668
669 for (i = 0; i < strlen; i++) {
670 if (tolower((uint8_t)value->bv_val[i]) != tolower((uint8_t)str[i])) return CMP(value->bv_val[i], str[i]);
671 }
672
673 return 0;
674}
675
676/** Compare two ldap trunk structures on connection URI / DN
677 *
678 * @param[in] one first connection to compare.
679 * @param[in] two second connection to compare.
680 * @return CMP(one, two)
681 */
682static inline fr_cmp_ret_t fr_ldap_trunk_cmp(void const *one, void const *two)
683{
684 fr_ldap_thread_trunk_t const *a = one, *b = two;
685 fr_cmp_ret_t uricmp = CMP(strcmp(a->uri, b->uri), 0);
686
687 if (uricmp !=0) return uricmp;
688 if (!a->bind_dn || !b->bind_dn) return CMP(a->bind_dn, b->bind_dn);
689 return CMP(strcmp(a->bind_dn, b->bind_dn), 0);
690}
691
692/** Compare two ldap query structures on msgid
693 *
694 * @param[in] one first query to compare.
695 * @param[in] two second query to compare.
696 * @return CMP(one,two)
697 */
698static inline fr_cmp_ret_t fr_ldap_query_cmp(void const *one, void const *two)
699{
700 fr_ldap_query_t const *a = one, *b = two;
701
702 return CMP(a->msgid, b->msgid);
703}
704
705/** Compare two ldap bind auth structures on msgid
706 *
707 * @param[in] one first bind request to compare.
708 * @param[in] two second bind request to compare.
709 * @return CMP(one,two)
710 */
711static inline fr_cmp_ret_t fr_ldap_bind_auth_cmp(void const *one, void const *two)
712{
713 fr_ldap_bind_auth_ctx_t const *a = one, *b = two;
714
715 return CMP(a->msgid, b->msgid);
716}
717
719 char const *base_dn, int scope, char const *filter, char const * const * attrs,
720 LDAPControl **serverctrls, LDAPControl **clientctrls);
721
722fr_ldap_query_t *fr_ldap_modify_alloc(TALLOC_CTX *ctx, char const *dn,
723 LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls);
724
725fr_ldap_query_t *fr_ldap_extended_alloc(TALLOC_CTX *ctx, char const *reqiod, struct berval *reqdata,
726 LDAPControl **serverctrls, LDAPControl **clientctrls);
727
730 char const *base_dn, int scope, char const *filter, char const * const *attrs,
731 LDAPControl **serverctrls, LDAPControl **clientctrls);
732
735 char const *dn, LDAPMod *mods[],
736 LDAPControl **serverctrls, LDAPControl **clientctrls);
737
740 char const *reqoid, struct berval *reqdata,
741 LDAPControl **serverctrls, LDAPControl **clientctrls);
742
743/*
744 * base.c - Wrappers arounds OpenLDAP functions.
745 */
747
749
750size_t fr_ldap_uri_unescape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
751 CC_HINT(nonnull(2,4));
752
753char const *fr_ldap_error_str(fr_ldap_connection_t const *conn);
754
757 char const *dn, int scope, char const *filter, char const * const *attrs,
758 LDAPControl **serverctrls, LDAPControl **clientctrls);
759
761 char const *dn, LDAPMod *mods[],
762 LDAPControl **serverctrls, LDAPControl **clientctrls);
763
765 char const *dn,
766 LDAPControl **serverctrls, LDAPControl **clientctrls);
767
769 char const *reqiod, struct berval *reqdata);
770
771fr_ldap_rcode_t fr_ldap_error_check(LDAPControl ***ctrls, fr_ldap_connection_t const *conn,
772 LDAPMessage *msg, char const *dn);
773
774fr_ldap_rcode_t fr_ldap_result(LDAPMessage **result, LDAPControl ***ctrls,
775 fr_ldap_connection_t const *conn, int msgid, int all,
776 char const *dn,
777 fr_time_delta_t timeout);
778
780
781int fr_ldap_global_config(int debug_level, char const *tls_random_file);
782
783int fr_ldap_init(void);
784
785void fr_ldap_free(void);
786
787/*
788 * control.c - Connection based client/server controls
789 */
790void fr_ldap_control_merge(LDAPControl *serverctrls_out[],
791 LDAPControl *clientctrls_out[],
792 size_t serverctrls_len,
793 size_t clientctrls_len,
795 LDAPControl *serverctrls_in[],
796 LDAPControl *clientctrls_in[]);
797
798int fr_ldap_control_add_server(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit);
799
800int fr_ldap_control_add_client(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit);
801
803
805
806/*
807 * directory.c - Get directory capabilities from the remote server
808 */
809#define LDAP_DIRECTORY_ATTRS { "vendorname", \
810 "vendorversion", \
811 "isGlobalCatalogReady", \
812 "objectClass", \
813 "orcldirectoryversion", \
814 "supportedControl", \
815 "namingContexts", \
816 NULL }
817
819
820char const *fr_ldap_directory_common_base_find(fr_ldap_directory_t const *directory, char const * const *dn_list);
821
822int fr_ldap_directory_result_parse(fr_ldap_directory_t *directory, LDAP *handle,
823 LDAPMessage *result, char const *name);
824
826
828
829/*
830 * edir.c - Edirectory integrations
831 */
833 fr_ldap_thread_trunk_t *ttrunk, fr_dict_attr_t const *password_da);
834
835char const *fr_ldap_edir_errstr(int code);
836
837
838/*
839 * map.c - Attribute mapping code.
840 */
842 map_t const *map, void *uctx);
843
845 map_t const *map, void *uctx);
846
847int fr_ldap_map_verify(map_t *map, void *instance);
848
849int fr_ldap_map_expand(TALLOC_CTX *ctx, fr_ldap_map_exp_t *expanded, request_t *request,
850 map_list_t const *maps, char const *generic_attr, char const *check_attr,
851 char const *fallthrough_attr);
852
853int fr_ldap_map_do(request_t *request, char const *check_attr,
854 char const *valuepair_attr, fr_ldap_map_exp_t const *expanded, LDAPMessage *entry);
855
856/*
857 * connection.c - Connection configuration functions
858 */
860
861connection_state_t fr_ldap_connection_init(void **h, connection_t *conn, void *uctx);
862
864
865void fr_ldap_connection_close(fr_event_list_t *el, void *h, void *uctx);
866
868
870 char const *bind_dn, char const *bind_password,
872
873trunk_state_t fr_thread_ldap_trunk_state(fr_ldap_thread_t *thread, char const *uri, char const *bind_dn);
874
876
877/*
878 * state.c - Connection state machine
879 */
881
883
884/*
885 * start_tls.c - Mostly async start_tls
886 */
888 LDAPControl **serverctrls, LDAPControl **clientctrls);
889
890/*
891 * sasl.c - Async sasl bind
892 */
893#ifdef WITH_SASL
895 char const *mechs,
896 char const *identity,
897 char const *password,
898 char const *proxy,
899 char const *realm,
900 LDAPControl **serverctrls, LDAPControl **clientctrls);
901
903 int *msgid,
904 fr_ldap_connection_t *ldap_conn);
905
908 fr_ldap_thread_t *thread,
909 char const *mechs,
910 char const *identity,
911 char const *password,
912 char const *proxy, char const *realm);
913#endif
914
915/*
916 * bind.c - Async bind
917 */
919 char const *bind_dn, char const *password,
920 LDAPControl **serverctrls, LDAPControl **clientctrls);
921
923 char const *bind_dn, char const *password);
924
925/*
926 * uti.c - Utility functions
927 */
928size_t fr_ldap_common_dn(char const *full, char const *part);
929
930bool fr_ldap_util_is_dn(char const *in, size_t inlen);
931
932size_t fr_ldap_util_normalise_dn(char *out, char const *in);
933
934char *fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in);
935
936/** State of an in place iteration over an attribute's values
937 *
938 * fr_ldap_value_iter_init returns the first value, fr_ldap_value_iter_next
939 * each value after it, NULL ends the iteration. The caller must always
940 * release the iterator with fr_ldap_value_iter_done, whether iteration
941 * completed or not.
942 */
943typedef struct {
944 BerElement *ber; //!< Cursor over the entry.
945 char *last; //!< End marker of the value set.
946 ber_len_t len; //!< Length of the current element.
947 struct berval value; //!< Value the iterator is positioned on.
948 bool found; //!< The attribute was found in the entry.
949 bool end; //!< All values have been returned.
951
952struct berval *fr_ldap_value_iter_init(int *err, fr_ldap_value_iter_t *iter, LDAP *handle, LDAPMessage *entry,
953 char const *attr);
954
955struct berval *fr_ldap_value_iter_alloc(int *err, fr_ldap_value_iter_t **out, TALLOC_CTX *ctx,
956 LDAP *handle, LDAPMessage *entry, char const *attr);
957
958struct berval *fr_ldap_value_iter_next(int *err, fr_ldap_value_iter_t *iter);
959
961
962int fr_ldap_result_values_len(size_t *num, size_t *strings_len, LDAP *handle, LDAPMessage *result,
963 char const *attr);
964
965int fr_ldap_entry_value_find(struct berval *out, LDAP *handle, LDAPMessage *entry, char const *attr);
966
967talloc_str_list_t *fr_ldap_str_list_afrom_result(TALLOC_CTX *ctx, LDAP *handle, LDAPMessage *result,
968 char const *attr, size_t extra);
969
970uint8_t *fr_ldap_berval_to_bin(TALLOC_CTX *ctx, struct berval const *in);
971
972int fr_ldap_parse_url_extensions(LDAPControl **sss, size_t sss_len, char *extensions[]);
973
974int fr_ldap_attrs_check(char const **attrs, char const *attr);
975
976int fr_ldap_server_url_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION const *cs);
977
978int fr_ldap_server_config_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION *cs);
979
980char const *fr_ldap_url_err_to_str(int ldap_url_err);
981
982void fr_ldap_entry_dump(LDAPMessage *entry);
983
984int fr_ldap_dn_box_escape(fr_value_box_t *vb, UNUSED void *uctx);
985
987
988/** Marks a value box as already escaped for use as a DN attribute value
989 */
990#define LDAP_DN_SAFE_FOR ((fr_value_box_safe_for_t)fr_ldap_dn_box_escape)
991
992/** Marks a value box as already escaped for use as a filter assertion value
993 */
994#define LDAP_FILTER_SAFE_FOR ((fr_value_box_safe_for_t)fr_ldap_filter_box_escape)
995
996char *fr_ldap_filter_afrom_dn_list(TALLOC_CTX *ctx, char const *dn_attr, char const *filter,
997 char const * const *dn_list);
998
999int fr_ldap_filter_to_tmpl(TALLOC_CTX *ctx, tmpl_rules_t const *t_rules, char const **sub, size_t sublen,
1000 tmpl_t **out) CC_HINT(nonnull());
1001
1002/*
1003 * referral.c - Handle LDAP referrals
1004 */
1006
1008
1010
1011/*
1012 * filter.c - Basic filter parsing and filtering
1013 */
1014typedef int (*filter_attr_check_t)(char const *attr, void *uctx);
1015
1016fr_slen_t fr_ldap_filter_parse(TALLOC_CTX *ctx, fr_dlist_head_t **root, fr_sbuff_t *filter,
1017 filter_attr_check_t attr_check, void *uctx);
1018
1019bool 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:947
static uint8_t request[4]
#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:130
#define UNUSED
Definition build.h:415
fr_cmp_ret_t
Result of an ordering comparison.
Definition build.h:113
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
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:1136
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:523
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:194
size_t fr_ldap_util_normalise_dn(char *out, char const *in)
Normalise escape sequences in a DN.
Definition util.c:794
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
fr_ldap_directory_type_t
Definition base.h:139
@ FR_LDAP_DIRECTORY_ORACLE_UNIFIED_DIRECTORY
Directory server is Oracle Unified Directory.
Definition base.h:148
@ FR_LDAP_DIRECTORY_UNKNOWN
We can't determine the directory server.
Definition base.h:140
@ FR_LDAP_DIRECTORY_NETSCAPE
Directory server is Netscape.
Definition base.h:145
@ FR_LDAP_DIRECTORY_EDIRECTORY
Directory server is eDir.
Definition base.h:143
@ FR_LDAP_DIRECTORY_ORACLE_INTERNET_DIRECTORY
Directory server is Oracle Internet Directory.
Definition base.h:147
@ FR_LDAP_DIRECTORY_UNBOUND_ID
Directory server is Unbound ID.
Definition base.h:152
@ FR_LDAP_DIRECTORY_SIEMENS_AG
Directory server is Siemens AG.
Definition base.h:151
@ FR_LDAP_DIRECTORY_ORACLE_VIRTUAL_DIRECTORY
Directory server is Oracle Virtual Directory.
Definition base.h:149
@ FR_LDAP_DIRECTORY_ACTIVE_DIRECTORY
Directory server is Active Directory.
Definition base.h:142
@ FR_LDAP_DIRECTORY_OPENLDAP
Directory server is OpenLDAP.
Definition base.h:146
@ FR_LDAP_DIRECTORY_SUN_ONE_DIRECTORY
Directory server is Sun One Directory.
Definition base.h:150
@ FR_LDAP_DIRECTORY_IBM
Directory server is IBM.
Definition base.h:144
@ FR_LDAP_DIRECTORY_SAMBA
Directory server is Samba.
Definition base.h:153
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:637
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:174
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:348
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:910
char const * mech
SASL mech(s) to try.
Definition base.h:128
ber_len_t len
Length of the current element.
Definition base.h:946
char const * proxy
Proxy identity, may be NULL in which case identity is used.
Definition base.h:496
fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS]
Server controls specific to this query.
Definition base.h:437
LDAP * ldap_global_handle
Hack for OpenLDAP libldap global initialisation.
Definition base.c:38
LDAPURLDesc * referral_url
URL for the referral.
Definition base.h:467
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:483
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:447
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:393
char const * tls_private_key_file
Sets the path to the private key for our public certificate.
Definition base.h:279
fr_dlist_t entry
Entry in the list of connection references.
Definition base.h:411
char const * proxy
Identity to proxy.
Definition base.h:129
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:510
fr_ldap_rcode_t ret
Return code of bind operation.
Definition base.h:611
char * host_uri
Host URI used for referral connection.
Definition base.h:468
char const * fr_ldap_error_str(fr_ldap_connection_t const *conn)
Return the error string associated with a handle.
Definition base.c:152
char const * admin_password
Password used in administrative bind.
Definition base.h:240
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:715
fr_ldap_request_type_t
Types of LDAP requests.
Definition base.h:178
@ LDAP_REQUEST_MODIFY
A modification to an LDAP entity.
Definition base.h:180
@ LDAP_REQUEST_SEARCH
A lookup in an LDAP directory.
Definition base.h:179
@ LDAP_REQUEST_DELETE
A deletion of an LDAP entity.
Definition base.h:181
@ LDAP_REQUEST_EXTENDED
An extended LDAP operation.
Definition base.h:182
fr_ldap_state_t state
LDAP connection state machine.
Definition base.h:341
int fr_ldap_filter_box_escape(fr_value_box_t *vb, UNUSED void *uctx)
Escape a value box for use as an RFC 4515 filter assertion value.
Definition util.c:172
fr_ldap_config_t * config
Module instance config.
Definition base.h:368
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:360
LDAP * fr_ldap_handle_thread_local(void)
Get a thread local dummy LDAP handle.
Definition base.c:1104
void fr_ldap_value_iter_done(fr_ldap_value_iter_t *iter)
Release value iteration state.
Definition util.c:474
bool chase_referrals
If the LDAP server returns a referral to another server or point in the tree, follow it,...
Definition base.h:249
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:242
char ** referral_urls
Referral results to follow.
Definition base.h:446
char * last
End marker of the value set.
Definition base.h:945
int msgid
libldap msgid for this bind.
Definition base.h:604
int fr_ldap_global_config(int debug_level, char const *tls_random_file)
Change settings global to libldap.
Definition base.c:1125
map_list_t const * maps
Head of list of maps we expanded the RHS of.
Definition base.h:356
fr_slen_t fr_ldap_dn_escape(fr_sbuff_t *out, fr_sbuff_t *in)
Escape a value for use as an RFC 4514 DN attribute value.
Definition util.c:95
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:844
char const * tls_certificate_file
Sets the path to the public certificate file we present to the servers.
Definition base.h:276
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:490
char * server
Initial server to bind to.
Definition base.h:233
int dereference
libldap value specifying dereferencing behaviour.
Definition base.h:246
fr_ldap_sync_type_t sync_type
What kind of LDAP sync this directory supports.
Definition base.h:211
uint16_t referral_depth
How many referrals we have followed.
Definition base.h:448
LDAP * handle
libldap handle.
Definition base.h:327
int msgid
The unique identifier for this query.
Definition base.h:440
char const * dn
Base DN for searches, DN for modifications.
Definition base.h:416
char const * bind_dn
DN connection is bound as.
Definition base.h:389
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:387
int serverctrls_cnt
Number of server controls associated with the handle.
Definition base.h:333
fr_dlist_head_t referrals
List of parsed referrals.
Definition base.h:447
static fr_cmp_ret_t fr_ldap_query_cmp(void const *one, void const *two)
Compare two ldap query structures on msgid.
Definition base.h:698
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:972
char const * admin_identity
Identity we bind as when we need to query the LDAP directory.
Definition base.h:238
global_lib_autoinst_t fr_libldap_global_config
Definition base.c:134
fr_ldap_result_code_t ret
Result code.
Definition base.h:455
fr_ldap_result_parser_t parser
Custom results parser.
Definition base.h:451
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:764
bool freeit
Whether the control should be freed after we've finished using it.
Definition base.h:135
fr_rb_tree_t * trunks
Tree of LDAP trunks used by this thread.
Definition base.h:367
request_t * request
Request this referral relates to.
Definition base.h:472
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:369
fr_rb_tree_t * queries
Outstanding queries on this connection.
Definition base.h:345
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:197
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:409
fr_time_delta_t keepalive_idle
Number of seconds a connections needs to remain idle before TCP starts sending keepalive probes.
Definition base.h:293
char const * dereference_str
When to dereference (never, searching, finding, always)
Definition base.h:247
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
fr_ldap_directory_t * directory
The type of directory we're connected to.
Definition base.h:336
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:748
char const * identity
of the user.
Definition base.h:494
trunk_request_t * treq
Trunk request this query is associated with.
Definition base.h:443
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:410
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:653
fr_dlist_head_t refs
Replied to queries still referencing this connection.
Definition base.h:346
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:890
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:343
fr_timer_t * ev
Event to close the thread when it has been idle.
Definition base.h:394
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:465
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:620
bool fr_ldap_filter_eval(fr_dlist_head_t *root, fr_ldap_connection_t *conn, LDAPMessage *msg)
Evaluate an LDAP filter.
Definition filter.c:588
char const * uri
Server URI for this connection.
Definition base.h:388
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:998
fr_dlist_t entry
Entry in the list of filter nodes.
Definition base.h:548
const char * sasl_secprops
SASL Security Properties to set.
Definition base.h:244
struct fr_ldap_referral_s fr_ldap_referral_t
Parsed LDAP referral structure.
Definition base.h:397
bool end
All values have been returned.
Definition base.h:949
void fr_ldap_free(void)
LDAPMessage * result
Previous result.
Definition base.h:502
fr_slen_t fr_ldap_filter_escape(fr_sbuff_t *out, fr_sbuff_t *in)
Escape a value for use as an RFC 4515 filter assertion value.
Definition util.c:144
fr_time_delta_t keepalive_interval
Interval between keepalive probes.
Definition base.h:299
char * fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced string.
Definition util.c:745
int msgid
Of the bind operation. Only used when binding as admin.
Definition base.h:485
char const * tls_require_cert_str
Sets requirements for validating the certificate the server presents.
Definition base.h:282
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:321
fr_ldap_config_t const * config
rlm_ldap connection configuration.
Definition base.h:338
fr_ldap_connection_t * c
to bind. Only used when binding as admin user.
Definition base.h:492
LDAPControl ** clientctrls
Controls to pass to the client (library).
Definition base.h:499
#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:605
fr_ldap_connection_t * c
to bind. Only used when binding as admin user.
Definition base.h:479
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:438
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:798
trunk_request_t * treq
Trunk request this bind is associated with.
Definition base.h:603
char const * tls_ca_path
Sets the path to a directory containing CA certificates.
Definition base.h:274
fr_ldap_bind_type_t
Definition base.h:506
@ LDAP_BIND_SIMPLE
Definition base.h:507
uint32_t keepalive_probes
Number of missed timeouts before the connection is dropped.
Definition base.h:296
char const * realm
SASL realm (may be NULL).
Definition base.h:497
bool rebind
If use_referral_credentials is false, controls whether we bind as our admin credentials (true) or ano...
Definition base.h:258
char const * mechs
SASL mechanisms to run.
Definition base.h:493
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:923
char const * password
of the user, may be NULL if no password is specified.
Definition base.h:495
fr_ldap_config_t config
Config used for this connection.
Definition base.h:390
int tls_require_cert
OpenLDAP constant representing the require cert string.
Definition base.h:285
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:315
static fr_cmp_ret_t fr_ldap_bind_auth_cmp(void const *one, void const *two)
Compare two ldap bind auth structures on msgid.
Definition base.h:711
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:1095
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:663
int fr_ldap_dn_box_escape(fr_value_box_t *vb, UNUSED void *uctx)
Escape a value box for use as an RFC 4514 DN attribute value.
Definition util.c:161
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:469
bool start_tls
Send the Start TLS message to the LDAP directory to start encrypted communications using the standard...
Definition base.h:267
int tls_min_version
Definition base.h:288
bool use_referral_credentials
If true use credentials from the referral URL.
Definition base.h:254
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:279
fr_ldap_query_t * query
Query this referral relates to.
Definition base.h:466
char const * vendor_str
As returned from the vendorName attribute in the rootDSE.
Definition base.h:202
int clientctrls_cnt
Number of client controls associated with the handle.
Definition base.h:334
fr_pair_list_t * bind_trigger_args
Passed to trigger request for bind trunks.
Definition base.h:375
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:444
LDAPControl ** serverctrls
Controls to pass to the server.
Definition base.h:482
char const * realm
Kerberos realm.
Definition base.h:130
char * orig
Text representation of filter for debug messages,.
Definition base.h:550
fr_ldap_sasl_t admin_sasl
SASL parameters used when binding as the admin.
Definition base.h:242
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:836
fr_hash_table_t * naming_contexts_ht
For resolving DNs to the naming context containing them.
Definition base.h:219
ldap_filter_logic_t
Logical operators for use in LDAP filters.
Definition base.h:526
@ LDAP_FILTER_LOGIC_NOT
Definition base.h:529
@ LDAP_FILTER_LOGIC_OR
Definition base.h:528
@ LDAP_FILTER_LOGIC_AND
Definition base.h:527
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:1051
bool found
The attribute was found in the entry.
Definition base.h:948
ldap_filter_type_t filter_type
Type of this filter node.
Definition base.h:549
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:411
bool cleartext_password
Whether the server will return the user's plaintext password.
Definition base.h:208
int msgid
Last msgid. Only used when binding as admin user.
Definition base.h:501
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:664
char const * tls_ca_file
Sets the full path to a CA certificate (used to validate the certificate the server presents).
Definition base.h:271
BerElement * ber
Cursor over the entry.
Definition base.h:944
bool chase_referrals_unset
If true, use the OpenLDAP defaults for chase_referrals.
Definition base.h:252
fr_ldap_result_code_t
LDAP query result codes.
Definition base.h:188
@ LDAP_RESULT_EXCESS_REFERRALS
The referral chain took too many hops.
Definition base.h:197
@ LDAP_RESULT_REFERRAL_FAIL
Initial results indicated a referral was needed but the referral could not be followed.
Definition base.h:195
@ LDAP_RESULT_TIMEOUT
The query timed out.
Definition base.h:192
@ LDAP_RESULT_ERROR
A general error occurred.
Definition base.h:191
@ LDAP_RESULT_SUCCESS
Successfully got LDAP results.
Definition base.h:190
@ LDAP_RESULT_PENDING
Result not yet returned.
Definition base.h:189
@ LDAP_RESULT_NO_RESULT
No results returned.
Definition base.h:194
@ LDAP_RESULT_BAD_DN
The requested DN does not exist.
Definition base.h:193
@ LDAP_RESULT_MISSING_REFERRAL
A referral was indicated but no URL was provided.
Definition base.h:198
#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:234
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
ldap_filter_op_t
Operators for use in LDAP filters.
Definition base.h:534
@ LDAP_FILTER_OP_BIT_AND
Bitwise AND comparison.
Definition base.h:541
@ LDAP_FILTER_OP_PRESENT
Attribute present.
Definition base.h:538
@ LDAP_FILTER_OP_SUBSTR
Attribute matches string with wildcards.
Definition base.h:537
@ LDAP_FILTER_OP_EQ
Attribute equals value.
Definition base.h:536
@ LDAP_FILTER_OP_LE
Attribute less than or equal to value.
Definition base.h:540
@ LDAP_FILTER_OP_BIT_OR
Bitwise OR comparison.
Definition base.h:542
@ LDAP_FILTER_OP_GE
Attribute greater than or equal to value.
Definition base.h:539
@ LDAP_FILTER_OP_UNSET
Attribute not set yet.
Definition base.h:535
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.
Definition connection.c:982
#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:231
trunk_conf_t * bind_trunk_conf
Trunk config for bind auth trunk.
Definition base.h:370
ldap_filter_type_t
Types of parsed LDAP filter nodes.
Definition base.h:517
@ LDAP_FILTER_GROUP
The filter node is a parent of a group which will be combined using a logical operator.
Definition base.h:520
@ LDAP_FILTER_NODE
The filter node is an individual one to be evaluated against an attribute.
Definition base.h:518
uint16_t referral_depth
How many referrals to chase.
Definition base.h:256
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:304
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:1025
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:345
void * uctx
User data associated with the handle.
Definition base.h:348
void fr_ldap_entry_dump(LDAPMessage *entry)
Dump out the contents of an LDAPMessage.
Definition util.c:1183
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:340
static fr_cmp_ret_t fr_ldap_trunk_cmp(void const *one, void const *two)
Compare two ldap trunk structures on connection URI / DN.
Definition base.h:682
connection_state_t fr_ldap_connection_init(void **h, connection_t *conn, void *uctx)
Initialise a standalone LDAP connection.
Definition connection.c:393
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:876
fr_ldap_rcode_t
Codes returned by fr_ldap internal functions.
Definition base.h:567
@ LDAP_PROC_CONTINUE
Operation is in progress.
Definition base.h:571
@ LDAP_PROC_SUCCESS
Operation was successful.
Definition base.h:572
@ LDAP_PROC_REFERRAL
LDAP server returned referral URLs.
Definition base.h:570
@ LDAP_PROC_TIMEOUT
Operation timed out.
Definition base.h:589
@ LDAP_PROC_ERROR
Unrecoverable library/server error.
Definition base.h:574
@ LDAP_PROC_BAD_CONN
Transitory error, caller should retry the operation with a new connection.
Definition base.h:576
@ LDAP_PROC_NOT_PERMITTED
Operation was not permitted, either current user was locked out in the case of binds,...
Definition base.h:579
@ LDAP_PROC_PENDING
fr_ldap_result() was polling and hasn't read the final message yet.
Definition base.h:568
@ LDAP_PROC_REJECT
Bind failed, user was rejected.
Definition base.h:583
@ LDAP_PROC_REFRESH_REQUIRED
Don't continue with the current refresh phase, exit, and retry the operation with a NULL cookie.
Definition base.h:591
@ LDAP_PROC_BAD_DN
Specified an invalid object in a bind or search DN.
Definition base.h:585
@ LDAP_PROC_NO_RESULT
Got no results.
Definition base.h:587
LDAPMessage * result
Head of LDAP results list.
Definition base.h:453
fr_event_list_t * el
Thread event list for callbacks / timeouts.
Definition base.h:371
fr_ldap_directory_t * directory
The type of directory we're connected to.
Definition base.h:391
fr_ldap_connection_t * fr_ldap_connection_alloc(TALLOC_CTX *ctx)
Allocate our ldap connection handle layer.
Definition connection.c:257
LDAPControl * control
LDAP control.
Definition base.h:134
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:696
char const * rmech
Mech we're continuing with.
Definition base.h:503
char const * password
Bind password for referral connection.
Definition base.h:470
fr_ldap_sync_type_t
Definition base.h:156
@ FR_LDAP_SYNC_NONE
No support for LDAP sync.
Definition base.h:157
@ FR_LDAP_SYNC_ACTIVE_DIRECTORY
Directory supports AD style persistent search.
Definition base.h:159
@ FR_LDAP_SYNC_PERSISTENT_SEARCH
Directory supports persistent search.
Definition base.h:160
@ FR_LDAP_SYNC_RFC4533
Directory supports RFC 4533.
Definition base.h:158
char const * tls_min_version_str
Minimum TLS version.
Definition base.h:287
bool discovered
A rootDSE response has been parsed into these fields.
Definition base.h:222
LDAPControl ** serverctrls
Controls to pass to the server.
Definition base.h:498
fr_ldap_state_t
LDAP connection handle states.
Definition base.h:166
@ FR_LDAP_STATE_ERROR
Connection is in an error state.
Definition base.h:172
@ FR_LDAP_STATE_BIND
Connection is being bound.
Definition base.h:169
@ FR_LDAP_STATE_START_TLS
TLS is being negotiated.
Definition base.h:168
@ FR_LDAP_STATE_RUN
Connection is muxing/demuxing requests.
Definition base.h:171
@ FR_LDAP_STATE_DISCOVER
Directory capabilities are being read from the rootDSE.
Definition base.h:170
@ FR_LDAP_STATE_INIT
Connection uninitialised.
Definition base.h:167
uint16_t port
Port to use when binding to the server.
Definition base.h:236
fr_ldap_thread_trunk_t * bind_trunk
LDAP trunk used for bind auths.
Definition base.h:372
ldap_supported_extension_t
Definition base.h:121
@ LDAP_EXT_BINDPW
Specifies the password for an LDAP bind.
Definition base.h:124
@ LDAP_EXT_UNSUPPORTED
Unsupported extension.
Definition base.h:122
@ LDAP_EXT_BINDNAME
Specifies the user DN or name for an LDAP bind.
Definition base.h:123
char const * version_str
As returned from the vendorVersion attribute in the rootDSE.
Definition base.h:204
char const * bind_dn
of the user, may be NULL to bind anonymously.
Definition base.h:480
void(* fr_ldap_result_parser_t)(LDAP *handle, fr_ldap_query_t *query, LDAPMessage *head, void *rctx)
Definition base.h:401
trunk_t * trunk
Connection trunk.
Definition base.h:392
fr_pair_list_t * trigger_args
Passed to trigger request for normal trunks.
Definition base.h:374
fr_ldap_thread_t * thread
This bind is being run by.
Definition base.h:602
fr_ldap_thread_trunk_t * ttrunk
Trunk this referral should use.
Definition base.h:471
connection_t * conn
Connection state handle.
Definition base.h:339
fr_ldap_referral_t * referral
Referral actually being followed.
Definition base.h:449
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:338
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:359
fr_rb_tree_t * binds
Tree of outstanding bind auths.
Definition base.h:373
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:590
char const * dn_attr
Attribute to match an entry's DN in a search filter.
Definition base.h:213
uint32_t ldap_debug
LDAP debug level.
Definition base.h:314
connection_state_t fr_ldap_trunk_connection_init(void **h, connection_t *conn, void *uctx)
Initialise an LDAP trunk connection.
Definition connection.c:410
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:1074
int(* filter_attr_check_t)(char const *attr, void *uctx)
Definition base.h:1014
fr_rb_node_t node
Entry in the tree of outstanding bind requests.
Definition base.h:601
fr_ldap_bind_type_t type
type of bind.
Definition base.h:606
char const ** naming_contexts
NULL terminated array of databases served by this directory.
Definition base.h:217
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:481
fr_time_delta_t idle_timeout
How long to wait before closing unused connections.
Definition base.h:307
fr_ldap_directory_type_t type
Canonical server implementation.
Definition base.h:206
fr_ldap_request_type_t type
What type of query this is.
Definition base.h:435
int fr_ldap_init(void)
Initialise libldap and check library versions.
Definition base.c:1164
LDAPURLDesc * ldap_url
parsed URL for current query if the source of the query was a URL.
Definition base.h:413
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:876
Holds arguments for async bind auth requests.
Definition base.h:600
Holds arguments for the async bind operation.
Definition base.h:478
Connection configuration.
Definition base.h:230
Tracks the state of a libldap connection handle.
Definition base.h:326
Result of expanding the RHS of a set of maps.
Definition base.h:355
LDAP query structure.
Definition base.h:409
Parsed LDAP referral structure.
Definition base.h:464
Holds arguments for the async SASL bind operation.
Definition base.h:491
Thread specific structure to manage LDAP trunk connections.
Definition base.h:366
Thread LDAP trunk structure.
Definition base.h:386
State of an in place iteration over an attribute's values.
Definition base.h:943
libldap global configuration data
Definition base.h:313
Structure to hold parsed details of LDAP filters.
Definition base.h:547
Stores all information relating to an event list.
Definition event.c:375
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:162
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:515
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:319
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:378
connection_state_t
Definition connection.h:47
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:343
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:254
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:219
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:410
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:5339
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:5101
static fr_sbuff_err_t char size_t fr_sbuff_t * in
Definition value.h:1061
static fr_sbuff_err_t char ** out
Definition value.h:1061
int nonnull(2, 5))