The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
base.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * $Id: deec044d33b75fb4132ddea66f9afa18297dfa91 $
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 
26 extern 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)
46 LDAP_F( int )
47 ldap_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 
122 typedef 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 
128 typedef struct {
129  char const *mech; //!< SASL mech(s) to try.
130  char const *proxy; //!< Identity to proxy.
131  char const *realm; //!< Kerberos realm.
133 
134 typedef struct {
135  LDAPControl *control; //!< LDAP control.
136  bool freeit; //!< Whether the control should be freed after
137  //!< we've finished using it.
139 
140 typedef 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 
157 typedef 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  */
167 typedef 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_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  */
178 typedef enum {
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  */
188 typedef enum {
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 
201 typedef 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 **naming_contexts; //!< Databases served by this directory.
215 
216 /** Connection configuration
217  *
218  * Must not be passed into functions except via the connection handle
219  * this avoids problems with not using the connection pool configuration.
220  */
221 typedef struct {
222  char const *name; //!< Name of the module that created this connection.
223 
224  char *server; //!< Initial server to bind to.
225  char const **server_str; //!< Server set in the config.
226 
227  uint16_t port; //!< Port to use when binding to the server.
228 
229  char const *admin_identity; //!< Identity we bind as when we need to query the LDAP
230  ///< directory.
231  char const *admin_password; //!< Password used in administrative bind.
232 
233  fr_ldap_sasl_t admin_sasl; //!< SASL parameters used when binding as the admin.
234 
235  const char *sasl_secprops; //!< SASL Security Properties to set.
236 
237  int dereference; //!< libldap value specifying dereferencing behaviour.
238  char const *dereference_str; //!< When to dereference (never, searching, finding, always)
239 
240  bool chase_referrals; //!< If the LDAP server returns a referral to another server
241  ///< or point in the tree, follow it, establishing new
242  ///< connections and binding where necessary.
243  bool chase_referrals_unset; //!< If true, use the OpenLDAP defaults for chase_referrals.
244 
245  bool use_referral_credentials; //!< If true use credentials from the referral URL.
246 
247  uint16_t referral_depth; //!< How many referrals to chase
248 
249  bool rebind; //!< If use_referral_credentials is false, controls whether we
250  ///< bind as our admin credentials (true) or anonymously (false)
251  ///< when connecting to a different server to follow a referral
252 
253  /*
254  * TLS items.
255  */
256  int tls_mode;
257 
258  bool start_tls; //!< Send the Start TLS message to the LDAP directory
259  ///< to start encrypted communications using the standard
260  ///< LDAP port.
261 
262  char const *tls_ca_file; //!< Sets the full path to a CA certificate (used to validate
263  ///< the certificate the server presents).
264 
265  char const *tls_ca_path; //!< Sets the path to a directory containing CA certificates.
266 
267  char const *tls_certificate_file; //!< Sets the path to the public certificate file we present
268  ///< to the servers.
269 
270  char const *tls_private_key_file; //!< Sets the path to the private key for our public
271  ///< certificate.
272 
273  char const *tls_require_cert_str; //!< Sets requirements for validating the certificate the
274  ///< server presents.
275 
276  int tls_require_cert; //!< OpenLDAP constant representing the require cert string.
277 
278  char const *tls_min_version_str; //!< Minimum TLS version
280 
281  /*
282  * For keep-alives.
283  */
284  fr_time_delta_t keepalive_idle; //!< Number of seconds a connections needs to remain idle
285  //!< before TCP starts sending keepalive probes.
286 
287  uint32_t keepalive_probes; //!< Number of missed timeouts before the connection is
288  ///< dropped.
289 
290  fr_time_delta_t keepalive_interval; //!< Interval between keepalive probes.
291 
292  /*
293  * Search timelimits
294  */
295  fr_time_delta_t srv_timelimit; //!< How long the server should spent on a single request
296  ///< (also bounded by value on the server).
297 
298  fr_time_delta_t res_timeout; //!< How long we wait for results.
299 
300  /*
301  * I/O timelimits.
302  */
303  fr_time_delta_t net_timeout; //!< How long we wait in blocking network calls.
304  ///< We set this in the LDAP API, even though with
305  ///< async calls, we control this using our event loop.
306  ///< This is just in case there are blocking calls which
307  ///< happen internally which we can't work around.
308 
309  fr_time_delta_t tls_handshake_timeout; //!< How long we wait for the TLS handshake to complete.
310 
311  fr_time_delta_t reconnection_delay; //!< How long to wait before attempting to reconnect.
312 
313  fr_time_delta_t idle_timeout; //!< How long to wait before closing unused connections.
315 
316 /** libldap global configuration data
317  *
318  */
319 typedef struct {
320  uint32_t ldap_debug; //!< LDAP debug level
321  char const *tls_random_file; //!< Path to the ramdon file if /dev/random and /dev/urandom
322  //!< are unavailable
324 
326 
328 
329 /** Tracks the state of a libldap connection handle
330  *
331  */
332 typedef struct {
333  LDAP *handle; //!< libldap handle.
334 
335  fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS + 1]; //!< Server controls to use for all operations
336  ///< with this handle.
337  fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS + 1]; //!< Client controls to use for all operations
338  ///< with this handle.
339  int serverctrls_cnt; //!< Number of server controls associated with the handle.
340  int clientctrls_cnt; //!< Number of client controls associated with the handle.
341 
342  fr_ldap_directory_t *directory; //!< The type of directory we're connected to.
343 
344  fr_ldap_config_t const *config; //!< rlm_ldap connection configuration.
345  connection_t *conn; //!< Connection state handle.
346 
347  fr_ldap_state_t state; //!< LDAP connection state machine.
348 
349  int fd; //!< File descriptor for this connection.
350 
351  fr_rb_tree_t *queries; //!< Outstanding queries on this connection
352  fr_dlist_head_t refs; //!< Replied to queries still referencing this connection.
353 
354  void *uctx; //!< User data associated with the handle.
356 
357 /** Contains a collection of values
358  *
359  */
360 typedef struct {
361  struct berval **values; //!< libldap struct containing bv_val (char *)
362  ///< and length bv_len.
363  int count; //!< Number of values.
365 
366 /** Result of expanding the RHS of a set of maps
367  *
368  * Used to store the array of attributes we'll be querying for.
369  */
370 typedef struct {
371  map_list_t const *maps; //!< Head of list of maps we expanded the RHS of.
372  char const *attrs[LDAP_MAX_ATTRMAP + LDAP_MAP_RESERVED + 1]; //!< Reserve some space for access attributes
373  //!< and NULL termination.
374  TALLOC_CTX *ctx; //!< Context to allocate new attributes in.
375  int count; //!< Index on next free element.
377 
378 /** Thread specific structure to manage LDAP trunk connections.
379  *
380  */
381 typedef struct {
382  fr_rb_tree_t *trunks; //!< Tree of LDAP trunks used by this thread
383  fr_ldap_config_t *config; //!< Module instance config
384  trunk_conf_t *trunk_conf; //!< Module trunk config
385  trunk_conf_t *bind_trunk_conf; //!< Trunk config for bind auth trunk
386  fr_event_list_t *el; //!< Thread event list for callbacks / timeouts
387  fr_ldap_thread_trunk_t *bind_trunk; //!< LDAP trunk used for bind auths
388  fr_rb_tree_t *binds; //!< Tree of outstanding bind auths
390 
391 /** Thread LDAP trunk structure
392  *
393  * One fr_ldap_thread_trunk_t will be allocated for each destination a thread needs
394  * to create an LDAP trunk connection to.
395  *
396  * Used to hold config regarding the LDAP connection and associate pending queries
397  * with the trunk they are running on.
398  */
399 typedef struct fr_ldap_thread_trunk_s {
400  fr_rb_node_t node; //!< Entry in the tree of connections
401  char const *uri; //!< Server URI for this connection
402  char const *bind_dn; //!< DN connection is bound as
403  fr_ldap_config_t config; //!< Config used for this connection
404  fr_ldap_directory_t *directory; //!< The type of directory we're connected to.
405  trunk_t *trunk; //!< Connection trunk
406  fr_ldap_thread_t *t; //!< Thread this connection is associated with
407  fr_event_timer_t const *ev; //!< Event to close the thread when it has been idle.
409 
411 
412 typedef struct fr_ldap_query_s fr_ldap_query_t;
413 
414 typedef void (*fr_ldap_result_parser_t)(LDAP *handle, fr_ldap_query_t *query, LDAPMessage *head, void *rctx);
415 
416 /** LDAP query structure
417  *
418  * Used to hold the elements of an LDAP query and track its progress.
419  * libldap structures will be freed by the talloc destructor.
420  * The same structure is used both for search queries and modifications
421  */
423  fr_rb_node_t node; //!< Entry in the tree of outstanding queries.
424  fr_dlist_t entry; //!< Entry in the list of connection references.
425 
426  LDAPURLDesc *ldap_url; //!< parsed URL for current query if the source
427  ///< of the query was a URL.
428 
429  char const *dn; //!< Base DN for searches, DN for modifications.
430 
431  /** Fields which are unique to each type of query
432  *
433  * @note Delete only uses the DN field, as it operates at an object level.
434  */
435  union {
436  struct {
437  char const **attrs; //!< Attributes being requested in a search.
438  int scope; //!< Search scope.
439  char const *filter; //!< Filter for search.
440  } search;
441  struct {
442  char const *reqoid; //!< OID of extended operation to perform.
443  struct berval *reqdata; //!< Data required for the request.
444  } extended;
445  LDAPMod **mods; //!< Changes to be applied if this query is a modification.
446  };
447 
448  fr_ldap_request_type_t type; //!< What type of query this is.
449 
450  fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS]; //!< Server controls specific to this query.
451  fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS]; //!< Client controls specific to this query.
452 
453  int msgid; //!< The unique identifier for this query.
454  ///< Uniqueness is only per connection.
455 
456  trunk_request_t *treq; //!< Trunk request this query is associated with
457  fr_ldap_connection_t *ldap_conn; //!< LDAP connection this query is running on.
458 
459  fr_event_timer_t const *ev; //!< Event for timing out the query
460 
461  char **referral_urls; //!< Referral results to follow
462  fr_dlist_head_t referrals; //!< List of parsed referrals
463  uint16_t referral_depth; //!< How many referrals we have followed
464  fr_ldap_referral_t *referral; //!< Referral actually being followed
465 
466  fr_ldap_result_parser_t parser; //!< Custom results parser.
467 
468  LDAPMessage *result; //!< Head of LDAP results list.
469 
470  fr_ldap_result_code_t ret; //!< Result code
471 };
472 
473 /** Parsed LDAP referral structure
474  *
475  * When LDAP servers respond with a referral, it is parsed into one or more fr_ldap_referral_t
476  * and kept until the referral has been followed.
477  * Avoids repeated parsing of the referrals as provided by libldap.
478  */
479 typedef struct fr_ldap_referral_s {
480  fr_dlist_t entry; //!< Entry in list of possible referrals
481  fr_ldap_query_t *query; //!< Query this referral relates to
482  LDAPURLDesc *referral_url; //!< URL for the referral
483  char *host_uri; //!< Host URI used for referral connection
484  char const *identity; //!< Bind identity for referral connection
485  char const *password; //!< Bind password for referral connection
486  fr_ldap_thread_trunk_t *ttrunk; //!< Trunk this referral should use
487  request_t *request; //!< Request this referral relates to
489 
490 /** Holds arguments for the async bind operation
491  *
492  */
493 typedef struct {
494  fr_ldap_connection_t *c; //!< to bind. Only used when binding as admin user.
495  char const *bind_dn; //!< of the user, may be NULL to bind anonymously.
496  char const *password; //!< of the user, may be NULL if no password is specified.
497  LDAPControl **serverctrls; //!< Controls to pass to the server.
498  LDAPControl **clientctrls; //!< Controls to pass to the client (library).
499 
500  int msgid; //!< Of the bind operation. Only used when binding as admin.
502 
503 /** Holds arguments for the async SASL bind operation
504  *
505  */
506 typedef struct {
507  fr_ldap_connection_t *c; //!< to bind. Only used when binding as admin user.
508  char const *mechs; //!< SASL mechanisms to run
509  char const *identity; //!< of the user.
510  char const *password; //!< of the user, may be NULL if no password is specified.
511  char const *proxy; //!< Proxy identity, may be NULL in which case identity is used.
512  char const *realm; //!< SASL realm (may be NULL).
513  LDAPControl **serverctrls; //!< Controls to pass to the server.
514  LDAPControl **clientctrls; //!< Controls to pass to the client (library).
515 
516  int msgid; //!< Last msgid. Only used when binding as admin user.
517  LDAPMessage *result; //!< Previous result.
518  char const *rmech; //!< Mech we're continuing with.
520 
521 typedef enum {
523 #ifdef WITH_SASL
524  LDAP_BIND_SASL
525 #endif
527 
528 typedef struct ldap_filter_s ldap_filter_t;
529 
530 /** Types of parsed LDAP filter nodes
531  */
532 typedef enum {
533  LDAP_FILTER_NODE = 0, //!< The filter node is an individual one
534  //!< to be evaluated against an attribute.
535  LDAP_FILTER_GROUP //!< The filter node is a parent of a group
536  //!< which will be combined using a logical operator.
538 
539 /** Logical operators for use in LDAP filters
540  */
541 typedef enum {
546 
547 /** Operators for use in LDAP filters
548  */
549 typedef enum {
550  LDAP_FILTER_OP_UNSET = 0, //!< Attribute not set yet
551  LDAP_FILTER_OP_EQ, //!< Attribute equals value
552  LDAP_FILTER_OP_SUBSTR, //!< Attribute matches string with wildcards
553  LDAP_FILTER_OP_PRESENT, //!< Attribute present
554  LDAP_FILTER_OP_GE, //!< Attribute greater than or equal to value
555  LDAP_FILTER_OP_LE, //!< Attribute less than or equal to value
556  LDAP_FILTER_OP_BIT_AND, //!< Bitwise AND comparison
557  LDAP_FILTER_OP_BIT_OR //!< Bitwise OR comparison
559 
560 /** Structure to hold parsed details of LDAP filters
561  */
563  fr_dlist_t entry; //!< Entry in the list of filter nodes.
564  ldap_filter_type_t filter_type; //!< Type of this filter node.
565  char *orig; //!< Text representation of filter for debug messages,
566  union {
567  struct {
568  ldap_filter_logic_t logic_op; //!< Logical operator for this group.
569  fr_dlist_head_t children; //!< List of child nodes in this group.
570  };
571  struct {
572  char *attr; //!< Attribute for the filter node.
573  ldap_filter_op_t op; //!< Operator to be used for comparison.
574  fr_value_box_t *value; //!< Value to compare with.
575  };
576  };
577 };
578 
579 /** Codes returned by fr_ldap internal functions
580  *
581  */
582 typedef enum {
583  LDAP_PROC_REFERRAL = 2, //!< LDAP server returned referral URLs.
584  LDAP_PROC_CONTINUE = 1, //!< Operation is in progress.
585  LDAP_PROC_SUCCESS = 0, //!< Operation was successful.
586 
587  LDAP_PROC_ERROR = -1, //!< Unrecoverable library/server error.
588 
589  LDAP_PROC_BAD_CONN = -2, //!< Transitory error, caller should retry the operation
590  //!< with a new connection.
591 
592  LDAP_PROC_NOT_PERMITTED = -3, //!< Operation was not permitted, either current user was
593  //!< locked out in the case of binds, or has insufficient
594  //!< access.
595 
596  LDAP_PROC_REJECT = -4, //!< Bind failed, user was rejected.
597 
598  LDAP_PROC_BAD_DN = -5, //!< Specified an invalid object in a bind or search DN.
599 
600  LDAP_PROC_NO_RESULT = -6, //!< Got no results.
601 
602  LDAP_PROC_TIMEOUT = -7, //!< Operation timed out.
603 
604  LDAP_PROC_REFRESH_REQUIRED = -8 //!< Don't continue with the current refresh phase,
605  //!< exit, and retry the operation with a NULL cookie.
607 
608 /** Holds arguments for async bind auth requests
609  *
610  * Used when LDAP binds are being used to authenticate users, rather than admin binds.
611  * Allows tracking of multiple bind requests on a single connection.
612  */
613 typedef struct {
614  fr_rb_node_t node; //!< Entry in the tree of outstanding bind requests.
615  fr_ldap_thread_t *thread; //!< This bind is being run by.
616  trunk_request_t *treq; //!< Trunk request this bind is associated with.
617  int msgid; //!< libldap msgid for this bind.
618  request_t *request; //!< this bind relates to.
619  fr_ldap_bind_type_t type; //!< type of bind.
620  union {
621  fr_ldap_bind_ctx_t *bind_ctx; //!< User data for simple binds.
622  fr_ldap_sasl_ctx_t *sasl_ctx; //!< User data for SASL binds.
623  };
624  fr_ldap_rcode_t ret; //!< Return code of bind operation.
626 
627 /*
628  * Tables for resolving strings to LDAP constants
629  */
631 extern size_t fr_ldap_connection_states_len;
632 
636 extern size_t fr_ldap_dereference_len;
637 extern fr_table_num_sorted_t const fr_ldap_scope[];
638 extern size_t fr_ldap_scope_len;
640 extern size_t fr_ldap_tls_require_cert_len;
641 
642 /** Inline function to copy pointers from a berval to a valuebox
643  *
644  * @note This results in a shallow copy of the berval, so if the berval is freed
645  * the value box becomes invalidated.
646  *
647  * @param[out] value to write berval values to.
648  * @param[in] berval to copy pointers/lengths from.
649  */
650 static inline void fr_ldap_berval_to_value_shallow(fr_value_box_t *value, struct berval *berval)
651 {
652  fr_value_box_memdup_shallow(value, NULL, (uint8_t *)berval->bv_val, berval->bv_len, true);
653 }
654 
655 /** Inline function to copy pointer from a berval to a string value box
656  *
657  * Useful for printing contents of bervals known to contain strings in DEBUG output since
658  * they are not NULL terminated.
659  *
660  * @note This results in a shallow copy of the berval, so if the berval is freed
661  * the value box becomes invalidated.
662  *
663  * @param[out] value to write berval value to.
664  * @param[in] berval top copy pointer / length from.
665  */
666 static inline void fr_ldap_berval_to_value_str_shallow(fr_value_box_t *value, struct berval *berval)
667 {
668  fr_value_box_bstrndup_shallow(value, NULL, berval->bv_val, berval->bv_len, true);
669 }
670 
671 /** Compare a berval with a C string of a known length using case insensitive comparison
672  *
673  * @param[in] value berval.
674  * @param[in] str String to compare with value.
675  * @param[in] strlen Number of characters of str to compare.
676  */
677 static inline int fr_ldap_berval_strncasecmp(struct berval *value, char const *str, size_t strlen)
678 {
679  size_t i;
680  if (strlen != value->bv_len) return CMP(strlen, value->bv_len);
681 
682  for (i = 0; i < strlen; i++) {
683  if (tolower(value->bv_val[i]) != tolower(str[i])) return CMP(value->bv_val[i], str[i]);
684  }
685 
686  return 0;
687 }
688 
689 /** Compare two ldap trunk structures on connection URI / DN
690  *
691  * @param[in] one first connection to compare.
692  * @param[in] two second connection to compare.
693  * @return CMP(one, two)
694  */
695 static inline int8_t fr_ldap_trunk_cmp(void const *one, void const *two)
696 {
697  fr_ldap_thread_trunk_t const *a = one, *b = two;
698  int8_t uricmp = CMP(strcmp(a->uri, b->uri), 0);
699 
700  if (uricmp !=0) return uricmp;
701  if (!a->bind_dn || !b->bind_dn) return CMP(a->bind_dn, b->bind_dn);
702  return CMP(strcmp(a->bind_dn, b->bind_dn), 0);
703 }
704 
705 /** Compare two ldap query structures on msgid
706  *
707  * @param[in] one first query to compare.
708  * @param[in] two second query to compare.
709  * @return CMP(one,two)
710  */
711 static inline int8_t fr_ldap_query_cmp(void const *one, void const *two)
712 {
713  fr_ldap_query_t const *a = one, *b = two;
714 
715  return CMP(a->msgid, b->msgid);
716 }
717 
718 /** Compare two ldap bind auth structures on msgid
719  *
720  * @param[in] one first bind request to compare.
721  * @param[in] two second bind request to compare.
722  * @return CMP(one,two)
723  */
724 static inline int8_t fr_ldap_bind_auth_cmp(void const *one, void const *two)
725 {
726  fr_ldap_bind_auth_ctx_t const *a = one, *b = two;
727 
728  return CMP(a->msgid, b->msgid);
729 }
730 
731 fr_ldap_query_t *fr_ldap_search_alloc(TALLOC_CTX *ctx,
732  char const *base_dn, int scope, char const *filter, char const * const * attrs,
733  LDAPControl **serverctrls, LDAPControl **clientctrls);
734 
735 fr_ldap_query_t *fr_ldap_modify_alloc(TALLOC_CTX *ctx, char const *dn,
736  LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls);
737 
738 fr_ldap_query_t *fr_ldap_extended_alloc(TALLOC_CTX *ctx, char const *reqiod, struct berval *reqdata,
739  LDAPControl **serverctrls, LDAPControl **clientctrls);
740 
741 unlang_action_t fr_ldap_trunk_search(TALLOC_CTX *ctx,
743  char const *base_dn, int scope, char const *filter, char const * const *attrs,
744  LDAPControl **serverctrls, LDAPControl **clientctrls);
745 
746 unlang_action_t fr_ldap_trunk_modify(TALLOC_CTX *ctx,
748  char const *dn, LDAPMod *mods[],
749  LDAPControl **serverctrls, LDAPControl **clientctrls);
750 
753  char const *reqoid, struct berval *reqdata,
754  LDAPControl **serverctrls, LDAPControl **clientctrls);
755 
756 /*
757  * base.c - Wrappers arounds OpenLDAP functions.
758  */
759 void fr_ldap_timeout_debug(request_t *request, fr_ldap_connection_t const *conn,
760  fr_time_delta_t timeout, char const *prefix);
761 
762 size_t fr_ldap_uri_escape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
763  CC_HINT(nonnull(2,4));
764 
765 size_t fr_ldap_uri_unescape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
766  CC_HINT(nonnull(2,4));
767 
768 char const *fr_ldap_error_str(fr_ldap_connection_t const *conn);
769 
770 fr_ldap_rcode_t fr_ldap_search_async(int *msgid, request_t *request,
771  fr_ldap_connection_t *pconn,
772  char const *dn, int scope, char const *filter, char const * const *attrs,
773  LDAPControl **serverctrls, LDAPControl **clientctrls);
774 
776  char const *dn, LDAPMod *mods[],
777  LDAPControl **serverctrls, LDAPControl **clientctrls);
778 
780  char const *dn,
781  LDAPControl **serverctrls, LDAPControl **clientctrls);
782 
784  char const *reqiod, struct berval *reqdata);
785 
786 fr_ldap_rcode_t fr_ldap_error_check(LDAPControl ***ctrls, fr_ldap_connection_t const *conn,
787  LDAPMessage *msg, char const *dn);
788 
789 fr_ldap_rcode_t fr_ldap_result(LDAPMessage **result, LDAPControl ***ctrls,
790  fr_ldap_connection_t const *conn, int msgid, int all,
791  char const *dn,
793 
794 LDAP *fr_ldap_handle_thread_local(void);
795 
796 int fr_ldap_global_config(int debug_level, char const *tls_random_file);
797 
798 int fr_ldap_init(void);
799 
800 void fr_ldap_free(void);
801 
802 /*
803  * control.c - Connection based client/server controls
804  */
805 void fr_ldap_control_merge(LDAPControl *serverctrls_out[],
806  LDAPControl *clientctrls_out[],
807  size_t serverctrls_len,
808  size_t clientctrls_len,
809  fr_ldap_connection_t *conn,
810  LDAPControl *serverctrls_in[],
811  LDAPControl *clientctrls_in[]);
812 
813 int fr_ldap_control_add_server(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit);
814 
815 int fr_ldap_control_add_client(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit);
816 
818 
820 
821 /*
822  * directory.c - Get directory capabilities from the remote server
823  */
824 #define LDAP_DIRECTORY_ATTRS { "vendorname", \
825  "vendorversion", \
826  "isGlobalCatalogReady", \
827  "objectClass", \
828  "orcldirectoryversion", \
829  "supportedControl", \
830  "namingContexts", \
831  NULL }
832 
833 int fr_ldap_directory_result_parse(fr_ldap_directory_t *directory, LDAP *handle,
834  LDAPMessage *result, char const *name);
835 
836 int fr_ldap_trunk_directory_alloc_async(TALLOC_CTX *ctx, fr_ldap_thread_trunk_t *ttrunk);
837 
839 
840 /*
841  * edir.c - Edirectory integrations
842  */
843 unlang_action_t fr_ldap_edir_get_password(request_t *request, char const *dn,
844  fr_ldap_thread_trunk_t *ttrunk, fr_dict_attr_t const *password_da);
845 
846 char const *fr_ldap_edir_errstr(int code);
847 
848 
849 /*
850  * map.c - Attribute mapping code.
851  */
852 int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request,
853  map_t const *map, void *uctx);
854 
855 int fr_ldap_map_verify(map_t *map, void *instance);
856 
857 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);
858 
859 int fr_ldap_map_do(request_t *request,
860  char const *valuepair_attr, fr_ldap_map_exp_t const *expanded, LDAPMessage *entry);
861 
862 /*
863  * connection.c - Connection configuration functions
864  */
866 
868  fr_ldap_config_t const *config, char const *log_prefix);
869 
871 
873 
875 
877  char const *bind_dn, char const *bind_password,
878  request_t *request, fr_ldap_config_t const *config);
879 
880 trunk_state_t fr_thread_ldap_trunk_state(fr_ldap_thread_t *thread, char const *uri, char const *bind_dn);
881 
883 
884 /*
885  * state.c - Connection state machine
886  */
888 
890 
891 /*
892  * start_tls.c - Mostly async start_tls
893  */
895  LDAPControl **serverctrls, LDAPControl **clientctrls);
896 
897 /*
898  * sasl.c - Async sasl bind
899  */
900 #ifdef WITH_SASL
902  char const *mechs,
903  char const *identity,
904  char const *password,
905  char const *proxy,
906  char const *realm,
907  LDAPControl **serverctrls, LDAPControl **clientctrls);
908 
910  int *msgid,
911  fr_ldap_connection_t *ldap_conn);
912 
914  fr_ldap_thread_t *thread,
915  char const *mechs,
916  char const *identity,
917  char const *password,
918  char const *proxy, char const *realm);
919 #endif
920 
921 /*
922  * bind.c - Async bind
923  */
925  char const *bind_dn, char const *password,
926  LDAPControl **serverctrls, LDAPControl **clientctrls);
927 
929  char const *bind_dn, char const *password);
930 
931 /*
932  * uti.c - Utility functions
933  */
934 size_t fr_ldap_common_dn(char const *full, char const *part);
935 
936 bool fr_ldap_util_is_dn(char const *in, size_t inlen);
937 
938 size_t fr_ldap_util_normalise_dn(char *out, char const *in);
939 
940 char *fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in);
941 
942 uint8_t *fr_ldap_berval_to_bin(TALLOC_CTX *ctx, struct berval const *in);
943 
944 int fr_ldap_parse_url_extensions(LDAPControl **sss, size_t sss_len, char *extensions[]);
945 
946 int fr_ldap_attrs_check(char const **attrs, char const *attr);
947 
948 int fr_ldap_server_url_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION const *cs);
949 
950 int fr_ldap_server_config_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION *cs);
951 
952 char const *fr_ldap_url_err_to_str(int ldap_url_err);
953 
955 
956 int fr_ldap_filter_to_tmpl(TALLOC_CTX *ctx, tmpl_rules_t const *t_rules, char const **sub, size_t sublen,
957  tmpl_t **out) CC_HINT(nonnull());
958 
959 /*
960  * referral.c - Handle LDAP referrals
961  */
962 fr_ldap_referral_t *fr_ldap_referral_alloc(TALLOC_CTX *ctx, request_t *request);
963 
965 
966 int fr_ldap_referral_next(fr_ldap_thread_t *thread, request_t *request, fr_ldap_query_t *query);
967 
968 /*
969  * filter.c - Basic filter parsing and filtering
970  */
971 typedef int (*filter_attr_check_t)(char const *attr, void *uctx);
972 
973 fr_slen_t fr_ldap_filter_parse(TALLOC_CTX *ctx, fr_dlist_head_t **root, fr_sbuff_t *filter,
975 
976 bool 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:110
#define UNUSED
Definition: build.h:313
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:101
fr_dcursor_eval_t void const * uctx
Definition: dcursor.h:546
static fr_time_delta_t timeout
Definition: dhcpclient.c:54
static fr_slen_t in
Definition: dict.h:821
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
connection_t * fr_ldap_connection_state_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, fr_ldap_config_t const *config, char const *log_prefix)
Alloc a self re-establishing connection to an LDAP server.
Definition: connection.c:386
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:164
size_t fr_ldap_util_normalise_dn(char *out, char const *in)
Normalise escape sequences in a DN.
Definition: util.c:439
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:650
int fr_ldap_control_add_session_tracking(fr_ldap_connection_t *conn, request_t *request)
size_t fr_ldap_uri_escape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg))
Converts "bad" strings into ones which are safe for LDAP.
Definition: util.c:70
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:517
char const * mech
SASL mech(s) to try.
Definition: base.h:129
struct berval ** values
libldap struct containing bv_val (char *) and length bv_len.
Definition: base.h:361
char const * proxy
Proxy identity, may be NULL in which case identity is used.
Definition: base.h:511
fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS]
Server controls specific to this query.
Definition: base.h:450
LDAP * ldap_global_handle
Hack for OpenLDAP libldap global initialisation.
Definition: base.c:39
LDAPURLDesc * referral_url
URL for the referral.
Definition: base.h:482
LDAPControl ** clientctrls
Controls to pass to the client (library).
Definition: base.h:498
LDAP * fr_ldap_handle_thread_local(void)
Get a thread local dummy LDAP handle.
Definition: base.c:1105
uint8_t * fr_ldap_berval_to_bin(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced buffer.
Definition: util.c:409
int fr_ldap_conn_directory_alloc_async(fr_ldap_connection_t *ldap_conn)
Async extract useful information from the rootDSE of the LDAP server.
Definition: directory.c:287
size_t fr_ldap_dereference_len
Definition: base.c:92
fr_ldap_thread_t * t
Thread this connection is associated with.
Definition: base.h:406
char const * tls_private_key_file
Sets the path to the private key for our public certificate.
Definition: base.h:270
fr_dlist_t entry
Entry in the list of connection references.
Definition: base.h:424
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:298
ldap_filter_logic_t
Logical operators for use in LDAP filters.
Definition: base.h:541
@ LDAP_FILTER_LOGIC_NOT
Definition: base.h:544
@ LDAP_FILTER_LOGIC_OR
Definition: base.h:543
@ LDAP_FILTER_LOGIC_AND
Definition: base.h:542
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:528
fr_ldap_rcode_t ret
Return code of bind operation.
Definition: base.h:624
char * host_uri
Host URI used for referral connection.
Definition: base.h:483
char const * admin_password
Password used in administrative bind.
Definition: base.h:231
fr_ldap_state_t state
LDAP connection state machine.
Definition: base.h:347
fr_ldap_config_t * config
Module instance config.
Definition: base.h:383
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:375
fr_event_timer_t const * ev
Event for timing out the query.
Definition: base.h:459
bool chase_referrals
If the LDAP server returns a referral to another server or point in the tree, follow it,...
Definition: base.h:240
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:211
char ** referral_urls
Referral results to follow.
Definition: base.h:461
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:617
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:371
char const * fr_ldap_error_str(fr_ldap_connection_t const *conn)
Return the error string associated with a handle.
Definition: base.c:210
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:488
char const * tls_certificate_file
Sets the path to the public certificate file we present to the servers.
Definition: base.h:267
char * server
Initial server to bind to.
Definition: base.h:224
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:724
int dereference
libldap value specifying dereferencing behaviour.
Definition: base.h:237
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:463
LDAP * handle
libldap handle.
Definition: base.h:333
int msgid
The unique identifier for this query.
Definition: base.h:453
char const * dn
Base DN for searches, DN for modifications.
Definition: base.h:429
char const * bind_dn
DN connection is bound as.
Definition: base.h:402
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:918
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:400
int serverctrls_cnt
Number of server controls associated with the handle.
Definition: base.h:339
fr_dlist_head_t referrals
List of parsed referrals.
Definition: base.h:462
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:579
char const * admin_identity
Identity we bind as when we need to query the LDAP directory.
Definition: base.h:229
global_lib_autoinst_t fr_libldap_global_config
Definition: base.c:134
fr_ldap_result_code_t ret
Result code.
Definition: base.h:470
fr_ldap_result_parser_t parser
Custom results parser.
Definition: base.h:466
fr_ldap_connection_t * fr_ldap_connection_alloc(TALLOC_CTX *ctx)
Allocate our ldap connection handle layer.
Definition: connection.c:258
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:382
request_t * request
Request this referral relates to.
Definition: base.h:487
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:384
fr_rb_tree_t * queries
Outstanding queries on this connection.
Definition: base.h:351
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:185
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:449
fr_time_delta_t keepalive_idle
Number of seconds a connections needs to remain idle before TCP starts sending keepalive probes.
Definition: base.h:284
char const * dereference_str
When to dereference (never, searching, finding, always)
Definition: base.h:238
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:1052
int fr_ldap_connection_timeout_set(fr_ldap_connection_t const *conn, fr_time_delta_t timeout)
Definition: connection.c:409
fr_ldap_directory_t * directory
The type of directory we're connected to.
Definition: base.h:342
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:172
@ 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: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:754
char const * identity
of the user.
Definition: base.h:509
trunk_request_t * treq
Trunk request this query is associated with.
Definition: base.h:456
fr_event_timer_t const * ev
Event to close the thread when it has been idle.
Definition: base.h:407
fr_rb_node_t node
Entry in the tree of outstanding queries.
Definition: base.h:423
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:666
fr_dlist_head_t refs
Replied to queries still referencing this connection.
Definition: base.h:352
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:742
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:51
int fd
File descriptor for this connection.
Definition: base.h:349
void fr_ldap_state_error(fr_ldap_connection_t *c)
Signal that there's been an error on the connection.
Definition: state.c:134
fr_dlist_t entry
Entry in list of possible referrals.
Definition: base.h:480
int fr_ldap_trunk_directory_alloc_async(TALLOC_CTX *ctx, fr_ldap_thread_trunk_t *ttrunk)
Async extract useful information from the rootDSE of the LDAP server.
Definition: directory.c:257
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:401
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:605
fr_dlist_t entry
Entry in the list of filter nodes.
Definition: base.h:563
const char * sasl_secprops
SASL Security Properties to set.
Definition: base.h:235
struct fr_ldap_referral_s fr_ldap_referral_t
Parsed LDAP referral structure.
Definition: base.h:410
ldap_filter_type_t
Types of parsed LDAP filter nodes.
Definition: base.h:532
@ LDAP_FILTER_GROUP
The filter node is a parent of a group which will be combined using a logical operator.
Definition: base.h:535
@ LDAP_FILTER_NODE
The filter node is an individual one to be evaluated against an attribute.
Definition: base.h:533
void fr_ldap_free(void)
LDAPMessage * result
Previous result.
Definition: base.h:517
fr_time_delta_t keepalive_interval
Interval between keepalive probes.
Definition: base.h:290
fr_time_delta_t tls_handshake_timeout
How long we wait for the TLS handshake to complete.
Definition: base.h:309
int msgid
Of the bind operation. Only used when binding as admin.
Definition: base.h:500
char const * tls_require_cert_str
Sets requirements for validating the certificate the server presents.
Definition: base.h:273
fr_time_delta_t net_timeout
How long we wait in blocking network calls.
Definition: base.h:303
int count
Number of values.
Definition: base.h:363
struct fr_ldap_thread_trunk_s fr_ldap_thread_trunk_t
Thread LDAP trunk structure.
Definition: base.h:327
fr_ldap_config_t const * config
rlm_ldap connection configuration.
Definition: base.h:344
fr_ldap_connection_t * c
to bind. Only used when binding as admin user.
Definition: base.h:507
LDAPControl ** clientctrls
Controls to pass to the client (library).
Definition: base.h:514
#define LDAP_MAX_ATTRMAP
Maximum number of mappings between LDAP and.
Definition: base.h:96
request_t * request
this bind relates to.
Definition: base.h:618
fr_ldap_connection_t * c
to bind. Only used when binding as admin user.
Definition: base.h:494
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:451
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:800
fr_ldap_bind_type_t
Definition: base.h:521
@ LDAP_BIND_SIMPLE
Definition: base.h:522
trunk_request_t * treq
Trunk request this bind is associated with.
Definition: base.h:616
int fr_ldap_box_escape(fr_value_box_t *vb, UNUSED void *uctx)
Definition: util.c:110
char const * tls_ca_path
Sets the path to a directory containing CA certificates.
Definition: base.h:265
uint32_t keepalive_probes
Number of missed timeouts before the connection is dropped.
Definition: base.h:287
char const * realm
SASL realm (may be NULL).
Definition: base.h:512
bool rebind
If use_referral_credentials is false, controls whether we bind as our admin credentials (true) or ano...
Definition: base.h:249
static int8_t fr_ldap_query_cmp(void const *one, void const *two)
Compare two ldap query structures on msgid.
Definition: base.h:711
char const * mechs
SASL mechanisms to run.
Definition: base.h:508
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:924
char const * password
of the user, may be NULL if no password is specified.
Definition: base.h:510
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:695
fr_ldap_config_t config
Config used for this connection.
Definition: base.h:403
char const * fr_ldap_edir_errstr(int code)
Definition: edir.c:326
int tls_require_cert
OpenLDAP constant representing the require cert string.
Definition: base.h:276
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:321
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:701
char * fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced string.
Definition: util.c:390
fr_ldap_state_t fr_ldap_state_next(fr_ldap_connection_t *c)
Move between LDAP connection states.
Definition: state.c:49
fr_table_num_sorted_t const fr_ldap_dereference[]
Definition: base.c:86
char const * identity
Bind identity for referral connection.
Definition: base.h:484
bool start_tls
Send the Start TLS message to the LDAP directory to start encrypted communications using the standard...
Definition: base.h:258
ldap_filter_op_t
Operators for use in LDAP filters.
Definition: base.h:549
@ LDAP_FILTER_OP_BIT_AND
Bitwise AND comparison.
Definition: base.h:556
@ LDAP_FILTER_OP_PRESENT
Attribute present.
Definition: base.h:553
@ LDAP_FILTER_OP_SUBSTR
Attribute matches string with wildcards.
Definition: base.h:552
@ LDAP_FILTER_OP_EQ
Attribute equals value.
Definition: base.h:551
@ LDAP_FILTER_OP_LE
Attribute less than or equal to value.
Definition: base.h:555
@ LDAP_FILTER_OP_BIT_OR
Bitwise OR comparison.
Definition: base.h:557
@ LDAP_FILTER_OP_GE
Attribute greater than or equal to value.
Definition: base.h:554
@ LDAP_FILTER_OP_UNSET
Attribute not set yet.
Definition: base.h:550
int tls_min_version
Definition: base.h:279
bool use_referral_credentials
If true use credentials from the referral URL.
Definition: base.h:245
fr_ldap_query_t * query
Query this referral relates to.
Definition: base.h:481
char const * vendor_str
As returned from the vendorName attribute in the rootDSE.
Definition: base.h:202
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
int tls_mode
Definition: base.h:256
int clientctrls_cnt
Number of client controls associated with the handle.
Definition: base.h:340
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:457
LDAPControl ** serverctrls
Controls to pass to the server.
Definition: base.h:497
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
char const * realm
Kerberos realm.
Definition: base.h:131
char * orig
Text representation of filter for debug messages,.
Definition: base.h:565
fr_ldap_sasl_t admin_sasl
SASL parameters used when binding as the admin.
Definition: base.h:233
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:840
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.
Definition: connection.c:1295
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
ldap_filter_type_t filter_type
Type of this filter node.
Definition: base.h:564
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:516
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:677
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)
Expand values in an attribute map where needed.
Definition: map.c:271
char const * tls_ca_file
Sets the full path to a CA certificate (used to validate the certificate the server presents).
Definition: base.h:262
bool chase_referrals_unset
If true, use the OpenLDAP defaults for chase_referrals.
Definition: base.h:243
#define LDAP_MAP_RESERVED
Number of additional items to allocate in expanded.
Definition: base.h:98
char const ** server_str
Server set in the config.
Definition: base.h:225
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:996
#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:222
trunk_conf_t * bind_trunk_conf
Trunk config for bind auth trunk.
Definition: base.h:385
fr_time_delta_t reconnection_delay
How long to wait before attempting to reconnect.
Definition: base.h:311
uint16_t referral_depth
How many referrals to chase.
Definition: base.h:247
int fr_ldap_directory_result_parse(fr_ldap_directory_t *directory, LDAP *handle, LDAPMessage *result, char const *name)
Definition: directory.c:52
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:295
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:222
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:1026
void * uctx
User data associated with the handle.
Definition: base.h:354
int fr_ldap_parse_url_extensions(LDAPControl **sss, size_t sss_len, char *extensions[])
Parse a subset (just server side sort for now) of LDAP URL extensions.
Definition: util.c:309
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
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:881
LDAPMessage * result
Head of LDAP results list.
Definition: base.h:468
fr_event_list_t * el
Thread event list for callbacks / timeouts.
Definition: base.h:386
fr_ldap_directory_t * directory
The type of directory we're connected to.
Definition: base.h:404
LDAPControl * control
LDAP control.
Definition: base.h:135
int fr_ldap_map_do(request_t *request, char const *valuepair_attr, fr_ldap_map_exp_t const *expanded, LDAPMessage *entry)
Convert attribute map into valuepairs.
Definition: map.c:323
unlang_action_t fr_ldap_edir_get_password(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:295
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:708
char const * rmech
Mech we're continuing with.
Definition: base.h:518
char const * password
Bind password for referral connection.
Definition: base.h:485
char const * tls_min_version_str
Minimum TLS version.
Definition: base.h:278
LDAPControl ** serverctrls
Controls to pass to the server.
Definition: base.h:513
uint16_t port
Port to use when binding to the server.
Definition: base.h:227
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:387
int fr_ldap_connection_timeout_reset(fr_ldap_connection_t const *conn)
Definition: connection.c:431
unlang_action_t fr_ldap_bind_auth_async(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:319
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:495
void(* fr_ldap_result_parser_t)(LDAP *handle, fr_ldap_query_t *query, LDAPMessage *head, void *rctx)
Definition: base.h:414
trunk_t * trunk
Connection trunk.
Definition: base.h:405
fr_ldap_thread_t * thread
This bind is being run by.
Definition: base.h:615
fr_ldap_thread_trunk_t * ttrunk
Trunk this referral should use.
Definition: base.h:486
connection_t * conn
Connection state handle.
Definition: base.h:345
fr_ldap_referral_t * referral
Referral actually being followed.
Definition: base.h:464
size_t fr_ldap_tls_require_cert_len
Definition: base.c:84
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:1075
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:374
fr_rb_tree_t * binds
Tree of outstanding bind auths.
Definition: base.h:388
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
uint32_t ldap_debug
LDAP debug level.
Definition: base.h:320
int(* filter_attr_check_t)(char const *attr, void *uctx)
Definition: base.h:971
fr_rb_node_t node
Entry in the tree of outstanding bind requests.
Definition: base.h:614
fr_ldap_bind_type_t type
type of bind.
Definition: base.h:619
char const ** naming_contexts
Databases served by this directory.
Definition: base.h:213
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:496
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:313
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:448
int fr_ldap_init(void)
Initialise libldap and check library versions.
Definition: base.c:1164
fr_ldap_rcode_t
Codes returned by fr_ldap internal functions.
Definition: base.h:582
@ LDAP_PROC_CONTINUE
Operation is in progress.
Definition: base.h:584
@ LDAP_PROC_SUCCESS
Operation was successful.
Definition: base.h:585
@ LDAP_PROC_REFERRAL
LDAP server returned referral URLs.
Definition: base.h:583
@ LDAP_PROC_TIMEOUT
Operation timed out.
Definition: base.h:602
@ LDAP_PROC_ERROR
Unrecoverable library/server error.
Definition: base.h:587
@ LDAP_PROC_BAD_CONN
Transitory error, caller should retry the operation with a new connection.
Definition: base.h:589
@ LDAP_PROC_NOT_PERMITTED
Operation was not permitted, either current user was locked out in the case of binds,...
Definition: base.h:592
@ LDAP_PROC_REJECT
Bind failed, user was rejected.
Definition: base.h:596
@ LDAP_PROC_REFRESH_REQUIRED
Don't continue with the current refresh phase, exit, and retry the operation with a NULL cookie.
Definition: base.h:604
@ LDAP_PROC_BAD_DN
Specified an invalid object in a bind or search DN.
Definition: base.h:598
@ LDAP_PROC_NO_RESULT
Got no results.
Definition: base.h:600
LDAPURLDesc * ldap_url
parsed URL for current query if the source of the query was a URL.
Definition: base.h:426
Holds arguments for async bind auth requests.
Definition: base.h:613
Holds arguments for the async bind operation.
Definition: base.h:493
Connection configuration.
Definition: base.h:221
Tracks the state of a libldap connection handle.
Definition: base.h:332
Result of expanding the RHS of a set of maps.
Definition: base.h:370
LDAP query structure.
Definition: base.h:422
Parsed LDAP referral structure.
Definition: base.h:479
Contains a collection of values.
Definition: base.h:360
Holds arguments for the async SASL bind operation.
Definition: base.h:506
Thread specific structure to manage LDAP trunk connections.
Definition: base.h:381
Thread LDAP trunk structure.
Definition: base.h:399
libldap global configuration data
Definition: base.h:319
Structure to hold parsed details of LDAP filters.
Definition: base.h:562
Stores all information relating to an event list.
Definition: event.c:411
A timer event.
Definition: event.c:102
unsigned short uint16_t
Definition: merged_model.c:31
unsigned int uint32_t
Definition: merged_model.c:33
unsigned char uint8_t
Definition: merged_model.c:30
ssize_t fr_slen_t
Definition: merged_model.c:35
static const conf_parser_t config[]
Definition: base.c:183
The main red black tree structure.
Definition: rb.h:73
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(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:341
Value pair map.
Definition: map.h:77
An element in a lexicographically sorted array of name to num mappings.
Definition: table.h:49
A time delta, a difference in time measured in nanoseconds.
Definition: time.h:80
Wraps a normal request.
Definition: trunk.c:97
Main trunk management handle.
Definition: trunk.c:195
trunk_state_t
Definition: trunk.h:62
Common configuration parameters for a trunk.
Definition: trunk.h:224
static fr_event_list_t * el
static fr_slen_t head
Definition: xlat.h:406
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:4548
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:4232
static size_t char fr_sbuff_t size_t inlen
Definition: value.h:997
int nonnull(2, 5))
static size_t char ** out
Definition: value.h:997